if mode == 'NextOne': player = NextOne(Stone("○"),name,education_bord) elif mode == 'CountStone': player = CountStone(Stone("○"),name,education_bord) elif mode == 'Random': player = Random(Stone("○"),name,education_bord) elif mode == 'Q_learning': player = Q_learning(Stone("○"),name,education_bord) elif mode == 'Naive': player = Naive(Stone("○"),name,education_bord) elif mode == 'MLP': player = MLP_p(Stone("○"),name,education_bord) return player player1 = get_player('MLP','P1','black') player2 = get_player('Random','P2','white') player1.battleMode() game = Othello(nplay=600,show_result=True,show_board=False) game.play(player1,player2) # player2 = get_player('Q_learning','P2','white','no') # game = Othello(nplay=120000,show_result=True,show_board=False) # game.play(player1,player2) # player1.q.save('p1.pickle') # player2.q.save('p2.pickle') # player1.battleMode() # print() # player2 = get_player('Random','P2','white') # game = Othello(nplay=600,show_result=True,show_board=False) # game.play(player1,player2)
from Othello import Othello from Othello import AI import numpy as np import matplotlib.pyplot as plt generation = int(input('Which generation do you wish to play against:')) w1 = np.load('weights\weight-Gen{:03d}-1.npy'.format(generation)) w2 = np.load('weights\weight-Gen{:03d}-2.npy'.format(generation)) ai = AI(weight1=w1, weight2=w2) player = int( input( 'Which player do you wish to be (black: -1, white: 1) (or choose another ai):' )) game = Othello() print(np.average(np.abs(w1))) print(np.average(np.abs(w2))) if player > 1: w1 = np.load('weights\weight-Gen{:03d}-1.npy'.format(player)) w2 = np.load('weights\weight-Gen{:03d}-2.npy'.format(player)) ai2 = AI(weight1=w1, weight2=w2) ai.set_name('Gen' + str(generation)) ai2.set_name('Gen' + str(player)) game.play_self(ai, ai2, display_board=True) else: game.play(ai, player) # n, bins, patches = plt.hist(w1, 50, normed=1, facecolor='green', alpha=0.75) # plt.show()