Exemple #1
0
    return possible_moves_lst[max_index(scores)]


if __name__ == "__main__":
    while not game.is_game_over()[0]:
        if game.current_turn == 1:
            best_move = get_moves_computer(thing_1)

            game.move_piece(best_move.oldLoc, best_move.newLoc)
        else:

            if HUMAN_PLAYING:
                piece, move = get_moves_human()
                game.move_piece(piece, move)

            else:
                game.flip_board_nocopy()  # flip it for use

                best_move = get_moves_computer(thing_2)

                game.move_piece(best_move.oldLoc, best_move.newLoc)

                game.flip_board_nocopy()  # flip it back

        print(game)
        print(
            "############################################################################"
        )
        # time.sleep(2)
                        scores = [thing_1.predict(vec)[0, 0] for vec in possible_state_vecs]
                    else:
                        scores = [thing_2.predict(vec)[0, 0] for vec in possible_state_vecs]

                    best_move = possible_moves_lst[max_index(scores)]

                    game.move_piece(best_move.oldLoc, best_move.newLoc)

                    if team_for_real == 1:
                        thing1_state_vecs.append(game.get_alt_state_vec())
                    else:
                        thing2_state_vecs.append(game.get_alt_state_vec())

                    if should_display_game_results and team_for_real == 1:
                        print(game)
                    game.flip_board_nocopy()
                    if should_display_game_results and team_for_real == -1:
                        print(game)

                    if should_display_game_results:
                        print("#############################################################################")
                    team_for_real *= -1
                    moves_taken += 1


                did_we_win = game.is_game_over()
                print("Played", i, "of", games_per_itr, "games")
                # post game memory
                who_actually_won = team_for_real * did_we_win[1]

                thing1_score = ((who_actually_won + 1) / 2) * 6 / moves_taken