2015-12-16 LabN08

posted Dec 16, 2015, 4:56 AM by Samuel Konstantinovich   [ updated Dec 16, 2015, 4:56 AM ]
Goal: Cellular Automata

HW: Complete conways game of life

Regarding yesterday's lab:

If you think about your code using big ideas, and write functions to do those ideas, you will meet with more success.

Most of your cellular automata can be written in the following way using 'big ideas':

to go
  ask patches
  [   pickNextColor   ]
  ask patches
  [   changeColor   ]

OR in this specific case, since color is dependent on neighbor counts:

to go
  ask patches
  [   countNeighbors   ]
  ask patches
  [   changeColor   ]

PickColor will be different for different automata, but the separation of deciding what you want to be, and the changing into that new state must be clear.

LabN08  Conway's game of life:


Patches are either Alive or Dead
Each type of patch exhibits different behavior. This is a variation on what you have done already with voting. 

Alive  (pcolor is lime)
    Alive patches sometimes stay alive, and sometimes die.

Dead (pcolor is black)
    Dead patches sometimes stay dead, and sometimes are re-born.

You must be careful not to allow a patch to die then be reborn at the same time! 
In order to do this, do not change color right away, instead make a variable to store the "nextColor" so that you can make sure everyone bases their next state on the current state.

Similar to before, you calculate all patches first, then you change later:
ask living patches [ calculate next state]
ask dead patches [ calculate next state]
ask all patches [ change to next state]

How do we calculate the next state? We use different rules for each cellular automata:

Birth / Survival  notation:

3B/23S is notation that means:
3B:      3 living neighbors means a DEAD cell will Be born (otherwise stay dead)
23S:    2 or 3 living neighbors means a LIVING cell will Survive (otherwise die)

Here are some other rules:

Make slider:

Make Buttons:
    -clear the world. Fill the world with some living patches (Use the percent-alive slider for the % you want to be alive)
    -Run your conway model rules, calculating the next state and changing state.