Skip to main content

My

Returns the value of an agent's trait.

My block

Description​

The My block returns the value of an agent's trait. This is a code block part of the Traits drawer.

Usage​

Returns the value of an agent's trait.

Syntax​

Inputs in this block:

  • A category of trait from the dropdown menu

Example​

The use of the 'my trait' block in this example ensures that the fish do not swim below the seafloor by ensuring their z coordinate, selected from the traits drop down, is >= 0 before the fish are rendered.

My example code

Notes​

The My block allows agents to access their own trait values, which is essential for conditional logic and state management in simulations.

  • Set My to - Set an agent's trait value
  • Of - Access another agent's trait value
  • Set of to - Set another agent's trait value