def __init__(self, go_engine, board, debug_mode=False):
        """
        GTP connection of Go3
        """
        GtpConnection.__init__(self, go_engine, board, debug_mode)

        self.commands['policy'] = self.policy_cmd
        self.commonds['selection'] = self.selection_cmd
        self.commands['policy_moves'] = self.policy_moves_cmd
        self.commands['genmove'] = self.genmove_cmd

        self.argmap['policy'] = (1, 'Usage: policy random|pattern')
        self.argmap['selection'] = (1, 'Usage: selection rr|ucb')
        self.argmap['genmove'] = (1, 'Usage: genmove b|w')
예제 #2
0
    def __init__(self, go_engine, board, debug_mode=False):
        """
        GTP connection of Go1

        Parameters
        ----------
        go_engine :
            a program that is capable of playing go by reading GTP commands
        komi : float
            komi used for the current game
        board: GoBoard
            SIZExSIZE array representing the current board state
        """
        GtpConnection.__init__(self, go_engine, board, debug_mode)
        self.commands["hello"] = self.hello_cmd
        self.argmap["hello"] = (0, 'Usage: hello')
예제 #3
0
    def __init__(self, go_engine, board, outfile = 'gtp_log', debug_mode = False):
        """
        GTP connection of Go1

        Parameters
        ----------
        go_engine : GoPlayer
            a program that is capable of playing go by reading GTP commands
        komi : float
            komi used for the current game
        board: GoBoard
            SIZExSIZE array representing the current board state
        """
        GtpConnection.__init__(self, go_engine, board, outfile, debug_mode)
        self.commands["prior_knowledge"] = self.prior_knowledge_cmd
        self.commands["genmove"] = self.genmove_cmd
        self.argmap["prior_knowledge"] = (0, 'Usage: prior_knowledge')
        self.argmap["genmove"] = (1, 'Usage: genmove {w,b}')
    def __init__(self, go_engine, board, debug_mode=False):
        """
        GTP connection of Go3
        """
        GtpConnection.__init__(self, go_engine, board, debug_mode)

        self.commands["selfatari"] = self.selfatari_cmd
        self.commands["use_pattern"] = self.use_pattern_cmd
        self.commands["random_simulation"] = self.random_simulation_cmd
        self.commands["use_ucb"] = self.use_ucb_cmd
        self.commands["num_sim"] = self.num_sim_cmd
        self.commands[
            "legal_moves_for_toPlay"] = self.legal_moves_for_toPlay_cmd
        self.commands["policy_moves"] = self.policy_moves_cmd
        self.commands["random_moves"] = self.random_moves_cmd
        self.commands["gogui-analyze_commands"] = self.gogui_analyze_cmd

        self.argmap["selfatari"] = (1, 'Usage: selfatari BOOL')
        self.argmap["use_pattern"] = (1, 'Usage: use_pattern BOOL')
        self.argmap["random_simulation"] = (1, 'Usage: random_simulation BOOL')
        self.argmap["use_ucb"] = (1, 'Usage: use_ucb BOOL')
        self.argmap["num_sim"] = (1, 'Usage: num_sim #(e.g. num_sim 100 )')
예제 #5
0
        for n in range(self.num_simulation):
            board_copy = board.copy()
            self.MCTS._playout(board_copy, color)

        if print_info:
            self.MCTS.good_print(board, self.MCTS._root, color,self.num_nodes)
    
    def reset(self):
        self.MCTS = MCTS()

    def update(self, move):
        self.MCTS.update_with_move(move)

    def get_move(self, board, color):
        move = self.MCTS.get_move(board,
                color,
                komi=self.komi,
                limit=self.limit,
                selfatari=self.selfatari,
                pattern=self.pattern,
                num_simulation = self.num_simulation,
                exploration = self.exploration)
        self.update(move)
        return move

if __name__=='__main__':
    c = GtpConnection(Go6Player(num_simulation))
    c.start_connection()

예제 #6
0
파일: Go1.py 프로젝트: phlam1/cmput496_A2
def run():
    """
    start the gtp connection and wait for commands.
    """
    con = GtpConnection(RandomPlayer())
    con.start_connection()
def createPolicyPlayer():
    con = GtpConnection(PolicyPlayer())
    con.start_connection()
예제 #8
0
 def test_size_2(self):
     board = SimpleGoBoard(2)
     con = GtpConnection(Go0(), board)
     con.start_connection()