本文整理汇总了Python中ai.AI.getNextMove方法的典型用法代码示例。如果您正苦于以下问题:Python AI.getNextMove方法的具体用法?Python AI.getNextMove怎么用?Python AI.getNextMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ai.AI
的用法示例。
在下文中一共展示了AI.getNextMove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import getNextMove [as 别名]
def main(args):
gameType = args[1] if len(args) > 1 else constants.NO_AI
game = BigBoard()
ai = AI(game)
print 'Welcome to Ultimate Tic-Tac-Toe! X goes first. Denote moves ' \
'with an ordered pair (row, col) where the top left is (0,0)\n\n' \
'Example move: 4,4'
if gameType == constants.TWO_AI:
ai2 = AI(game)
print game
while not game.getState():
game.makeMove(ai2.getNextMove())
print game
if not game.getState():
game.makeMove(ai.getNextMove())
print game
else:
print game
while not game.getState(): # game ongoing
move = raw_input('Enter your move: ')
try:
coords = (int(move[0]), int(move[2]))
except:
coords = (9, 9)
if game.makeMove(coords) == constants.ILLEGAL_MOVE:
print 'Illegal move. Try again: '
else:
print game
if gameType == constants.ONE_AI and not game.getState():
game.makeMove(ai.getNextMove())
print game
result = game.getState()
if result == constants.X_WIN:
print 'X wins!'
elif result == constants.O_WIN:
print 'O wins!'
else:
print 'Tie game!'