Living Museum of Learning

Small circles, Big thinkers 🌱
Nicole and the Two Worlds

Nicole and the Two Worlds

How a broken beehive led to the discovery of array copying

In the previous class, Nicole implemented the update rules for Conway's Game of Life. The initial pattern was a small "beehive" made of six living cells.

The rules appeared correct. Neighbor counts were computed properly, and cells were updated according to the standard rules.

Yet something strange happened.

A six-second clip captured the result: the stable beehive suddenly collapsed.

The world seemed to change while it was still being observed.

At first, Nicole tried:

arr1 = arr0

The idea seemed natural: create a second array and update it.

But an experiment revealed something surprising.

Changing one array changed the other.

The two worlds were not separate.

They were the same world.

To understand this, we stepped back from the Game of Life itself and experimented with copying one-dimensional arrays. Nicole then built a new array element by element using push().

Only after understanding how copying works did we return to the larger problem.

Nicole implemented:

let worldCopy = copyArr(world)

The update rules now operated on the copy while neighbor counts continued to read from the original world.

Only after all updates were completed did the new world replace the old one.

The beehive remained stable.

The simulation finally behaved correctly.

The class extended ten extra minutes as Nicole completed the entire copying function herself and watched the world evolve properly for the first time.

Assignment is not the same as copying.

Two names can refer to the same object.

Experiments on smaller problems can reveal larger ideas.

Simulations often require both a current world and a next world.

Computer science sometimes requires creating a second reality before changing the first.