Create Each Do

From StarLogo Nova Wiki
Revision as of 18:02, 11 August 2023 by Admin (talk | contribs) (Marked this version for translation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Other languages:
The Create Each Do Block

Creates the specified number of agents of the selected breed. Each newly created agent immediately follows the directions specified in "do".

The created agents have the default shape, color, and size specified in their breed’s ‘Show Traits’ area. They are created in the middle of the terrain, on the ground (x=0, y=0, z=0), with their headings evenly distributed, starting at 0 degrees (e.g. if 4 are created, one will start out facing toward each of the 4 sides of spaceland.) The turtles then follow the instructions provided within the each do hook once.

create [_] [▼](s) each do is a code block part of the agents drawer.

Usage

create [_] [▼](s) each do is used to populate Spaceland with agents and then run a stack of code individually for each agent. This can be useful for making many agents and setting different traits for each.

Syntax

The Create Each Do Block

Inputs in this block:

  1. a number in the socket
  2. a breed from the dropdown menu
  3. relevant code


Example

Create Each Do example gif
Create Each Do example code

When setup is pushed, The World creates 100 turtles, and each of those turtles follow the instructions within the “each do” block. In this example, each turtle takes on a random color and moves to a random position in spaceland. All turtles are created, change color, and relocate in one tick of the StarLogo clock.

Nuances

create [_] [▼](s) each do is very similar to create [_] [▼](s). Both create agents, but generally create [_] [▼](s) each do allows for more complex and powerful usages.

Related Blocks

Relevant Video Resources

Relevant Activities