1. Home
  2. Docs
  3. MATRX features
  4. Simulation, agent and action speeds

Simulation, agent and action speeds

Depending on the type of experiment, it is desirable to tune the speed of specific actions, specific agents, or the complete simulation. Below is described how these aspects can be configured in MATRX.

Simulation speed

The simulation speed can be changed by passing the tick_duration parameter to the WorldBuilder constructor:

factory = WorldBuilder(random_seed=1, shape=[14, 20], tick_duration=0.1)

As described in the API reference, the tick_duration is “The duration of a single ‘tick’ or loop in the game-loop of the world you create. Defaults to 0.5.”

One way in using this parameter is to speed up the MATRX simulation: setting the tick_duration to 0 will run the MATRX simulation as quick as possible. This is very handy when MATRX simulations have to be run as fast as possible, for instance to gather data required for training a neural network. If running the simulation as quick as possible is your goal, it is recommended to also disable the MATRX visualizer (run_matrx_visualizer=False) and MATRX API (run_matrx_api=False) in the WorldBuilder to speed up the process even more. See the API reference on how to do this.

For a user experiment with human agents a tick_duration of 0.1 is recommended, which means every second, 10 ticks are performed. Setting the tick_durationto a higher value will make the input lag for human agents very noticeable.

Action speed

Every action performed by a (human)agent has a certain action_duration. This parameter indicates how many ticks the agent is busy working on this action. By default this action_duration is set to 0 for all actions, which means the action is performed and the next tick the agent is done and immediately ready to perform a new action. Setting the action_duration to 10, means the agent is busy for 10 ticks (tick 0 – 9) before executing the action (tick 10), and is available again at tick 11.

busy_black_small

If desired, it is also possible to visualize in the default MATRX GUI when an agent is busy with an action, by displaying a gear icon. Simply add visualize_when_busy=True to your agent when adding it to your WorldBuilder:

factory.add_human_agent([6, 6], HumanAgentBrain(), name="human", visualize_when_busy=True)

Agent speed

Instead of setting the action_duration of every action for a specific agent, the PatrollingAgent shows an example of how the action_duration might be set for all actions of an agent in one go. For the example, see the PatrollingAgent here. A parameter has been added to this custom artificial agent that let’s the user specify the move_speed of the PatrollingAgent when adding it to the users usecase file. The move_speed is then used by the PatrollingAgent as the default for the action_duration of every action it executes as decided in its decide_on_action:

    def decide_on_action(self, state):
        # determine which action needs to be performed
        move_action = self.navigator.get_move_action(self.state_tracker)

        return move_action, {"action_duration": self.move_speed}
Was this article helpful to you? Yes No

Leave a Reply

Your email address will not be published.