I was gaming the other night, and suddenly missed the sight of a warm fire next to me. I grew up with a wood stove, so am quite fond of it. Unfortunately, my apartment does not have a fireplace – so I decided to simulate some fire instead!
Using Python, I wrote a quick script to generate a 2d array of one of three values – red, yellow, or black – one row at a time, with each row after the first (all red) seeding a random integer between 1 and 3. If the number equals 1, that column “decays”, or decreases in color (from red to yellow, or from yellow to black). When ran through an infinite loop and throttled by a sleep function, I got a nice little animation in the terminal window that looked like this:
That looks neat, but it also doesn’t look like fire. I added some code to make it take into account the array used in the previous loop (instead of completely random each frame) and also counted the elements to each side in the calculation, rather than just the one below. The result looks like so:
Poor gif quality aside, I am happy with the result 🙂 especially for only an hour of my life wasted on it. If anyone is interested in seeing the code, I uploaded it to github.
Thanks for reading!