<jupyter_start><jupyter_text>Performance during training<jupyter_code>MCTS_ITER = 100
DIR = 'models/checkpoints/tictactoe'

az_games_played = list(range(0, 1000 + 1, 100))
az_training_draws = list()

minimax = Minimax(game)

# Before starting training
_, draws, _ = parallel_play(game, TicTacToeAdapter(), minimax,
                            color='black', max_workers=10,
                            mcts_iter=MCTS_ITER, games=100)
az_training_draws.append(draws)

for filename in os.listdir(DIR):
    _, draws, _ = parallel_play(game, TicTacToeAdapter(), minimax,
                                os.path.join(DIR, filename),
                                color='black', max_workers=10,
                                mcts_iter=MCTS_ITER, games=100)
    az_training_draws.append(draws)

az_training_draws
mcts = MonteCarloTree(game, max_iter=MCTS_ITER, reset_tree=False)
_, mcts_draws_, _ = play(game, minimax, mcts, games=100, max_workers=10)
mcts_draws_
import matplotlib.pyplot as plt


plt.plot([az_games_played[0], az_games_played[-1]], [mcts_draws_, mcts_draws_], '--')
plt.plot(az_games_played, az_training_draws, '-o')
plt.legend(['MCTS', 'AlphaZero'])
plt.xlabel('games played')
plt.ylabel('draws with black')
plt.savefig('images/az_training.png')<jupyter_output><empty_output><jupyter_text>Performance after training<jupyter_code>mcts_draws = list()
az_draws = list()
iters = (2, 20, 100, 200)

for m in iters:
    _, draws, _ = parallel_play(game, TicTacToeAdapter(), Minimax(game),
                                'models/TicTacToe.h5', 'black', max_workers=10,
                                mcts_iter=m, games=100)
    az_draws.append(draws)

for m in iters:
    mcts = MonteCarloTree(game, max_iter=m, reset_tree=False)
    _, draws, _ = play(game, minimax, mcts, games=100, max_workers=10)
    mcts_draws.append(draws)

mcts_draws, az_draws
plt.plot(iters, mcts_draws, '-o')
plt.plot(iters, az_draws, '-o')
plt.legend(['MCTS', 'AlphaZero'])
plt.xlabel('iterations')
plt.ylabel('draws with black')
plt.savefig('images/az_vs_mcts.png')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1314148681055156, 'fraction_numerical': 0.023501199040767386, 'mean_word_length': 3.708803611738149, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '13978', 'license': 'MIT', 'n_tokens_mistral': 851, 'n_tokens_neox': 781, 'n_words': 127, 'path': 'experiments/Tic-Tac-Toe evaluation.ipynb', 'repo_name': 'TFG-AlphaZero/Implementacion-TFG', 'size': '2085'}