# Setup NN net = JasonNet() current_NN = net best_NN = net if not os.path.isdir("model_data"): os.mkdir("model_data") logger.info("Starting to train...") for i in range(args.iteration, args.total_iterations): logger.info(F"Iteration {i}") # Play a number of Episodes (games) of self play to generate data generate_data(current_NN, episodes, search_depth, i) # original monte carlo #run_monte_carlo(current_NN, 0, i, episodes, search_depth) # Train NN from dataset of monte carlo tree search above train_net(current_NN, i, args.lr, args.bs, args.epochs) # Fight new version against reigning champion in the Arena # Even with first iteration just battle against yourself arena = Arena(best_NN, current_NN) best_NN = arena.battle(episodes // 2, search_depth) # Save the winning net as a Pickle for battle later save_as_pickle(i, best_NN) print("End of the main driver program. Training has completed!")
from Arena import Arena from IPython.display import clear_output arena = Arena() while True: print(''' 1. Create pokemon 2. Show Existing pokemon 3. Battle 4. Quit ''') choice = int(input('Enter your choice:')) if choice == 1: arena.create_pokemon() elif choice == 2: arena.show_all() pass elif choice == 3: clear_output() arena.battle() pass else: break
from RockBot import RockBot from ScissorsBot import ScissorsBot from PaperBot import PaperBot from BeatLastBot import BeatLastBot from RockThenPaperThenScissorsBot import RockThenPaperThenScissorsBot from ScissorsThenPaperThenRockBot import ScissorsThenPaperThenRockBot from Arena import Arena if __name__ == '__main__': rockBot = RockBot() scissorsBot = ScissorsBot() paperBot = PaperBot() beatLastBot = BeatLastBot() rockThenPaperThenScissorsBot = RockThenPaperThenScissorsBot() scissorsThenPaperThenRockBot = ScissorsThenPaperThenRockBot() arena = Arena() arena.battle(beatLastBot, rockThenPaperThenScissorsBot, 20) arena.__init__() beatLastBot.__init__() arena.battle(beatLastBot, scissorsThenPaperThenRockBot, 20)