ForumArcade ► Game of Life in Crayon
A few months ago I wrote a Game of Life implementation using Crayon. You can see the source here and try it out in your browser here. (Click to toggle cells and press space to advance.)

It's an extremely naive implementation and I don't think Crayon is super efficient when running so many calculations so frequently so the performance is kind of bad. It was a great learning project though. Crayon's drawing tools are pretty slick and having matrices in the standard library is neat.
  
Cool!
  
Sweet, I love the game of life!

I think there must be a performance bug with the Matrix type because I tried switching the matrices out for lists of lists, and that makes it run pretty smoothly. I wouldn't have thought the getValue/setValue calls would cause that much overhead.

Also, if you decide to extend this later, the getNeighbors() function can just return the count directly, rather than returning a list of neighbors which you then have to filter and count. (Tried this first before getting rid of the matrices.) Every object instantiation or function call you can eliminate from the tight loop helps a lot, especially because Crayon doesn't do much inlining.

Hope you'll share more stuff! 😃
  
Thanks for the feedback! I was originally going to do just a 2D list but matrices looked like too much fun to pass up. They're probably overkill though since none of the arithmetic functions are being used, especially if they're hitting the performance that hard.

Stripping down getNeighbors() would definitely make sense. I don't remember why I bothered building a whole list instead of just counting inside the loop. I'll probably revisit this to clean it up a bit and add some features like automated playing/pausing and inserting prebuilt patterns.
  
Been really debating getting a SMCFP github account so I can contribute crayon stuff without doxxing myself....

Might fork this if I get more time.
  
Sorry for not having the compiler service running at this time and making you guys self-host these. I promise to get it back up at some point but it'll be after I finish the TwoCans app.
  
It's okay, I'm working on a Crayon-based Bitcoin miner so I can profit from the TwoCans traffic.
  
Blake said:
the TwoCans app.

*Spit take* Whaaaaaatttt?!

When did that get announced?!
  
He did say it's not finished yet
  
Forum > Arcade > Game of Life in Crayon