TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

66 pointsby isaacsandersalmost 7 years ago

7 comments

wool_gatheralmost 7 years ago
&gt; I was bored and<p>Be proud of your experimentation! We&#x27;re all fellow geeks here. You don&#x27;t have to hedge like this with us about spending your time hacking. Thanks for sharing!
评论 #17846246 未加载
braythwaytalmost 7 years ago
I&#x27;m also one of umpteen developers who have played with writing a Conway&#x27;s Game of Life app. All the ones I&#x27;ve built have used the HashLife algorithm:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Hashlife" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Hashlife</a><p>Here&#x27;s one of my attempts, you can play with it in a browser. There&#x27;s infinite scrolling, and you can do ridiculous things like start up a glider gun and watch it run out to billions of generations.<p><a href="http:&#x2F;&#x2F;raganwald.com&#x2F;hashlife&#x2F;" rel="nofollow">http:&#x2F;&#x2F;raganwald.com&#x2F;hashlife&#x2F;</a><p>The source code is on Github:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;raganwald&#x2F;hashlife" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;raganwald&#x2F;hashlife</a>
babyalmost 7 years ago
Link to code for those of us on a phone?<p>Edit: found it <a href="https:&#x2F;&#x2F;github.com&#x2F;isaacsanders&#x2F;game_of_life-elixir" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;isaacsanders&#x2F;game_of_life-elixir</a>
markysoftalmost 7 years ago
I think every dev should have a go at Conway&#x27;s life, I made one a while ago too <a href="http:&#x2F;&#x2F;www.markysoft.com&#x2F;es6life&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.markysoft.com&#x2F;es6life&#x2F;</a>
评论 #17846360 未加载
DonHopkinsalmost 7 years ago
Great work! However, one pedantic comment: it doesn&#x27;t look like Life to me -- it looks like In-Place-Life-Without-Double-Buffering.<p>I can&#x27;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.<p>So if you don&#x27;t double buffer the cells, and execute the rule in-place instead (and presumably scan in row major left-&gt;right, top-&gt;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&#x27;t, and other weird asymmetrical behavior, instead of the gliders gliding the same in all directions like they&#x27;re supposed to.<p>The most obvious artifact is the stable symmetrical configuration in the upper left corner corner that flickers asymmetrically:<p><pre><code> 0110 0010 0110 1001 =&gt; 1001 =&gt; 1001 0110 0110 0110 </code></pre> <a href="https:&#x2F;&#x2F;www.fourmilab.ch&#x2F;cellab&#x2F;manual&#x2F;chap4.html" rel="nofollow">https:&#x2F;&#x2F;www.fourmilab.ch&#x2F;cellab&#x2F;manual&#x2F;chap4.html</a><p>&gt;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. [...]<p>&gt;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.<p>Life is a rotationally symmetrical counting rule (&quot;semitotalistic&quot;), so there are no special directions, unless the in-place scanning process is introducing asymmetrical &quot;temporal shearing&quot; 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.<p>You just need to use more temporal jewel matrix crystals (<i>ahem</i> I mean memory), to buffer the cells!<p><a href="https:&#x2F;&#x2F;www.whofic.com&#x2F;viewstory.php?sid=14049" rel="nofollow">https:&#x2F;&#x2F;www.whofic.com&#x2F;viewstory.php?sid=14049</a><p>&gt;“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…”<p>&gt;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… [...]<p>&gt;“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.” [...]<p>&gt;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…?”
评论 #17846320 未加载
DonaldFiskalmost 7 years ago
After ITS was resurrected and running Ken Harrenstien&#x27;s PDP-10 emulator, I wrote a version of Life in MIDAS for it: <a href="http:&#x2F;&#x2F;www.fmjlang.co.uk&#x2F;its&#x2F;life.txt" rel="nofollow">http:&#x2F;&#x2F;www.fmjlang.co.uk&#x2F;its&#x2F;life.txt</a>
no_gravityalmost 7 years ago
Some years ago, I was bored and made this javascript version:<p><a href="http:&#x2F;&#x2F;www.gibney.org&#x2F;conway_s_game_of_life" rel="nofollow">http:&#x2F;&#x2F;www.gibney.org&#x2F;conway_s_game_of_life</a><p>When you click &#x27;Start&#x27; and then &#x27;BigBang&#x27;, it will start from a single cell in the center. I find the resulting evolution pretty fascinating.
评论 #17846220 未加载
评论 #17846121 未加载