Camo Lab

Turtles swim around a pond. They interact by competing or mating. Turtles with lower visibility tend to win competitions, thereby increasing their fitness while lowering the fitness of the loser. The visibility of a turtle is the difference between the turtle's color and the color of the pond. The color of the pond can be adjusted using a slider. This simulates changing conditions in the environment.

Mating turtles must have above average fitness. The color of an offspring is the average of the colors of its parents.

Here's a screen shot:

As the user changes the pond color by moving the slider, the mean color of the turtles should slowly approach the new color.

Implementation

Camo Lab customizes the BAM2 framework.

In addition to energy, mobility, and vision, turtles also have an age attribute that is incremented each time the turtle is updated. A turtle dies when its energy is less than or equal to zero or when its age is greater than 100.

Turtles interact with each other by either competing or mating:

to interact [candidate]
  ifelse age mod 10 = 0
  [
    mate-with candidate
  ]
  [
    compete-with candidate
  ]
end

When turtle T1 competes with T2, each computes a random number less than its visibility. The turtle with the lowest number wins and is awarded N units of energy; the loser loses N units of energy. (For now try N = 3).

The visibility of a turtle is the absolute value of the difference between the turtle's color and the pond color. Each patch in the pond takes its color from the patch-color slider, which allows the user to dynamically adjust the color of the pond to any value from 0 to 140.

T1 and T2 can mate if both have above average fitness. There is also some luck involved. Only M% of the time does mating produce an offspring. (For now try M = 60.) The color of the offspring will be the average of the colors of the parents.