Settings

Theme

I was bored and made a Conway's Game of Life app in Elixir

game-of-life.isaacbfsanders.com

66 points by isaacsanders 8 years ago · 13 comments

Reader

wool_gather 8 years ago

> I was bored and

Be proud of your experimentation! We're all fellow geeks here. You don't have to hedge like this with us about spending your time hacking. Thanks for sharing!

  • venantius 8 years ago

    I don't think of this as a hedge; rather, it's saying "look what I was able to do in my spare time!"

    • isaacsandersOP 8 years ago

      Maybe half hedge and half humble-brag. I am having fun figuring out what I need to do to handle the server load. :D

braythwayt 8 years ago

I'm also one of umpteen developers who have played with writing a Conway's Game of Life app. All the ones I've built have used the HashLife algorithm:

https://en.wikipedia.org/wiki/Hashlife

Here's one of my attempts, you can play with it in a browser. There's infinite scrolling, and you can do ridiculous things like start up a glider gun and watch it run out to billions of generations.

http://raganwald.com/hashlife/

The source code is on Github:

https://github.com/raganwald/hashlife

baby 8 years ago

Link to code for those of us on a phone?

Edit: found it https://github.com/isaacsanders/game_of_life-elixir

markysoft 8 years ago

I think every dev should have a go at Conway's life, I made one a while ago too http://www.markysoft.com/es6life/

  • Insanity 8 years ago

    Seems to be something traditional. I made one over a decade ago to learn C# and many more for learning other languages since then.

    It's good fun to try it with different languages because the base problem is simple enough to learn how to solve it rather quickly.

DonHopkins 8 years ago

Great work! However, one pedantic comment: it doesn't look like Life to me -- it looks like In-Place-Life-Without-Double-Buffering.

I can't follow the code, but the NEXT state of a cell should depend strictly on the PREVIOUS state of the cell and its neighbors, not the NEXT state of any of the neighbors.

So if you don't double buffer the cells, and execute the rule in-place instead (and presumably scan in row major left->right, top->bottom order) by immediately storing the NEXT cell back in the PREVIOUS buffer instead of having a separate NEXT buffer, then the cells from the NORTHWEST, NORTH, NORTHEAST, and WEST are in the PREVIOUS instead of the NEXT state, resulting in the non-Life-like asymmetrical effect you seems to be getting there, with gliders going in different directions behaving differently, disintegrating when they shouldn't, and other weird asymmetrical behavior, instead of the gliders gliding the same in all directions like they're supposed to.

The most obvious artifact is the stable symmetrical configuration in the upper left corner corner that flickers asymmetrically:

    0110    0010    0110
    1001 => 1001 => 1001
    0110    0110    0110
https://www.fourmilab.ch/cellab/manual/chap4.html

>In a symmetric CA rule (and all semitotalistic rules are symmetric under flips and 90 degree rotations) a given CA pattern will have no reason to move in one direction rather than another unless the pattern itself is asymmetric. Setting one live cell next to another creates an asymmetry between north-south and east-west. The remaining symmetry is broken by gluing a pair of ghost cells to one side or the other of the live block. [...]

>There are of course many rules that stay alive in the trivial sense of turning the screen into what William Gosper calls “seething dog barf.” What makes Brain so remarkable is that it is drawn to a chaotic attractor that is a stochastically stable equilibrium between dead black and milky jitter.

Life is a rotationally symmetrical counting rule ("semitotalistic"), so there are no special directions, unless the in-place scanning process is introducing asymmetrical "temporal shearing" along the scanning directions, which causes bizarre mutations, like some hypothetical Doctor Who episode where you can see the future to your North and West, and the past to your South and East.

You just need to use more temporal jewel matrix crystals (ahem I mean memory), to buffer the cells!

https://www.whofic.com/viewstory.php?sid=14049

>“We seem to have hit a patch of temporal shearing. Dimensions are all mixed up…the TARDIS should protect us but…” his voice rose a full octave, “Rose? You’re not near anything, are you? You need to move to the middle of…”

>Rose watched as the book began to dissolve into purple smoke. Then the grass, the flowers, the sun…she felt the ground give beneath her feet. The walls twisted sickeningly, but there was no air to help her scream… [...]

>“Oh no no no you don’t, Miss Tyler.” He put a firm hand on her shoulders and shook his head. “You managed to step right into the middle of a shearing bubble. You should have listened to me! It’s scrambled all your electrical impulses — your heart, your brain — your whole nervous system.” [...]

>The Doctor swallowed and started to speak faster. “The time rotor got damaged from that shearing bubble. Not enough to ground us but we can only travel in space, not time.” He glanced at her out of the corner of his eye. “Lucky for us Tau Tauri Alpha isn’t far and it’s the best source of temporal jewel matrix crystals I know. That’ll repair the damage to the rotor. It’s interesting stuff; elementally identically to the matter in the shearing storm. Mining it isn’t a one-person job, though. So, if you’re feeling better when we arrive…?”

DonaldFisk 8 years ago

After ITS was resurrected and running Ken Harrenstien's PDP-10 emulator, I wrote a version of Life in MIDAS for it: http://www.fmjlang.co.uk/its/life.txt

no_gravity 8 years ago

Some years ago, I was bored and made this javascript version:

http://www.gibney.org/conway_s_game_of_life

When you click 'Start' and then 'BigBang', it will start from a single cell in the center. I find the resulting evolution pretty fascinating.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection