ALiEn – a GPU-accelerated artificial life simulation program
alien-project.org
alien-project.org
As I was developing this, I hadn't figured out how I wanted to do food yet, so as an easy first step, I just had a constant amount of energy that was split amongst all organisms on the screen. Lots of little dots buzzing around, was kind of neat but nothing too special. I left it to run overnight.
When I came back I was very surprised: previously i was running at about 30FPS - now it was running at about 4 seconds per frame. The screen was filled with dense expanding circles of tiny slow organisms emanating from where organisms had mated and nothing else.
My simulation evolved to outsmart my simple food algorithm: when food is divided equally among all organisms, the best strategy is to use minimal energy and maximize offspring count. I had populated the world with a default offspring count of ~5 and they had evolved to the tens of thousands. The more offspring an organism had, the greater the amount of the energy pool would go to their offspring.
It was a very cool "Life, uh, finds a way" moment - that such a simple toy simulation of evolution was able to find an unanticipated optimal solution to the environment I created overnight was very humbling and gave me a lot of respect for the power of evolution.
I had a lot of different graphs to show me stats as the simulation continued. One thing I noticed was that after a while of this simulation "average age" started to go way up.
At first, I was proud. I thought I had evolved creatures that could live indefinitely in my simulated environment. I kind of had - but it didn't work like I thought. At some point the creatures seemed to become immortal and all new creatures died off. I was monitoring "average age at death" which confirmed all the dying creatures were very young and "average generation count" which showed it stabilized midway through the simulation and then locked in place. They got to a place where new organisms died off and there were a bunch of immortal organisms running around.
I finally figured out what had gone wrong. The stats, including caretaker energy, could be randomly modified by a small random value up or down whenever a child was produced. Nothing prevented caretaker energy from going negative, and indeed, that's what would happen. The simulation would work for a while while only a small number of organisms had negative caretaker energy, but eventually these guys would take over and become the whole population. They could indefinitely sustain themselves by having children, but their children (spawned by two parents who passed on negative energy) would instantly die.
I eventually localized food sources and added a bunch of additional rules, but was never able to realize this goal. I think for predator-prey relationships to evolve in my system it would have required sensory organs and methods to react to local environment.
Seems like ALiEn is able to simulate food chains with distinct species - and alas I don't have a CUDA GPU - but curious if they've been able to create an ecosystem where predators and prey can coexist in a balanced stable ecosystem. (In my experiments, it was very easy to get predator population explosion, all of the prey gets eaten, and then all of the predators die)
Cicadas could be another example of a strategy to deal with prey-decimation - by only emerging every N years, food sources have time time to regenerate between cycles. Similarly, many large predators are nomadic - so as they reduce prey availability in one area, they choose to look elsewhere, giving the prey in that area time to recover.
I think geography and terrain also helps a lot in the real world: prey is usually smaller than predators and thus has more hiding spots. Maybe I should have implemented a 'turtling' mode, where organisms could spend part of their time immobile and invulnerable, but also not gaining energy, as a way to prevent predation. I think sensory organs would still probably be necessary to make that strategy work.
I too implemented GOL at some point (when I had a look at SDL) and for fun changed the (boolean) game field to integers that I mapped to grayscale (and later RGB). So instead of killing/giving birth to cells you just decrease/increase their integer value. The result looks like a spreading fungus (with the classic horizontal/vertical/diagonal patterns) which can be very chaotic when numbers start to overflow and underflow.
It's a really fun and engaging way to play with 2d graphics and simulation.
There are a few videos (not just this one) where I tweaked the rules arbitrarily but got realty interesting behavior!
They let it run for a while and came back to find all the creatures had evolved into extremely tall, thin stalks that would tip over and never move again. The top would be moving very fast before it hit the ground.
Try to simulate something that you're interested in! Everyone has their own interests, but I find these kinds of problems a lot of fun to work on.
When you're learning, it forces you to make reductive approximations and simplifications - you just can't do it the "right" way, so try to find a way to get something similar with something close to it. Trying to model a bunch of simplistic rules that replicate a phenomenon. Flocking/crowd/traffic behavior, spread of memes or viruses, growing plants, etc. - the sorts of problems were you have a bunch of tiny particle/cells that each have simple behavior but they can interact with each other are very rewarding to get working because simple rules can produce complex system behavior.
I wonder if there is an efficient cellular automata that vaguely approximates the behavior of real chemistry, just like the autoverse.
It's a shame the garden eden configuration plot point is kind of bunk.
i still use an RTX3080 though, thankfully got one before the current craze started
Just as a random anecdote, I grabbed an AMD 5700xt around when those came out (for gaming). Since I had it sitting around between gaming sessions, I figured I'd try to use it for some compute, for Go AI training. For _1.5 years_ there existed a showstopping bug with this, it just could not function for all of that time. They _still_ do not support this card in their ROCm library platform last I checked. The focus and support from AMD is just not there.
Also Hollywood is a city and most computer animation is not done there. The big movie studios aren't even in Hollywood except for paramount.
https://home.otoy.com/render/octane-render/
As for the rest of the comment, usual Nvidia hate.
I don't know where you are getting "nvidia hate", studios that use linux usually use nvidia, mostly because of the drivers.
None of this changes that optix is not a renderer.
WGPU is more portable, since it can use not only Vulkan but also other APIs like OpenGL and Direct3D 11, but Vulkan is already very highly portable for almost everyone with a computer modern enough to run anything related to GPU compute.
Why don't you complain about Apple not supporting Vulkan instead?
Getting CUDA to work well is hard. Not hard on your laptop, not hard on a particular machine but hard to work everywhere when you dont know the target environment beforehand -- there are different OSs, different OS versions, different versions of CUDA, different cards with different capabilities. But we did get it to work fairly widely across client machines.
The same effort needs to be put into getting things to work for other manufacturers, except a layer deeper since now you're not even standardized on CUDA. Many companies just dont make the investment. Our startup didn't, because we wouldn't find people who could make it work cost effectively.
What I really wish is that the other manufacturers would themselves test popular frameworks against a matrix of cards under different operating systems and versions. We see some of that, for example, with the effort of getting TensorFlow to run on Apple's m1 and metal. I just dont see a random startup (e.g., mine w/ 12 employees) being able to achieve this.
For example, if I know from the manufacturer that I could get TensorFlow X to work on GPU Y on {Centos N, Ubuntu 18/20}, I would gladly expand support to those GPUs. But sometimes you dont know if it is even possible and you spin your wheels for days or weeks -- and if the marketshare for the card is limited, the business justification for the effort is hard to make. The manufacturers can address this issue.
That said, NVIDIA Docker Runtime is awesome now -- however, all this underscores further how much further behind the non-NVIDIA stack is!
This despite v3.0 being released just last year... And completely breaking the API.
For proprietary implementations, Intel appears to have the broadest and most consistent support. Nvidia skipped OpenCL 2.x for some technical reason (IIUC). AMD is a complete mess, for some reason not bothering (!!!) to roll out ROCm support for their two most recent generations of consumer GPUs.
In open source "Linux only" land, Mesa mostly supports OpenCL 1.2 (https://mesamatrix.net/#OpenCL) at this point. So if you're targeting Linux specifically then that's something at least.
Good luck shipping an actual product using OpenCL that will "just work" across a wide variety of hardware and driver versions. POCL and CLVK are both experimental but might manage this "some day". In the mean time, resign yourself to writing Vulkan compute shaders. (Then realize that even those will only run on Apple devices via MoltenVK, and despair at the state of GPGPU standardization efforts.)
Other orgs are using something written in another language that compiles into CUDA.
Either way, to replace CUDA, that middle component needs to be replaced by someone and ideally it should be the card manufacturers themselves (IMHO.) I cant imagine any small/medium organization having sufficient engineering time to write the middle component and keep them up to date with the slew of new GPUs, OS updates, or new GPU features -- unless it is their core business.
[8] https://github.com/googlefonts/compute-shader-101/pull/8
He was a professor of mine in grad school, he also did visual effects for The Last Starfighter, and the early work on character recognition in the Apple Newton. Cool dude.
https://www.youtube.com/watch?v=JBgG_VSP7f8
Not sure how they're connected, but I remember being obsessed with that paper and actually recreating it in 2D as a grad project.
His fractal art is quite compelling as well: http://www.ventrella.com/
Others look evolved inside the sandbox. (see doc here: https://alien-project.org/documentation/Evolutionexperiments...)
It was ported here https://rednuht.org/genetic_cars_2/ but it's not quite the same thing.
If you leave the program running long enough, they do actually evolve different behavior. Specifically, they will learn to recognize that there are other lifeforms in a direction and then move the opposite direction, reducing competition over the fixed amount of energy in a cell. You can actually see the population density rise when this happens. Since the grid wraps, you will generally get them "flowing" in one direction, cooperatively.
The world is simple and boring and it doesn't have graphics. Also, since the naive "Dna"/opcodes I chose use branching and random number generation, it's very slow and can't be simulated on a GPU.
Fun project nevertheless. The last few months, I've been slowly rewriting it in Rust and adding more stuff like terrain height. Haven't published the Rust version yet as it's incomplete—got hung up on the poor state of its terminal libraries.
This reminds me of what IMHO is best use of artificial life in a game, Unnatural Selection. In the game you had to select and breed creatures to go against other enemy creatures. [3][4]
[1] https://en.wikipedia.org/wiki/Artificial_life
[2] https://www.amazon.com/Artificial-INSTITUTE-SCIENCES-COMPLEX...
(Old video of grobots in action at https://youtu.be/BLXKedZHls4?t=801)
Alien looks awesome!
I've been trying to produce a web version of it. This is where I got so far (before more or less desisting):
It's more simple, and more about physics than biology, but the emergent phenomena are pretty interesting nevertheless. This universe comes the closest to a life simulation: https://exophysics.net/exhibit/mordial.html [based on the Primordial Particle System, https://www.youtube.com/watch?v=makaJpLvbow]
Pretty cool! I see some rare behaviors like maybe there is a weak magnetic property and certain combinations of particles are more prone to it than others? Trying to rationalize this behavior I see after about a minute where some "molecules" seem to start trailing others.
On the other hand, there are a lot of things that make physics tractable to compute, such as the +++- metric tensor and other factors forbidding causality violations. A universe with closed timelike curves becomes very expensive to compute because you usually have to use implicit solvers that are slow and might not even converge, corresponding to various time travel paradoxes.
Couldn't the universe where the simulation runs be so entirely different to ours that computing all that stuff is just easy.
Granted, this scenario doesn't provide us with anything we can take action on, but the idea that we're in a simulation at all doesn't, either.
You don't have to assume anything is true if you don't want to, but if you want to consider whether we're living in a simulation, it's probably worth considering.
>And what would be the point of this simulation that has been running for billions of years?
First, it's billions of years in our time. Second, what's the point of Conway's Game of Life?
Which, for me, is a dead end. It's the same as assuming there's a God, except the moral implications are worse.
> First, it's billions of years in our time.
So, if billions of years of our time fly by like your average simulation run in "their" universe, the simulation can't be very meaningful to them. And it makes the distance between our and "their" physics even larger.
> what's the point of Conway's Game of Life?
None, and that's why nobody runs one with 10^120 cells for billions of years. And if somebody did, the result would be incomprehensible. The gap between us and our creators must then be incomprehensible for us. All this is so outlandish, that the word "likely" shouldn't be anywhere near this discussion.
There is zero evidence for or against the simulation hypothesis, so why would some random person on HN be able to have the answer to this question even if we are in a simulation or even if we simply assume that we are?
The odds of all that happening without it being prevented are all but zero.
We have a better chance that one of the simulators grows attached and—against protocol—decides to uplift us from the simulation into a form where we can directly communicate with them.
Sure, but look at the state of frontend web development :)
When you make a simple simulation of rigid bodies with classical physics you often get numerically unstable results - bodies jerking against each other, slowly passing through, etc. One common way to solve this is to introduce a "frozen" state. When objects are close enough to be at rest with balanced forces - you mark them as frozen and don't compute them every frame to save computing power. You only unfreeze them when some other unfrozen object interacts with them.
Additionally hierarchical space indexing algorithms are often used to avoid n^2 comparisons calculating what interacts and what doesn't. And these algorithms often use heuristics and hashing functions with collisions to subdivide the problem, which might result in objects becoming unfrozen without actually touching each other.
The result from inside this simulation would be weird, nonlinear, nonlocal and look a little like wave function collapse (if particle A whose coordinates hashed through this weird function are the same as those of particle B happens to unfreeze - the particle B unfreezes as well despite not interacting in any way). And this would be probably considered "hard to compute" compared to the simple equations the system developer wanted to simulate.
Example that might be more relatable for scientists - it's much easier and cheaper computationally to make a numerical simulation for 3-body problem than to make an analytic simulation of it. But describing this numerical simulation behavior in terms of physical equations requires much more complex model than the equations that you wanted to compute in the first place. You have to include implementation details like floating point accuracy, overflows, etc. And if you go far enough you have to add the possibility of space ray hitting a memory cell in the computer that runs your simulation.
I'm not saying this is the reason QM is weird - I don't understand QM well enough to form valid hypotheses ;), but I'm saying we might be mistaking the intention of The Developer with the compromises (s)he made to get there. If you take any imperfect implementation of a simple model and treat it as perfect - the model becomes much more complex.
How do you know it's all computed? To make a convincing simulation, you just need to simulate in detail the bits that are actually being observed.
Everything else that happens could just be approximated at larger and larger granularity the further it is away from an observer.
There isn’t actually an observed/unobserved distinction in physics. Unless you mean the simulation is specifically targeting humans, which is a vastly more complicated proposal.
It's also the most likely proposal (with current understanding of universe).
Axis of Evil (Cosmology) calls into question the Copernicus views of the universe. Essentially saying our solar system is somehow back at the center of the universe.
https://www.youtube.com/watch?v=hjVCjdX5XRw
If WE are the subject of the simulation, it's likely everything our instruments observe are like the sky on the Truman show - not there, just phantoms of what we would expect to be there with what the simulation wants us to know about physics.
There's a max speed the speed of light, what if this is the max processing ability of the computer we're running on. What if we're not on a computer at all but some sort of wetware computer system that grows as it needs to, and never runs out of resources?
What if the speed of light in the parent sim is 500x bigger for them, or ours is like a centimeter in comparison.
A dream is a simulation, we could all be dream creatures to some huge extra-dimensional being. Not everything pre-supposes human technology.
I've seen literal "glitches" in reality, so it's pretty easy for me to believe that reality isn't something completely set in stone. For others it challenges everything they believe in, for that I say open your mind.
Donald Hoffman believes that what we see is like what someone in a VR headset sees, outside the VR headset who knows what that world is like, but in this one -- everything except math (which he believes is universal and extra-universal), is made to fit this universe. Physics, science, all of it is unique only inside the headset. There could be many headsets with different settings running parallel (parallel worlds/universes), maybe the speed of light is faster in one than the other, maybe gravity works different, etc... So many things in our understanding are really like "settings" like size of a planck's constant, pie, speed of light, etc. Almost reads like a config file.
I mean if you buy into a "God" being, if computing is a thing which we have it so why wouldn't God? Wouldn't it even make more sense for him to just code up a simulation? I mean it's gotta be a lot less demanding than building a whole universe from nothing.
2. That the same arguments also apply to our simulator operators. They also inhabit a simulated universe. And so on. Where does it stop, and why?
In a universe where time itself could be fluid, where it could be easy to reverse events, rewrite events, etc - making quantum computers work even way better than we ever could because we're limited by causality.
I mean the people beyond this universe could have 50 senses, like a sense of how far up or down they are, or how much water they can breathe in before they need oxygen if o2 is even a thing, or a sense of time so they can go back/forward through time. If they have 50 senses, our 5 sounds like "nothing" to simulate.
It's all a matter of perspective, I'm sure an ant feels like they keep pretty busy and nothing could possibly simulate their colonies, but I'm sure that would be pretty easy.
Just as a thought experiment, I'd propose that our universe and the human experience is incredibly simple. Humans were only given a limited number of senses so that the simulation can be run in this "low fidelity". Compared to the thousands of senses a level or two up. We also are simulated in a simple linear time model, only able to experience a single time at once, greatly reducing the complexity and fidelity needed. Same for the number of dimensions we are able to sense.
This may not literally be a simulation, but it seems to behave like one in many ways.
The mathematical universe sidesteps this problem. If there is a concise and complete model of the universe, that is sufficient for it to exist. A simulation might also be considered a mathematical model, and it would exist in the same way even if nothing ever runs the simulation. So I guess maybe it could be a simulation, but we mustn't ask what it runs on, but what is the program?
The universe does not owe you visibility into its origins, the lack of it does not make the hypothesis any less likely.
> If there is a concise and complete model of the universe, that is sufficient for it to exist.
Sounds like the ontological argument [1], one of the worst contortions of apologia ever imagined.
This then leads to how does math exist instead of nothing? Math is a concept, and if concepts exist then that is not "nothing".
Many people confuse "nothing" with the vacuum of space and particles appearing out of nowhere. In this case, we have something (space, vacuums, and particles), not nothing.
A similar conception I've heard is that its like something and nothing, at the beginning of time, made a bet whether there'd be something or nothing, but the act of making the bet was already something, rigging it in something's favor. Nothing thought that was bullshit and tried to call it so, and they've been battling it out ever since.
Put another way, nothing has absolutely no properties - including the property of being nothing, or empty. If an empty nothing lacks the property of being empty, or nothing, then something must arise.
The problem is that nothing can't make bets.
(https://osf.io/ca8se, I'm the author)
Here is the link: https://archive.org/details/4.Macintyre/page/n17/mode/2up
This is a sort of test playground for marketing, brands, and so on since the programs occupy a no man's land between games, academic research, toys, entertainment, and programming.
It also satisfies the self-feeding dogfood condition: similar to games such as RoboWar, it is difficult to resist the temptation to experiment at the simulation level, a phenomenon that could be described as the MFTL effect.
I used this as inpiration and to learn about Unity ECS and made a 3D version with WebGL support [2]; native builds obviously have much better performance. But it is all CPU-only. Anyway. What I found very interesting is dynamically switching between 2d and 3d. Most organisms survive the dimensional increase or reduction and just reconfigure itself to a similar structure.
[1] https://fnky.github.io/particle-life/ [2] https://particlelife-3d-unity-ecs.github.io/
There are certainly a lot of other fascinating cellar automata though! Even within 2-state-2d-totalistic (the class GoL is from) there's loads to see and lots of surprises! Well worth exploring! (there's an app called 'golly' that's good for that, and it's cousin 'ready' does related (also 'raster') 'reaction-diffusion' simulations.)
My universe started as a uniform random distribution of small stationary objects, the only rules that existed were gravity (F=gm1m2/r^2) and inertia (F=ma).
Mass started clumping together, orbiting each other, eventually forming a relatively stable arrangement of what we recognize as stars orbited by planets orbited by moons.
With two simple rules to govern my universe, an emergent order had occurred that mirrored my reality.
Generalization of Conway's "Game of Life" to a continuous domain - SmoothLife (Stephan Rafler) http://arxiv.org/abs/1111.1567
Video of SmoothLifeL: https://www.youtube.com/watch?v=KJe9H6qS82I
The GPU compute ecosystem is truly in a very sorry state, and NVidia is very much to blame for this: in their quest to get a stranglehold on the market, they've reached a point where things don't even work reliably on their own products.
https://www.reddit.com/r/nosleep/comments/u7zc2/the_life_in_...
Later I'm going to test it on another computer with a RTX 2060 super, but slower CPU and slower interconnections (PCIe).
Thanks for the link too. :)
Since the i7 920 supports less instructions than the 3700x, it really is a specific problem with the GTX 1070 (8GB)
I've tried, the program runs but I cant step the simulation even once.
Have updated to current CUDA (11.3.1) and current NVidia driver (466.77) with no luck.
https://github.com/pavelliavonau/cmakeconverter
And also use Vcpkg for dependencies, but I guess there will be some mess with Nvidia SDKs so you'll have to hack around a bit.
And preferably an answer that goes beyond just saying that Von Neumann used Cellular Automata in his ALife research.
Also, if anyone knows of alternative methods to CA in studying the properties of life then I would also be interested in learning of these.
All in all, I find these procedurally generated art pieces to be rather underwhelming in any serious attempt or study of what artifical life is/can be.
> digital organisms and evolution
This is a claim without definition of what a non-biological organism even is. Could we just claim that any CA, any program is "living" while it is running?
I would love to see some formality before claims are made in this area.
EDIT: After watching the "Planet Gaia" video [0], I feel even more like the excitement about this is no different than the excitement for a video game and not for actual scientific progress. Cool code and cool visuals. Very little in the way of understanding life better.
Uh, it doesn't exist. Plenty of A-life research doesn't use cellular automata as a model.
> Also, if anyone knows of alternative methods to CA in studying the properties of life then I would also be interested in learning of these.
Thanks for the link!
> Plenty of A-life research doesn't use cellular automata as a model.
While I would like to believe you on that, one link does not seem sufficient to support the word "plenty" when the ratio of ALife projects built around CAs to not is extremely high.
What you see as a criticism of this line of research I think is actually its reason: Life is arguably the most interesting thing in the universe, and if we can create it digitally it will surprise us. Evolution yields insights and solutions that you cannot predict. If we can synthesize what the minimal set of key properties are necessary for artificial lifeforms to create interesting unexpected outcomes, it helps us clarify the definition of what a non-biological organism could be.
I'm personally fascinated by the idea of autonomous digital agents that exist and self replicate while trying to earn cryptocurrency, which is used to pay for the hosting costs of themselves and their progeny. I think we are about two decades away from this being realized, but in the future, software services could self assemble, replicate imperfectly and evolve to please humans without any humans writing additional code: we'd just have to code a profitable LUCA, create suitable 'nests' and pay the organisms that please us. "What is life" is debatable, but IMO this would be a valid digital lifeform.
But, this is a very unaddressed point. Why focus on "simulation" when mathematical formalisms & theories could be potentially even more useful? Especially when most "simulations" are running on some arbitrary set of hard-coded assumptions?
> What you see as a criticism of this line of research
To clarify, I was in no way criticizing ALife research. Quite the opposite. I am actually trying to help ensure it does not get stuck in a rut.
A mathematically formal approach does sound potentially more useful, but I'd have no idea how to approach that sort of problem. I speculate that the venn diagram of people who want to work on these types of problems and also have the depth of formal math understanding to actually achieve it is a small handful of people who have plenty of other interesting problems to work on.
Or maybe someone has done this work successfully, but the depth of knowledge required to understand it has prevented wider awareness?
"A cellular automaton consists of a regular grid of cells, each in one of a finite number of states, such as on and off "
From: https://en.wikipedia.org/wiki/Cellular_automaton?wprov=sfla1
I find it interesting that the project seems to have hard-coded emergence with the concept of "tokens".
So, I am much less intrigued by the simulation examples when most of what we are seeing is just a procedurally-generated video game with pre-defined game rules. Much of it is not truly emergent.
Again, it's a "oh, that's cool" kind of factor, but a far cry from contributing to anything in the way of "artificial life" research.
[0] https://alien-project.org/documentation/Basicnotion.html
no thanks.