在python中查看Unbeatable tic Tac toe bot的代码,我在类中找到了这两个函数:
def __minimax(self, player):
if self.won():
if player:
return (-1,None)
else:
return (+1,None)
elif self.tied():
return (0,None)
elif player:
best = (-2,None)
for x,y in self.fields:
if self.fields[x,y]==self.empty:
value = self.move(x,y).__minimax(not player)[0]
if value>best[0]:
best = (value,(x,y))
return best
else:
best = (+2,None)
for x,y in self.fields:
if self.fields[x,y]==self.empty:
value = self.move(x,y).__minimax(not player)[0]
if value<best[0]:
best = (value,(x,y))
return best
def best(self):
return self.__minimax(True)[1]
使用best
和__minimax
调用True
[1]
函数的功能如何?
True
和[1]
代表什么?