I want to build a player for the following game:
You have a board where position 1
is your player, position 2
is the rival player, -1
is a blocked cell and some positive value is a bonus. You can move up, down, left, or right. Also, each bonus has a timer until it disappears (number of steps). Furthermore, each move has a timeout limit. At the end game, when at least one of the players is stuck, we check the scores and announce the winner.
Board example:
-1 -1 0 0 0 -1 -1 -1
-1 0 -1 -1 -1 0 0 340
-1 -1 0 0 0 -1 0 0
-1 0 0 -1 1 -1 0 -1
-1 0 0 -1 -1 0 0 0
0 0 -1 -1 -1 0 2 -1
0 -1 0 0 -1 0 0 600
-1 -1 0 0 -1 -1 -1 -1
0 -1 0 0 0 0 -1 -1
I'm using the MiniMax algorithm with a time limit to play the game. If we got to children, we return $\infty$ for a player win, $-\infty$ for the rival win, and $0$ for a tie. If we got to a specific depth, we calculate the heuristic value. If we got timeout in some place in MiniMax, then we return the last calculated direction. I'm trying to figure out a good strategy to win this game or get to a tie if no solution is possible.
What heuristic function would you define?
What I thought - four factors:
- $f_A$ - The number of steps possible from each direction from the current position.
- $f_B$ - The analytical distance from the center.
- $f_C=\max_{b\in Bonus}\frac{X * I}{Y}$ - where $X$ is value of the bonus, $I$ is $1$ if we can get to the bonus, before it disappears (otherwise $0$) and $Y$ is the distance between the bonus and the player.
- $F_D$ - The distance between the players. The final formula: $$ f(s)=0.5\cdot(9-f_A(s))+0.2\cdot f_C(s)-0.2\cdot f_D(s)-0.1\cdot f_B(s) $$
I'm not sure if it will be a good strategy for that game or not. How would you define the heuristic function? It should also be quick to calculate it because the game has a timeout for each move.
In order words, what will give us the best indication that our player is going to win/lose/tie?