How to calculate Heuristic values for minimax

I am developing a software for a board game (2 player) which has 10x4 cells and both the players have 9 pieces each. Initially, the pieces for player 1 will be at the top of the board and for player 2 all the pieces will be at the bottom of the board (similar to chess but a lot less complex!).

I have used MiniMax algorithm to calculate the next best move. Now, the algorithm itself seems to work fine. The problem that I am facing is in Heuristic value calculation. If there is no best move found in the depth till I am searching (4 currently), my code simply takes the first step which it finds from the move list. That is probably because the score of all the moves are same till the depth of 4!

So, it just keeps stalling. Eg., it will move piece 1 from position A to B in 1st turn and in the 2nd turn it will move the same piece from position B to A. It keeps on doing that until the opponent moves closer to my pieces.

Now, what I want would love to know is how do I make sure that if the opponent is NOT closing in, I do that instead of stalling. Currently, I am calculating the heuristic values based on the difference between my pieces and opp pieces. How to calculate the values such that those moves which lead to position closer to the opponent's pieces are selected? Appreciate your help! Thanks!

链接地址: http://www.djcxy.com/p/56406.html

上一篇: 如何为游戏创建一个好的评估函数?

下一篇: 如何计算minimax的启发式值