[HN Gopher] Show HN: Life Simulation Written in Rust
___________________________________________________________________
Show HN: Life Simulation Written in Rust
Author : joelthelion
Score : 124 points
Date : 2021-11-28 15:57 UTC (7 hours ago)
(HTM) web link (joelthelion.github.io)
(TXT) w3m dump (joelthelion.github.io)
| worldmerge wrote:
| That looks really cool! What graphics library did you use or did
| you make your own?
|
| Also how did you compile rust code for the web? And were there
| any challenges with it like weird browser issues?
| joelthelion wrote:
| I made this simple 2D simulation of life using Rust. I find it
| fascinating to see how complex patterns can emerge from simple
| rules, and how well natural selection works!
|
| The code is not extremely pretty, but I'm happy with the results.
| I'm quite amazed that I was able to port the whole thing to the
| web with very little effort!
| jacobmischka wrote:
| Macroquad is great, it does make that virtually effortless.
| Nice work!
| SkyMarshal wrote:
| Question - it seems you explained what all the colors do, but
| what do the different shapes mean (squares and circles)?
| alexeldeib wrote:
| Square indicates intelligence, which allows them to move non
| randomly towards the nearest edible biot (it's on the page
| right after the bullet points).
| artursapek wrote:
| This is awesome, thanks for sharing. I may tinker with it
| syspec wrote:
| Because it is written in Rust, this is the most secure life
| simulation to exist.
| joelthelion2 wrote:
| Believe it or not, there is an annoying bug in the R* tree
| crate I use that causes it to occasionally panic. I added a
| very ugly workaround that seems to work quite well though :)
| [deleted]
| cosmodisk wrote:
| This is super nice: I sat for nearly 10 min observing how the
| numbers go up and dow and how they consume each other.
| la_fayette wrote:
| Is this a specific algorithm, defined like conways game of life?
| I have never read any Rust source code, so I would like to
| unterstand it generally...
| joelthelion wrote:
| This is closer to real life than Conway's algorithm. Biots are
| able to move freely, have a very simple genome that gives them
| unique characteristics, and natural selection does the rest.
| There is a succinct description of the rules at the bottom of
| the demo page.
| woodruffw wrote:
| This is extremely cool! I wonder how much work it would be to
| bundle it up into an XScreenSaver-compatible binary.
|
| Edit: It looks like running it locally on X11 is trivial, so this
| should be easy to do. I'm trying to hack it together now :-)
| joelthelion2 wrote:
| That would be awesome :)
| woodruffw wrote:
| Looks like it won't work out of the box, unfortunately, since
| {macro,mini}quad doesn't support a custom X11 parent window
| :-(
|
| But I've opened an issue upstream to track functionality in
| the renderer that would allow this[1].
|
| [1]: https://github.com/not-fl3/miniquad/issues/250
| Datagenerator wrote:
| That would be great. Another awesome screensaver is called
| substrate and included in the set 1) by Jamie Zawinski ( among
| the founders of Netscape and Mozilla ).
|
| 1) https://www.jwz.org/xscreensaver/
| phyalow wrote:
| Anyone else getting an edgy anti ddos message?
| woodruffw wrote:
| You can avoid that by not sending a Referer header with
| your request.
|
| jwz's default redirect for HN is well known[1] (and, IMO,
| apt).
|
| [1]: https://news.ycombinator.com/item?id=25801699
| [deleted]
| krisrm wrote:
| This is neat! The simulation didn't remain "stable" for me for
| very long though; biot count pushed over 3000 and I dropped to
| just a few fps. I'm on a phone and I'm also a bit color blind so
| I'm probably not the ideal use case.
| joelthelion wrote:
| If you wait for a few more minutes, it's highly likely that a
| predator will emerge. Maybe you were just unlucky though.
| Ardon wrote:
| I made it to 8500 before an effective predator evolved. Glad
| I waited, it was neat.
| lloydatkinson wrote:
| Could you add some keyboard shortcuts to make it skip a few dozen
| generations?
| nynx wrote:
| Awesome! Now you gotta port it to wgpu and run the simulation on
| the GPU!
| joelthelion2 wrote:
| I would love to learn how to do that!
|
| I'm not certain it would improve things, though, as the most
| time-consuming step is computing interactions between biots.
| nynx wrote:
| Yeah, by computing on the gpu (or by using a spatial
| partitioning system like a quad-tree), you could probably
| speed that up massively.
| nynx wrote:
| Oops, you're already using a R* tree!
| joelthelion wrote:
| :-)
___________________________________________________________________
(page generated 2021-11-28 23:01 UTC)