We proceed with the recipe as follows:
- We need to start by loading the necessary libraries for this script, as follows:
import tensorflow as tf import matplotlib.pyplot as plt import csv import random import numpy as np import random
- Next, we declare the following batch size for training our model:
batch_size = 50
- To make visualizing the boards a bit easier, we will create a function that outputs Tic Tac Toe boards with Xs and Os. This is done with the following code:
def print_board(board): symbols = ['O', ' ', 'X'] board_plus1 = [int(x) + 1 for x in board] board_line1 = ' {} | {} | {}'.format(symbols[board_plus1[0]], symbols[board_plus1[1]], symbols[board_plus1[2]]) board_line2 = ' {} | {} | {}'.format(symbols[board_plus1[3]], ...