When I was a kid, I used to draw "random" straight lines that made cool pattens, and turned every once in a while. I got pretty good at it, but realized that I was making many of the same shapes. I wondered what it would look like if it was random, and started flipping a coin to change the direction of the snake. Many years later, once I learned how to code, I created it in java. The java code exported a file containing coordinates, which I linked to a JMP script to plot with even more code.


Recently, I used Matlab to quickly write up the code. It runs fairly slowly due to how Matlab handles array indexing, but using Matlab allowed me to really easily analyze my data. Below are a few examples of the plots it gave me.


The chart at the bottom is A histogram of ~300,000 runs of the program. Number of deaths is on the Y axis, and number of moves on the X axis. The curve is interesting, as you can see some even-odd differences in the number of moves. No matter how many times it is run, for example, it is more likely to die on move 83 than 82 or 84. There's also a snake that turns every time, which makes for some interesting patterns.

Click to expand!