예제 #1
0
def start():
    config = OptimizerConfig()
    tf_util.update_memory(config.gpu_mem_fraction)
    util.set_high_process_priority()
    AIPlayer.create_if_nonexistant(config)
    models = sorted(glob.glob(config.data.model_location+"*.h5"))
    ai = AIPlayer(config.buffer_size, 1, model=models[-1], compile=True)
    train(ai, config)
예제 #2
0
def start():
    config = OptimizerConfig()
    tf_util.update_memory(config.gpu_mem_fraction)
    util.set_high_process_priority()
    AIPlayer.create_if_nonexistant(config)
    models = sorted(glob.glob(config.data.model_location + "*.h5"))
    ai = AIPlayer(config.buffer_size, 1, model=models[-1], compile=True)
    train(ai, config)
예제 #3
0
 def run(self):
     self.game_gui = Canvas(self.root, width=600, height=600, background='green')
     self.game_gui.bind("<Button-1>", self.click)
     self.game_gui.focus_set()
     self.game_gui.bind("<Key>", self.key)
     self.game_gui.pack()
     for i in range(1, 8):
         self.game_gui.create_line(0, i*75, 600, i*75)
         self.game_gui.create_line(i*75, 0, i*75, 600)
     
     self.pieces = []
     for i in range(8):
         self.pieces.append([])
         for j in range(8):
             self.pieces[i].append(self.game_gui.create_oval(i*75+5, j*75+5, (i+1)*75-5, (j+1)*75-5, fill="green", outline="green"))
     
     self.root.protocol("WM_DELETE_WINDOW", self.on_closing)
     self.root.resizable(0,0)
     self.running = True
     config = EvaluateConfig()
     tf_util.update_memory(config.gpu_mem_fraction)
     AIPlayer.create_if_nonexistant(config)
     self.game = Othello()
     if(random() > 0.5):
         self.human = 1
     else:
         self.human = -1
     
     ai = create_player(config.model_1, config)
     #print("You are playing against", config.model_1)
     #print("Playing games with %d simulations per move" % config.game.simulation_num_per_move)
     self.side = -1
     self.draw_board()
     self.value = ai.evaluate(self.game, self.side)
     while self.running and not self.game.game_over():
         #play move
         if self.side != self.human:
             self.value = ai.evaluate(self.game, self.side)
             self.root.title("Othello (Thinking of Move) Current Value: %0.2f (1 white wins, -1 black wins)" % self.value)
             self.root.config(cursor="wait")
             t = ai.pick_move(self.game, self.side)
             self.game.play_move(t[0], t[1], self.side)
             self.draw_board()
             self.side *= -1
             self.value = ai.evaluate(self.game, self.side)
         else:
             if len(self.game.possible_moves(self.side)) == 0:
                 self.side *= -1
                 continue
             if self.side == -1:
                 color = "black"
             else:
                 color = "white"
             self.root.title("Othello (Play as %s) Current Value: %0.2f (1 white wins, -1 black wins)" % (color, self.value))
             self.root.config(cursor="")
             if self.update:
                 self.update = False
                 if (self.x, self.y) in self.game.possible_moves(self.side):
                     self.game.play_move(self.x, self.y, self.side)
                     self.draw_board()
                     self.side *= -1
         time.sleep(0.01)
     if self.human == self.game.get_winner():
         self.root.title("Othello (You Win!)")
     elif self.game.get_winner() == 0:
         self.root.title("Othello (Its a draw!)")
     else:
         self.root.title("Othello (You Lose!)")
예제 #4
0
def start():
    config = EvaluateConfig()
    tf_util.update_memory(config.gpu_mem_fraction)
    AIPlayer.create_if_nonexistant(config)
    run_games(config)
예제 #5
0
def start():
    config = EvaluateConfig()
    tf_util.update_memory(config.gpu_mem_fraction)
    AIPlayer.create_if_nonexistant(config)
    run_games(config)
예제 #6
0
def start():
    config = RankingConfig()
    tf_util.update_memory(config.gpu_mem_fraction)
    AIPlayer.create_if_nonexistant(config)
    calc_ranking(config)
예제 #7
0
 def run(self):
     self.game_gui = Canvas(self.root, width=600, height=600, background='green')
     self.game_gui.bind("<Button-1>", self.click)
     self.game_gui.focus_set()
     self.game_gui.bind("<Key>", self.key)
     self.game_gui.pack()
     for i in range(1, 8):
         self.game_gui.create_line(0, i*75, 600, i*75)
         self.game_gui.create_line(i*75, 0, i*75, 600)
     
     self.pieces = []
     for i in range(8):
         self.pieces.append([])
         for j in range(8):
             self.pieces[i].append(self.game_gui.create_oval(i*75+5, j*75+5, (i+1)*75-5, (j+1)*75-5, fill="green", outline="green"))
     
     self.root.protocol("WM_DELETE_WINDOW", self.on_closing)
     self.root.resizable(0,0)
     self.running = True
     config = EvaluateConfig()
     tf_util.update_memory(config.gpu_mem_fraction)
     AIPlayer.create_if_nonexistant(config)
     self.game = Othello()
     if(random() > 0.5):
         self.human = 1
     else:
         self.human = -1
     
     ai = create_player(config.model_1, config)
     #print("You are playing against", config.model_1)
     #print("Playing games with %d simulations per move" % config.game.simulation_num_per_move)
     self.side = -1
     self.draw_board()
     self.value = ai.evaluate(self.game, self.side)
     while self.running and not self.game.game_over():
         #play move
         if self.side != self.human:
             self.value = ai.evaluate(self.game, self.side)
             self.root.title("Othello (Thinking of Move) Current Value: %0.2f (1 white wins, -1 black wins)" % self.value)
             self.root.config(cursor="wait")
             t = ai.pick_move(self.game, self.side)
             self.game.play_move(t[0], t[1], self.side)
             self.draw_board()
             self.side *= -1
             self.value = ai.evaluate(self.game, self.side)
         else:
             if len(self.game.possible_moves(self.side)) == 0:
                 self.side *= -1
                 continue
             if self.side == -1:
                 color = "black"
             else:
                 color = "white"
             self.root.title("Othello (Play as %s) Current Value: %0.2f (1 white wins, -1 black wins)" % (color, self.value))
             self.root.config(cursor="")
             if self.update:
                 self.update = False
                 if (self.x, self.y) in self.game.possible_moves(self.side):
                     self.game.play_move(self.x, self.y, self.side)
                     self.draw_board()
                     self.side *= -1
         time.sleep(0.01)
     self.root.config(cursor="")
     if self.human == self.game.get_winner():
         self.root.title("Othello (You Win!)")
     elif self.game.get_winner() == 0:
         self.root.title("Othello (Its a draw!)")
     else:
         self.root.title("Othello (You Lose!)")
예제 #8
0
def start():
    config = RankingConfig()
    tf_util.update_memory(config.gpu_mem_fraction)
    AIPlayer.create_if_nonexistant(config)
    calc_ranking(config)
def start():
    config = SelfPlayConfig()
    tf_util.update_memory(config.gpu_mem_fraction)
    util.set_low_process_priority()
    AIPlayer.create_if_nonexistant(config)
    run_games(config)