Hacker News new | past | comments | ask | show | jobs | submit login
Simulating worlds on the GPU: Four billion years in four minutes (davidar.io)
383 points by xk3 on July 25, 2021 | hide | past | favorite | 60 comments



Neat. I’ve been looking for something like this for gamedev — being able to model pseudo-realistic simulation of planetary evolution (for my interest, just starting at plate tectonics and going up until wind patterns) to provide a “basis” for further simulation.

It’s surprisingly hard to google though; almost all content is simple perlin noise generation that looks kind of correct but ultimately produces total nonsense (so any further derived rules have to also be total nonsense) — generally constrained with further nonsense rules to produce higher level concepts like “animals” and “biomes” that can’t be touched meaningfully.

Other material I can find is far too involved, and far too slow — targeting actual simulation of the earth. The few that do it with the goal of “just realistic enough” still end up being 10+ minutes generation time for small worlds. Modeling erosion processes being the main culprit, afaict.

Definitely stealing this one, for all my nefarious deeds.


Author here. This was definitely something I struggled with when creating this simulation. Reasonably fast simulations of tectonics and erosion have already been done before: some parts were tricky to translate to the constraints of a shader, but the parallelism pays off in being able to run the simulation at interactive speeds. The difficult part was the global climate model. I spent a while researching existing methods, but as you say, many of these are computationally expensive scientific simulations.

In the end I just downloaded some data for the Earth and went about seeing how well I could replicate climate maps with some simple curve fitting in a Jupyter notebook. After some trial and error, I was surprised to find that you could actually approximate things quite well with sine curves and some blurring, as described in the article.

Overall I learnt a lot about Earth systems from this project, it was a fun hobby for a few months. I have some ideas for taking it further, but haven't gotten around to it yet. Feel free to reach out to me if you have any questions, or want to discuss any ideas you have about it.


A question if you don't mind: Did you feel like a god when you wrote all this?


Heh, I'm not sure how to answer that question. As much of a god as in a god game, I suppose, SimEarth was a big source of inspiration for me. I occasionally get a vague urge to create new life and worlds, which led to this project at a time when that urge was particularly strong. I have a lot of respect for people who are able to do worldbuilding with just their minds, I tend to require a computer to do it for me.


Had to disable IPFS companion for the site because /ipns/davidar.io doesn't resolve (anymore?). It's nice the initial integration was there, though!


Why did you decide to have the life/electricfication spread so slowly relatively to the geological time scale? Was it just to better visualize the changes?


Yeah, I took a bit of artistic license with the timescales, in reality the systems evolve at such different rates that's it difficult to visualise them all simultaneously. Towards the end of the video some of the geological simulations switch off to signal a change in timescale as human populations spread, but it's still not entirely physically accurate.


You also missed the bit where the planets billionaires create giant penis rockets


A great job! One of most complex shader that I've found. I like GPU synthetic life projects and building one of them. Can you help me?


Thanks. Perhaps, feel free to send me some more details about it


based on what?


Some very detailed algorithms here [1]

1) https://github.com/DokimiCU/mg_tectonic


There's a risk to this sort of thing though: you tend to discover how hard it is to generate a life-bearing planet, depending on your pre-conditions. One of the devs on Star Control 2 put in a bunch of work to automatically generate the map and star systems in it, and during dev ran into the wall that while he could generate too hot or too cold or too dense or too light planets easily, getting interesting and potentially habitable planets out was exceptionally hard - the goldilocks criteria were in full effect and didn't happen too often when randomizing.


That’s part of why I’m only interested in starting at plate tectonics — solving the Goldilocks problem is not that interesting to me, and would require serious effort.

But given the right base parameters, I don’t think post-tectonics have the same problem — it’s harder to generate an invalid earth, where earth’s placement in the solar system/universe is hard coded.


Dwarf Fortress was the first thing I thought of when I saw this. It does do a geology sim for map setup.


If you have seen the glacier sims with Elmer, maybe start there and walk back until the simulation is fast.


