Nearest Within Steps With =

From StarLogo Nova Wiki
Other languages:
Nearest within steps with =

Returns the closest agent of a selected breed in a given radius with a specific trait.

nearest [▼] within [_] steps with [▼] = [_] is a code block part of the Detection drawer.

Usage

nearest [▼] within [_] steps with [▼] = [_] is used to refer to the nearest agent of a selected breed AND trait that exists within a given step limit in Spaceland.

Syntax

Nearest Within Steps With =

Inputs:

  1. a breed from the first dropdown menu
  2. a number

Example

Nearest Within Steps With = example gif
Nearest Within Steps With = example code

This is a model of a grazing herd of hungry elephants. In this model, there are two species of grass (blue and red). The elephants prefer blue glass but do not mind red grass. Because the elephants want to eat as much bue grass as possible, they walk toward the blue grass that is closest to them within their sensing radius (while eating red grass if they happen across it on the way). Toward the end of the simulation, you can observe that there is plenty of leftover red grass.

Common Uses

Nuances

Related Blocks