Elementary Cellular Automaton Image Generator

1 minute read

I am at work right now, enjoing the benefits of having a job that allows me to surf the web all day and do nothing really! I think I will use some of the time spent working to keep my site updated so here we go...

size/m/242882650

I just finished my CS61C HW, Elementary Cellular Automaton, which basically takes 2 numbers as args, the first being the number of lines generated after the "seed" line, and the other a code between 0 and 255, which when converted to a binary number, gives a sequence of 1's and 0's. ex: 30 -> 00011110 The top line is provided . It is a blank line that has 1 pixel "on" in the middle of it. To generate the next lines of code, each pixel determines if it is "on" or not, it looks at the consequent pixels in the row above it to the left, up, and right. If one of the upper pixels is on, it is marked with a 1. Then we look at the 3 digit sequence, for example, 110, and after converting that to binary, 6, we look to see if the 6th bit (starting from the right) in the original code (00011110) is a 1 (it's not) and then turn the current pixel "on" if the code bit is on. Otherwise it stays off. Dont worry if you didn't get that... just look at the cool patterns it creates. The one above is 1022 line generations against the code the code 126 (01111110 in binary). Almost off-shift so I'm off to Di's to do my EE100 HW

Was this page helpful for you? Buy me a slice of πŸ• to say thanks!

Updated:

Comments