我正在編寫Connect-K簡單AI(不修剪,僅限4層)。我想知道什麼是最好的啓發式這是快速計算。Connect-K的良好啓發式AI
東西比我有更好的:
def eval(board, player)
connections = 0
magnitude = 0
for x in range(0, self.boardW(board)):
for y in range(0, self.boardH(board)):
if(self.get_player(board, x, y) == player): #assuming x and y are in bounds
temp = 1
# keep checking in this direction to find the max temp can be
if (magnitude < temp):
magnitude = temp
if(self.get_player(board, x, y) == player):
connection += 1
........
return connection**2 + magnitude**2
基本上,這應該與它相鄰的點返回的最大連接電路板上的任何點了,加上多少個連續的項目是在任何的8個方向的(上,下,左,右,上,左,下,左,...)
我ķ將大於4;因此我無法進行徹底的樹搜索。