## Train Station Math

Hey all!

### Introduction:

A video by great Youtuber Mathematician James Grime (aka singingbanana) recently posted a video on a new train station in Cambridge, with some very interesting patterns on it (above). While not derived from Conway’s Game of Life, it is derived from an automata, dubbed Rule 135 by mathematician Stephen Wolfram. Here’s a link (and the wiki page) if you’re interested. It’s an interesting cellular automata that can be described with a positive integer no greater than $$2^8$$, or $$256$$. Below is an example.

(example is from Rule 30; picture is from the Wolfram MathWorld page.)

### So, why the name?

Good question!

Notice that the above number can be written as $$00011110_2$$. Convert that to decimal, and you get the number 30. Similarly, if you had rule 255. that just means that you’d have to colour in every grind, regardless; if you had rule 0, you wouldn’t have to colour in any grid at all.

So, to answer your question, it’s simply a matter of ‘Rule 35 sounds better than “Rule 00011110 in base 2″‘.

Now that we’ve got the naming out of the way…

### Here’s how it works:

1. Define a starting position. For example, I could have a row of all blank grids, and one filled in in the middle.
2. For each grid in the second row, look at the grid directly above it, the grid to the upper-left, and to the upper right. The pattern will decide if the grid we’re looking at is coloured or not. For example: if the grid I was looking at had the grid above it filled in, the grid to the upper-left blank, and the upper-right filled in, then we’d have to find the picture corresponding to that picture (fifth one from the left), and see that the grid ought to be filled in.do this for every grid in the row, then move on to the next row. Rinse and repeat.

Here’s a little demo that I hacked up in JSBin with canvas: Demo

You can get some really beautiful pictures in this: I’ve used the ruleN.randomise() function, and they look great! Block size was set to 50, iterations to 10.

### Epilogue

I think it’s amazing that such a basic rule – turning grids black or white can produce such mesmerizing patterns! What’s more, many of them have very interesting properties! Some of them are logic gates: Rule 90 is a XOR gate, along with Rule 110 being proven a Turing Machine! Imagine trying to run a simple ‘Hello World’ on that! My favourite Rule is probably 90, which has the property of generating a Sierpinski Triangle….  Spoilers! I might make a short article explaining the code, but I think the comments are pretty self-explanatory.