Esempio n. 1
0
    def policy_moves_cmd(self, args):
        if len(self.board.get_empty_points()) == 0:
            self.respond()
            return

        if self.current_policy == 0:
            #only plays random move for now
            move = self.go_engine.simulate_random(self.board,
                                                  self.board.current_player)
            # answer = []
            # #color
            # answer[0] = int_to_color(self.board.current_player)

            #coordinate
            coords = point_to_coord(move, self.board.size)
            answer = format_point(coords)
            self.respond("Random {}".format(answer))
            #self.respond(self.board.get_empty_points())
            return
        else:
            formatted = []
            moves = GoBoardUtil.generate_rule_move_gomoku(
                self.board, self.board.current_player)
            if moves == PASS:
                self.respond()
                return
            for move in moves[1]:
                coords = point_to_coord(move, self.board.size)
                answer = format_point(coords)
                formatted.append(answer)
            formatted = sorted(formatted)
            answer = ' '.join(formatted)
            self.respond("{} {}".format(moves[0], answer))
            #self.respond(self.board.board)
            return
Esempio n. 2
0
 def simulate_rule_based(self, board, color):
     #####Fill in here#####
     if len(GoBoardUtil.generate_legal_moves(board, color)) == 0:
         return 'PASS'
     temp_board = board.copy()
     rule, move = GoBoardUtil.generate_rule_move_gomoku(temp_board, color)
     if rule != "Random":
         np.random.shuffle(move)
         return rule, move[0]
         # return move
     else:
         move = self.simulate_random(board, color)
         return "Random", move