NetLogo Models

Biology

Flocking

Flocking is an emergent behavior. No leader is required. Birds (fish, turtles, agents, etc.) follow three local rules:

Alignment: Heading = average heading of neighbors

to align
   turn-towards average-flockmate-heading max-align-turn
end

Separation: Turn away if closest neighbor gets too close

to separate
   turn-away (heading-of nearest-neighbor) max-separate-turn
end

Coherence: Heading = move closer to neighbors

to cohere
   turn-towards average-heading-towards-flockmates max-cohere-turn
end

Ants

Cooperation

Evolution seems to favor greedy or selfish behavior. Can evolution explain cooperative or altruistic behavior? In this model we can ask what conditions will favor greedy cows that eat grass down to the roots and cooperative cows that only eat the tips.

Patches have grass; cows (turtles) have energy:

turtles-own [ energy ]
patches-own [ grass ]

Patches grow grass. The probability that a patch of grass will grow back depends on its height. If above the low-high-threshold, then the probability is good, otherwise it is low:

to grow-grass
  ifelse ( grass >= low-high-threshold) [
    if (high-growth-chance >= (random-float 100)) [
      set grass grass + 1
    ]
  ][
    if (low-growth-chance >= (random-float 100)) [
      set grass grass + 1
    ]
  ]
  if (grass > max-grass-height) [
    set grass max-grass-height
  ]
end

Cows move, eat, and reproduce:

ask turtles [
    move
    eat
    reproduce
  ]

Cows reproduce only if they have enough energy. Cows use energy to reproduce:

to reproduce
  if (energy > reproduction-threshold) [
    set energy energy - reproduction-cost
    hatch 1 [ ]
  ]
end

Cows move in random directions. Cows use energy to move and die  if they use all of their energy:

to move
  rt random-float 360
  fd stride-length ; set by user
  set energy energy – metabolism ; set by user
  if (energy < 0) [ die ]
end

There are two breeds of cows: cooperative and greedy.

breed [ cooperative-cows cooperative-cow ]
breed [ greedy-cows greedy-cow ]

Cooperative cows only eat grass if the height is above a certain threshold:

to eat-cooperative
  if (grass > low-high-threshold) [
    set grass grass - 1
    set energy energy + grass-energy
  ]
end

Greedy cows don't care about thresholds:

to eat-greedy  ;; turtle procedure
  if (grass > 0) [
    set grass grass - 1
    set energy energy + grass-energy
  ]
end

Conclusions:

Wanderlust favors the greedy. Take it all, and then move on.

High metabolism is bad for everyone, especially the greedy.
Grass that grows back slowly favors cooperative cows.

AIDS

Wolf-Sheep

Ecologists are interested in stability of predator-prey populations. Usually logistics equations tell us that as

In a stable predator-prey system populations fluctuate according to the logistics equation:

population = (1 - population) * population

As the wolf population increases, the sheep population decreases, and the grass population increases. Eventually wolves begin to starve. This causes an increase in the sheep population, which decreases the grass population but increases the wolf population.

 

There are two breeds of turtles: sheep and wolves:

breed [ sheep a-sheep ]
breed [ wolves wolf ]

Sheep and wolves have energy:

turtles-own [ energy ]

The color of a patch (brown or green) determines if grass is present. Patches own a countdown that determines how long it will take to turn green again:

patches-own [ countdown ]

 

In each cycle a sheep takes a step, tries to eat grass, and tries to reproduces:

ask sheep [
    move ; take 1 step in a random direction
    set energy energy - 1 
    eat-grass ; eat any grass here
    reproduce-sheep
    if (energy < 0) [die]
  ]

In any cycle a sheep reproduces with a given probability. If this happens, the parent gives half of its energy to its offspring.

In each cycle a wolf takes a step, tries to eat a sheep, and tries to reproduce:

ask wolves [
    move ; take 1 step in a random direction
    set energy energy - 1
    catch-sheep
    reproduce-wolves
    if energy < 0 [ die ]
  ]

If a wolf finds a sheep, it kills and eats it:

to catch-sheep
   ; find a nearby ungrabbed sheep
   let prey one-of (sheep-here with [not grabbed?])
   if prey != nobody ; got one?
   [
      set grabbed?-of prey true ; grab it
      ask prey [ die ] ; kill it
      set energy energy + wolf-gain-from-food ; eat it
   ]
end

 

Social Science

Ethnocentrism

Wealth Distribution

PD

Rebellion

Computer Science

CA 1D Elementary