def play_games(): won_games = [] with tf.name_scope('play_game'): for _ in range(ITTERCOUNT): #generate new game game = TicTac(net=True, rand=True) # Get board state as flat vector inputs = list(game.boards[0]) inputs.extend(game.boards[1]) res = sess.run(results, feed_dict={x: [inputs]}) while game.winner == False: game.visual() game.doturn(netvals=res[0]) game.winner = game.check_win() if game.history[0] == 'X': #learn the last two moves won_games.append(game.history[1:]) #take winning games and build training data print(len(won_games)) for game in won_games: for move in game: inputvals.append(move[0]) targetvals.append(vote_for(move[1])) print(len(won_games) / float(ITTERCOUNT))