我有一个“连接 4”游戏的 java 实现(列和行数可变)。
该实现使用(根据用户的选择)Mini-max 的 Mini-max 算法,带有 Alpha-beta 剪枝,最大搜索深度为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
我需要设计第三个(如果可能更好)功能。有什么建议吗?
先感谢您。