def get_game_info(self, force_update: bool = False) -> state_delta.StateDelta: """ Queries the game for all of the information on the board.""" if force_update or self._current_state_delta is None: self._connection.send_data('info') data: bytes = self._connection.receive_data() # TODO: Should this also set the current state delta? return state_delta.state_delta_from_dict(json.loads(data.decode('utf-8'))) return self._current_state_delta
def _execute_leader(self, action: agent_actions.AgentAction) -> None: """ Executes an action taken by the leader. Input: action (agent_actions.AgentAction): The action taken by the leader. Returns: Whether the action increased the score (collected a card). Raises: ValueError if it's not the leader's turn. """ time.sleep(self._args.get_action_delay()) self._connection.send_data('human, ' + str(action)) self._current_state_delta = state_delta.state_delta_from_dict( json.loads(self._connection.receive_data().decode('utf-8')))
def _execute_follower(self, action: agent_actions.AgentAction) -> None: """ Executes the specified action for the follower in the environment. Inputs: action (str): The action that the follower should take. Returns: Whether it was still the Follower's turn when the action finished. Raises: ValueError if it's not the follower's turn. """ time.sleep(self._args.get_action_delay()) if action != agent_actions.AgentAction.START and action != agent_actions.AgentAction.STOP: self._connection.send_data('agent, ' + str(action)) self._current_state_delta = state_delta.state_delta_from_dict( json.loads(self._connection.receive_data().decode('utf-8'))) if action == agent_actions.AgentAction.STOP: # The STOP action maps to finishing a command for the follower. self._connection.send_data('finishcommand') _ = self._connection.receive_data()