I would like to see more work being done to simulate abiogenesis. Essentially, it's a search problem -- take some elements and probabilistically form increasingly complex molecular machines to the point where they become self-replicating and exhibit the basic properties of life. Once this bootstrapping has begun, it's a matter of subjecting the proto-lifeforms to evolutionary pressures, and over time, they will "evolve" to become increasingly complex organisms.


Great work. Interesting that he didn't simulate the impact that formed the moon, though. I'm interested in how that impacted (ha) plate tectonics. I'm not aware of a scientific theory that posits a causality between the impact and plate tectonics, but we are the only rocky planet that has both plate tectonics and a natural satellite created by impact, so I have to wonder if they're related.


Not an expert at all but from skimming Wikipedia

“The appearance of plate tectonics on terrestrial planets is related to planetary mass, with more massive planets than Earth expected to exhibit plate tectonics. Earth may be a borderline case, owing its tectonic activity to abundant water”

https://en.m.wikipedia.org/wiki/Plate_tectonics

It is just that there no objects in the solar system big enough to have plate tectonics. And we currently have no way of detecting them on exoplanets.


> we are the only rocky planet that has both plate tectonics and a natural satellite

We have the oceans to thank for plate tectonics.

https://www.researchgate.net/publication/253303432_Are_Ocean...


I’m under the impression that there were no “plate tectonics” at the time of impact (surface was still nearly molten), and if there were (surface had actually crustified), plates were quickly melted by massive amounts of energy from the collision.


Shameless plug: I've been working on a Simulation along similar lines. Runs entirely on GPU and allows you to view it all in real time: https://store.steampowered.com/app/1482770/Terra_Firma/

Some really cool details in this blog post- I hadn't done anything complicated related to weather.


That's really cool. There's something magical about such a complicated simulation running at 60fps.


I see stuff like this and then ponder whether I'm living in someone's weekend project... it'd be pretty interesting to discover the universe is a simulation, but it'd also kinda suck.


Even if the universe /is/ simulated, it wouldn't have an affect on anything mundane. We all still need to eat. Suffering is as real as anything else, and the alleviation of pain is still a good thing.

It also means that there is the potential to exploit the simulation, and take advantages of the corner cases - which may also get us shut down, but we would likely never know it happened, so it's almost without penalty.


I sometimes wonder if humanity thought of the world as if it is a simulation (visualize it as a video game), perhaps we could better realize that we have the ability to change how the future unfolds, and that the actions we take will only be successful if they are in accordance with the actual behavior of the simulation (how it actually is versus how we think it is).


It would actually have consequences, for instance we would likely not be able to do interstellar travel. Ok, not really mundane, but still. See https://osf.io/ca8se (disclaimer, I'm the author).


Well, we're not likely to be able to do interstellar travel in our lifetimes, so for today it doesn't have much consequence :)


Sure, let's see how throwing some NaNs into the mix works out!


Re: living in simulations: The Thirteenth Floor[0][1] and eXistenz[2][3]

Great movies, but may be seem somewhat dated if you're new to them as they're late 90's fare. I still love both of them.

[0]: https://en.wikipedia.org/wiki/The_Thirteenth_Floor

[1]: https://www.rottentomatoes.com/m/1089671-13th_floor

[2]: https://en.wikipedia.org/wiki/Existenz

[3]: https://www.rottentomatoes.com/m/existenz


I think therefore I am. Being in a simulation doesn't make my experience any less real.


Cogito, ergo sim?


Brilliant comment. I'm playing the sims while reading this too and one can't help but wonder the extent of their sentience


What about the opposite? Maybe there are animals that have the same level of sentience as sims.


What's a definition of "simulation"?

Bostrom's original paper (which proposed the "simulation hypothesis") doesn't define it properly that I can see.

It's a very late C20 / early C21 computer technology phrase - because we make models and simulations, and nest things in our computers, we think it is a meaningful concept about our universe.

How would we know our reality is a simulation, vs. e.g. an "alternate dimension"? Or something much subtler that we have no understanding of?

