def black_tree(): statemachine = state_machine.StateMachine() model = mock_model.MockModel() tree = azts_tree.AztsTree(model=model, \ color=BLACK, \ rollouts_per_move=10) return tree
def new_player(): model = mock_model.MockModel() config = utility.load_player_conf("Player/default_config.yaml") new_p = player.Player(color=BLACK, \ model=model, \ rollouts_per_move=10, \ **(config.player.as_dictionary())) return new_p
def rollout_node(): model = mock_model.MockModel() # testing: model responds with all ones when(model).inference(...).thenReturn((np.ones(MOVE_TENSOR_SHAPE), 1)) statemachine = state_machine.StateMachine() node = azts_node.AztsNode(statemachine, model) for i in range(10): node.rollout() return node
def new_match(): model = mock_model.MockModel() conf = utility.load_player_conf("Player/default_config") player_one = player.Player(model=model, \ rollouts_per_move=10, \ **(conf.player.as_dictionary())) player_two = player.Player(model=model, \ rollouts_per_move=10, \ **(conf.player.as_dictionary())) new_match = match.Match(player_one, player_two) return new_match
def load_model(conf): ''' load model from configuration :param Configuration conf: configuration of model ''' model = None if conf.mock: model = mock_model.MockModel() elif conf.stockfish.enable: model = None else: #TODO: connect to mlflow here! model = AZero(conf) return model
def set_up(color=WHITE): ''' helper function to initialise all data structures :return tuple: containing a state machine, a model and an azts tree that has been initialised with that state machine and model. ''' statemachine = state_machine.StateMachine() model = mock_model.MockModel() tree = AztsTree(statemachine=statemachine, \ model=model, \ color=color, \ rollouts_per_move=200) np.set_printoptions(suppress=True, precision=3) return statemachine, model, tree
def lose_node(): model = mock_model.MockModel() statemachine = state_machine.StateMachine() statemachine.set_to_fen_state(WIN_STATE) node = azts_node.AztsNode(statemachine, model, WHITE) return node
def stale_node(): model = mock_model.MockModel() statemachine = state_machine.StateMachine() statemachine.set_to_fen_state(STALE_MATE) node = azts_node.AztsNode(statemachine, model, BLACK) return node
def initial_node(): model = mock_model.MockModel() statemachine = state_machine.StateMachine() node = azts_node.AztsNode(statemachine, model) return node
def receive_move(self, move): ''' update own state machine and print feedback to player ''' if self.color is not self.statemachine.get_player_color(): print(f"> Other player played {move}") self.statemachine.actual_fen_move(move) # TODO: implement other getters and setters def game_over(self): return self.statemachine.actual_game_over() def get_stats(self): return None def dump_data(self): return [None, None, None] if __name__ == "__main__": model = mock_model.MockModel() configuration = config.Config("Player/default_config.yaml") player = Player(model=model, **(configuration.player.as_dictionary())) print(f"First move of white player is {player.make_move()}.") print(player.get_stats()) # pylint: enable=E0401