Coral Growth

Source

Four simulations, one automaton, one starting grid. Each simulation draws its own random numbers, so the same starting configuration ends up growing differently in every world. Pausing one doesn't affect the others.

const sea = element("sea", "darkblue")
const coral = element("coral", "coral")
const growth = element("growth", "yellow")
const bubble = element("bubble", "blue")
const rising = element("rising", "blue")

          
sea.to(bubble).is(BOTTOM, rising)
sea.to(growth)
  .is(BOTTOM, growth)
  .chance(50, 100)
  .accept("all")
sea.to(growth)
  .count(growth, 1)
  .chance(42, 100)
  .accept("all")
sea.to(bubble).chance(1, 5000)

          
bubble.to(sea).chance(1, 200)
bubble.to(rising).chance(4, 7)

          
rising.to(sea).is(TOP, sea)
rising.to(sea).is(TOP, coral)
rising.to(sea)
  .is(TOP, bubble)
  .is(TOP, rising)
  .accept("any")
rising.to(sea).is(TOP, TOP).accept("none")
rising.to(bubble)

          
growth.to(coral)
coral.to(growth).count(coral, 0).chance(1, 500)

          
const coralGrowth = create()

          
for (const canvas of canvases) {
  await setup({ canvas, automaton: coralGrowth, initialGrid })
}
Read the docs
@wonderyard/vivarium