def nextstate(self, board, player, action): if action == self.gbsize * self.gbsize: return board, -player b = Phan(self.gbsize, self.win_standard) b.board = np.copy(board) move = (int(action / self.gbsize), action % self.gbsize) b.moving(move, player) return b.board, -player
def validmove(self, board, player): valids = [0] * self.actionsize() b = Phan(self.gbsize, self.win_standard) b.board = np.copy(board) dun_soo = b.dun_soo() if len(dun_soo) == 0: valids[-1] = 1 return np.array(valids) for x, y in dun_soo: valids[self.gbsize * x + y] = 1 return np.array(valids)
def Run(): try: b = Phan(13, 5) board = Omokgame.startphan() b.board = np.copy(board) display = visual(13, 5) display.prepare_display() f = fight(13, 5) human_move = f.Act(b.board) best_model = nn.loading("folder", "model1") best_mcts = mcts(Omokgame(13, 5), best_model) except KeyboardInterrupt: print("error")
def nextstate(self, board, new_board, player, action): if action == self.gbsize * self.gbsize: return board, -player b = Phan(self.gbsize, self.win_standard) b.board = np.copy(board) b.new_board = np.copy(new_board) move = (int(action / self.gbsize), action % self.gbsize) b.moving(move, player) b.dim_moving(move, player) b.new_board[2] = self.oneminusone(np.copy(b.board), -player) return b.board, -player, b.new_board
def Act(self, board): try: where = input("move, ex(3,7)") b = Phan(self.gbsize, self.win_standard) b.board = np.copy(board) b.moving(where, self.human) board = np.copy(b.board) except Exception as e: move = -1 if move == -1 or move not in Omokgame( self.gbsize, self.win_standard).validmove(board, self.human): print("Impossible move, retry") move = self.Act(board) return move
def ggeutnam(self, board, player): b = Phan(self.gbsize, self.win_standard) b.board = np.copy(board) if b.iswin(player): return 1 if b.iswin(-player): return -1 if b.ganeung_soo(): return 0 return 1e-4
def startphan(self): b = Phan(self.gbsize, self.win_standard) return np.array(b.board)
def dim_board(self): b = Phan(self.gbsize, self.win_standard) return b.board3d