本文整理匯總了Python中Engine.Engine.get_one_ply_materialistic_move方法的典型用法代碼示例。如果您正苦於以下問題:Python Engine.get_one_ply_materialistic_move方法的具體用法?Python Engine.get_one_ply_materialistic_move怎麽用?Python Engine.get_one_ply_materialistic_move使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Engine.Engine
的用法示例。
在下文中一共展示了Engine.get_one_ply_materialistic_move方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from Engine import Engine [as 別名]
# 或者: from Engine.Engine import get_one_ply_materialistic_move [as 別名]
class Game:
def __init__(self):
self.board = ChessBoard()
self.engine = Engine()
pass
def play_game(self, withAI=False, verbose=False):
while not self.is_game_over():
if verbose:
print self.board
if withAI:
if self.board.is_whites_turn():
self.play_move()
else:
self.play_ai_move()
else:
self.play_move()
print str(self.board) + "\n" + "Game Over! {}".format(self.board.outcome)
def auto_play(self):
while not self.is_game_over():
self.play_ai_move()
print str(self.board) + "\n" + "Game Over! {}".format(self.board.outcome)
def is_game_over(self):
return self.board.is_game_over
def play_move(self):
move = raw_input("Enter move: (example: e2e4): ")
if not self.board.attempt_to_make_move(move):
print "\n Invalid Move! \n"
def play_ai_move(self):
origin, destination = self.engine.get_one_ply_materialistic_move(self.board)
self.board.execute_move(origin, destination)
print "Computer plays: {}{}".format(origin, destination)