CS010
Introduction to Computer Science I

Term Project

Deliverable One

Celluar Automata:

Building Blocks

(last updated 11/10/2005)

Term Project

Deliverable One

Celluar Automata:

Building Blocks

(last updated 11/10/2005)

Update: [11/10] Note the change to the parameters to the show-all function at the bottom of this page.

For the first deliverable, you will become familiar with cellular automata (CA) and implement the building blocks for future deliverables. See one of many descriptions of cellular automata. For this first deliverable, we will only consider one-dimensional CAs. One of the key elements of CAs is state. We will define states to be 1 or 0.

Once you understand the basics of cellular automata, we need come up with data definitions. First, we need to represent rules; that is, a way to determine the new state of a cell based on the pattern of its neighbors. If we assume a left-to-right ordering on cells and a neighborhood of three cells (one to either side of a given cell, plus itself), we can associate the patterns with the numbers 0 through 7. Thus, a vector of 8 cells can represent a rule. The content of an indexed cell will be the new value of the cell centered in the corresponding pattern. For example, a cell that is off and with both neighbors on (101 -- binary for the number 5) would have a new value found in (vector-ref this-rule 5) for a rule stored in a vector called this-rule.

Next, we need to represent the universe. Since we're starting with one-dimensional CAs, let's represent the universe as a list. One important thing to note is that the ends of the universe wrap around. That is, the far-right cell is the left neighbor of the far-left cell.

With rules and universes in place, we want to develop a program that will update the universe according to a given rule.

Finally, we would like a way to visualize the universe over time. We can do this by rendering a snapshot of the universe as a line across the canvas. The line will consist of dots wherever corresponding cells are on. The line above will be the previous state of the universe and the line below will be the following state.

Putting this all together, I want you to write a function, show-all, that consumes three arguments: a rule (vector), the number of generations to render or simulate (height of the canvas), and the initial universe state (listof states). When I call this function with my arguments, I should see a canvas appear (of the appropriate dimensions) and then a picture develop that shows the evolution of the universe.

;; a state is either 1 or 0I hope you will have fun with this project.

;; show-all: (vectorof state) number number (listof state) -> true