def yield_move_analyses(self, moves_list): playable_game = PlayableChessGame() uci_moves = [] evaluations = [] for move in moves_list: self.uci_client.set_position_from_moves_list(uci_moves) evaluations.append(self.uci_client.evaluate_position()) uci_moves.append(playable_game.make_move_from_algebraic_and_return_uci(move)) yield move, uci_moves[-1], evaluations[-1]
def yield_move_analyses(self, moves_list): playable_game = PlayableChessGame() uci_moves = [] evaluations = [] for move in moves_list: self.uci_client.set_position_from_moves_list(uci_moves) evaluations.append(self.uci_client.evaluate_position()) uci_moves.append( playable_game.make_move_from_algebraic_and_return_uci(move)) yield move, uci_moves[-1], evaluations[-1]
def perform_analysis(game): from ChessUtil.playable_game import PlayableChessGame pg = PlayableChessGame() with game_analyzer.ChessGameAnalyzer() as analyzer: for move_num, (move, uci_move, (best_move, score)) in enumerate( analyzer.yield_move_analyses(game.moves) ): pg.make_move_from_algebraic_and_return_uci(move) white_score = score if not move_num % 2: print move_num/2 + 1 print "White to move." else: print "Black to move." white_score *= -1 if white_score > 0: print "White Winning" elif white_score < 0: print "Black Winning" print "%4s - %5s, %d" % (move, best_move, score) pg._board.print_board()