Figure out which step are we in the simulation

How can an agent tell which step we are in the simulation? Say a behavior changes color of agent in 10 steps from now, how can the agent tell which step the simulation is?

ie how to return the simulation step

Is there a unique identifier for an agent that is always created and can be accessed?



Agents can individually track the simulation step by using the published behavior. You can add it to your simulation by using the lower left sidebar, and then add it to your agents’ behavior array like so:

  "behaviors": ["@hash/"],

You can then access the age field of the agent using state.get("age").

Regarding your second question, yes! Each agent is generated with a field called “agent_id” which is guaranteed to be unique uuid string. You can access it using state.get("agent_id").

Let me know if there’s anything else I can clarify for you.

Thank you Nur,
Tried let age = the state.get(“age”) and then I console log it, I get null (?) on the developer’s console i opened.
it is under:
in move_around.js , what am I doing wrong.?

I am successful at getting the agent ids , thanks again


ok, got it to work.

Only after I added it the “” in the init,json under behavor but not when I added it to the behavior of the specific agent.
What is the difference between the two locations I added the “”

That’s a good question. The distinction is between the ‘creator’ agent and the agents that are moving around in your simulation. This page of the docs explains how creator agents work, existing only for the first step of the simulation in order to generate the rest of the agents.

When you added the behavior under the creator agent:

    "name": "creator",
    "behaviors": [

the behavior was not added to the actual agents you see later on in the simulation (since the creator agent is removed after the first step). When you added it to the behavior array under “scatter_templates” this made sure that the generated agents had the age behavior added to them:

"scatter_templates": [
        "template_name": "horses",
        "template_count": 4,
        "behaviors": ["color_change.js","move_around.js","@hash/"],
        "height": 2,
        "random_movement_step_size": 3