def test_parse_ggf(): ggf = parse_ggf(GGF_STR) eq_("8", ggf.BO.board_type) eq_(64, len(ggf.BO.square_cont)) eq_("*", ggf.BO.color) eq_(8, len(ggf.MOVES)) eq_("B", ggf.MOVES[0].color) eq_("F5", ggf.MOVES[0].pos) eq_("W", ggf.MOVES[1].color) eq_("F6", ggf.MOVES[1].pos)
def set_game(self, ggf_str): """Tell the engine that all further commands relate to the position at the end of the given game, in GGF format. Required:The engine must update its stored game state. :param ggf_str: see https://skatgame.net/mburo/ggsa/ggf . important info are BO, B+, W+ """ ggf = parse_ggf(ggf_str) black, white, actions = convert_to_bitboard_and_actions(ggf) player = Player.black if ggf.BO.color == "*" else Player.white self.engine.set_game(GameState(black, white, actions, player)) # if set_game at turn=1~2 is sent, reset engine state. if len(actions) <= 1: self.engine.reset_state() # clear MCTS cache
def test_parse_ggf_board_to_bitboard(): ggf = parse_ggf(GGF_STR) black, white = parse_ggf_board_to_bitboard(ggf.BO.square_cont) eq_(EXPECTED1.strip(), board_to_string(black, white).strip())