coopihc.bundle.Simulator.Simulator
- class Simulator(*args, task_model=None, user_model=None, assistant=None, **kwargs)[source]
- Bases: - coopihc.bundle.Bundle.Bundle- Methods - Close the bundle once the game is finished. - open- quarter_step- Combines all render methods. - Reset bundle. - Play a round - Attributes - parameters- The round number in the game (0 to N) - state- turn_dict- The turn number in the game (0 to 3) - render(mode, *args, **kwargs)
- Combines all render methods. - Parameters
- mode – “text” or “plot” 
- type – string 
 
 
 - reset(go_to=None, start_after=None, task=True, user=True, assistant=True, dic={}, random_reset=False)
- Reset bundle. - Reset the game and start at a specific turn number. 
- select which components to reset 
- forced reset mechanism using dictionnaries 
 - Example: - new_target_value = self.game_state["task_state"]["targets"] new_fixation_value = self.game_state["task_state"]["fixation"] ) reset_dic = {"task_state": {"targets": new_target_value, "fixation": new_fixation_value}} self.reset(dic=reset_dic, turn = 1) - Will set the substates “targets” and “fixation” of state “task_state” to some value. - Note - If subclassing BaseBundle, make sure to call super().reset() in the new reset method. - Parameters
- turn (int, optional) – game turn number. Can also be set globally at the bundle level by passing the “reset_turn” keyword argument, defaults to 0 
- start_after (int, optional) – which turn to start at (allows skipping some turns during reset), defaults to 0 
- task (bool, optional) – reset task?, defaults to True 
- user (bool, optional) – reset user?, defaults to True 
- assistant (bool, optional) – reset assistant?, defaults to True 
- dic (dict, optional) – reset_dic, defaults to {} 
- random_reset (bool, optional) – whether during resetting values should be randomized or not if not set by a reset dic, default to False 
 
- Returns
- new game state 
- Return type
 
 - property round_number
- The round number in the game (0 to N) - Returns
- turn number 
- Return type
- numpy.ndarray 
 
 - step(user_action=None, assistant_action=None, go_to=None, **kwargs)
- Play a round - Play a round of the game. A round consists in 4 turns. If go_to is not None, the round is only played until that turn. If a user action and assistant action are passed as arguments, then these are used as actions to play the round. Otherwise, these actions are sampled from each agent’s policy. - Parameters
- action (assistant) – user action 
- action – assistant action 
- go_to (int, optional) – turn at which round stops, defaults to None 
 
- Type
- any 
- Type
- any 
- Returns
- gamestate, reward, game finished flag 
- Return type
- tuple( - State, collections.OrderedDict, boolean)
 
 - property turn_number
- The turn number in the game (0 to 3) - Returns
- turn number 
- Return type
- numpy.ndarray