我有一个Java实现的“Connect 4”游戏(具有可变列数和行数)。
根据用户选择,此实现使用Mini-max算法或Alpha-beta剪枝的Mini-max算法,在搜索的最大深度为maxDepth时停止。
我的问题是设计一个良好的状态评估函数来评估棋盘(这是在maxDepth返回的值)。
该值介于-100(最差选择,对应于失败情况)和100(最佳选择,对应于获胜情况)之间,其中0被认为是“平局”状态。
实际上,我已经实现了两个函数(因为代码很长,我将提供伪代码):
1)
- 无胜负
--> 如果表已满 ==> 平局(0)
--> 如果表未满 ==> 不确定的情况(50)
- 赢
--> 如果我方获胜:100
--> 如果对手获胜:-100
2)
Of me:
- InARow[0] = maximum number of pieces in a HORIZONTAL in a row
- InARow[1] = maximum number of pieces in a VERTICAL in a row
- InARow[2] = maximum number of pieces in a DIAGONAL (ascending) in a row
- InARow[3] = maximum number of pieces in a DIAGONAL (descending) in a row
Of the opponent
- InARow2[0] = maximum number of pieces in a HORIZONTAL in a row
- InARow2[1] = maximum number of pieces in a VERTICAL in a row
- InARow2[2] = maximum number of pieces in a DIAGONAL (ascending) in a row
- InARow2[3] = maximum number of pieces in a DIAGONAL (descending) in a row
value = (100* (InARow[0] + InARow[1] + InARow[2] + InARow[3]) )/16 - (100* (InARow2[0] + InARow2[1] + InARow2[2] + InARow2[3]) )/16
我需要设计一个第三个(如果可能的话更好的)函数。有什么建议吗?
提前感谢。