Basic Agent Model 2

BAM2 extends BAM. Here's the framework:

bam2.nlogo

In BAM2 turtles have energy, vision, and mobility:

turtles-own [energy vision mobility]

Energy is a random number below 100. A turtle dies when his energy reaches 0.

Vision and mobility are random numbers below world-diam, where world-diam is the diameter of the turtle's world. Initially, this is set to 5. The idea is that turtles (and patches) are rather provincial. They only know about the nearby world.

Vision determines how far a turtle can see when it searches for a mate, opponent, or partner.

Mobility determines how far a turtle moves each time it's updated.

When a turtle updates, he moves, interacts, and dies if his energy is 0:

to update-turtle
  move
  let candidate
      one-of other turtles in-radius vision with [qualified?]
  if candidate != nobody
  [
    interact candidate
  ]
  if energy <= 0 [die]
end

Here a statechart diagram representing the update-turtle sub-state of the update-model state:

Candidate Selection

Candidate selection involves several useful NetLogo procedures:

AGENT-SET in-radius R

Reports the subset of AGENT-SET within radius R of the active agent.

AGENT-SET with [CONDITION]

Reports the subset of AGENT-SET for which CONDITION is true.

other AGENT-SET

Reports the subset of AGENT-SET excluding the active agent.

one-of AGENT-SET

Reports a random member of AGENT-SET. It reports a special null value called nobody if AGENT-SET is empty.

Helpers

Turtles move randomly:

to move
  rt random 360
  fd mobility
end

Interacting with the candidate (mate, fight, negotiate, play with, etc.) is empty:

to interact [candidate]
 
end

Initially, all agents are qualified to be a candidate:

to-report qualified?
  report true
end

More typically we might want to only interact with healthy agents:

to-report qualified?
   report energy > 50
end

BAM2 Examples

Brawling Turtles

Mating Turtles