It won't be a "computer" simulation, and I doubt it'll be running on top of a turing machine. There'll be something more interesting and complex going on - perhaps metaphorically analogous to a simulation, but a richer, more alien thing than that.


Any complex computational machine is still equivalent to a laptop machine in terms of what it can compute, so it can always reproduced as a regular physics simulation. Something different could be a machine able to do hypercomputation.


Technically, due to the manner in which the mind renders reality based on crude sensory input, reality as we perceive it is a simulation, of sorts - it just doesn't seem like it because it's kind of our only frame of reference.


             All the world's a simulation, 
  and all the men and women merely objects.
  They have destructors and constructors;
  And each one in its run morphs poly times


Our observable universe is just a zany snowglobe knick-knack picked up as a last minute gift for a spoiled little shit in a universe of higher order than ours that's simply imperceivable to us. All of what we know as mass in our universe was suspended in a tiny bowl centered in the globe, the kid gave it one shake, ala the big bang, then sat it on a shelf forever to collect dust as we near unmeasurably slowly eject towards the edges of the globe. Maybe one day he'll pick us back up...


That doesn't accord with what we observe in the universe - not expansion outward from a central point, but expansion everywhere as everything moves away from everything else.


Implies that the theoretical ability to simulate a universe (or even just a planet) exists somewhere, which absolutely might not be the case


No Mans Sky does it pretty well. Who knows? Maybe when we get up to PlayStation 10 or 20 it'll actually be simulating the cognitive/sentient elements of the universe too.


Doing something "pretty well" compared to the task and doing something complete, is not really the same, when we are talking about a possible infinite universe to simulate. Because in this case, even just correctly simulating the leave of an tree, would take infinite comouters.


You could simply alter the consciousness of simulated beings to believe that the tree is complex and exists fully. This sort of dynamic pruning/altering of conscious reality would dramatically cut down on what needs to be simulated.

We could all be staring at placeholders (if even that) while believing we are interacting with a complex, fully defined world - in the meantime, the simulation modifies our consciousness(es) to smooth over any gaps in what could actually be a crudely defined generative world.


> You could simply alter the consciousness of simulated beings to believe that the tree is complex and exists fully. This sort of dynamic pruning/altering of conscious reality would dramatically cut down on what needs to be simulated.

You mean a text adventure?


I don't know why everyone insists on No Mans Sky. Having a space engineers MMO with thousands of players would be way more interesting. If every player builds 5 autonomous vehicles then the game would have simulate 5000 vehicles 24/7.


Sometimes when I play No Man’s Sky, I hope I’ll come across a single planet that has culture/cities. A quirk in the simulation that gave rise to it. Much like our lonely little blue planet. Or maybe I just smoke too much.


That may be true but it doesn't change that we are trapped in bodies that evolved to survive in the universe created by that kid.


I don't get why this comment has been downvoted. Isn't pessimist poetry allowed on HN?


You might enjoy the Magic 2.0 book series. A bunch of programmers independently discover that the world is a simulation so they give them selves magic powers and time travel to medieval England to be wizards.


I love the series! I hope there'll be more!


Define the duration of a weekend, in the simulation controller's dimension.


Very cool simulation! Also love the John Murphy soundtrack.


Sunshine had this single redeeming quality.


People give it too hard of a time.. for those who haven’t watched it they should.. soundtrack is great for sure..


Aha - for my Masters Thesis, some 15 years ago, I did something very similar also using (strictly) GLSL shaders to simulate the Universe from Big Bang to present day.

"GPGPU N-Body Particle-Particle Cosmological Simulations".

[Abstract: https://bit.ly/3rzDNLy]

[Results and poster: https://bit.ly/3BE2cEp]

Well done - very nice presentation!

PS: Do you have plots of your simulation results and Earth's natural mass density power spectrum along (simulation) time?


The author's github is a cornucopia of delights too: https://github.com/davidar?tab=repositories


Not sure how this was made. But this looked very impressive to me: https://www.youtube.com/watch?v=uD4izuDMUQA


It's mostly cut from various disaster movies (a lot from 2012) as far as I can tell.


Of course, CAGW has to destroy life at the end.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: