Cellular Automaton

This is a challenge exercise. It is not compulsory, and may be completed individually or with your lab partner.

For this activity, you will need to complete a program called cellular.c.

Download cellular.c, or copy it into your current directory on a CSE system by running

$ cp /web/cs1511/17s2/week05/files/cellular.c .

This program is a simple life simulator. It is an example of a 1-dimensional cellular automaton. In this simulation, the world is represented by an array. Each element of the array is a single cell which can contain up to 1 creature. If it contains a creature, we call it ALIVE. If it contains no creatures, we call it DEAD.

The simulation will advance between generations. Every time it moves to a new generation each cell may

Your task is to complete the function nextGeneration, which takes in an array of the current generation and the next generation, and sets all of the values of the cells in the next generation. Currently, this function makes every generation the same.

The rules for what happens on each generation are:

There are no tests for this activity, so feel free to have some fun. Try and see what happens to the output if you change the rules.

To run Styl-o-matic:

$ 1511 stylomatic cellular.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk05_cellular

Or, if you are working from home, upload the relevant file(s) to the wk05_cellular activity on Give Online.