Amazing simulation! I think separating the world with some walls that have openings, to create speciation, could help reduce the amount of extinctions. I can imagine those waves which wipe out the majority of the prey (then consequently the predators) can be isolated to specific areas. Can't wait for part 4!
I think it's hard to balance because the plant growth is slower than the reproduction/maturation rate of the animals. IRL wild herbivores are part of the life cycle of many plants, getting eaten isn't bad, it fertilizes the soil and propagates seeds. Total loss of ground cover is not part of normal fluctuation in population levels, it's a natural disaster.
Growing on that, not all the energy can be transfered to the next level, meaning that a prey only uses a % of the energy of the consumed plant and predator gets only a % of the enrgy of eaten prey, this will reduce the growth of predators and prey, making prey food more abundant. Each level of plant life gives different energy inputs, meaning that prey might choose to e
yes but herbivores doesn't eat hole plant and they are free range in bigger plane. and same time carnivores have harder time to hunt not every hunt successful many of them if they are not cooperate while hunting lover then 25%
Very nice. I've dabbled in the subject a bit. This is what I'd do to avoid extinctions (best benefit/cost first): 1. Regional variation: This can be as simple as the left of the screen has high reserve loss and the right has less. Or maybe the energy cost per move speed formula is different on part of the map. Ideally there would be a sharp change between these regional properties. The change in each property should be a neuron input. The goal is to have specialist populations in the regions so that migrants from a different region will tend to be outcompeted. It's important because it means that a population collapse in one region is less likely to affect the others, and when that happens the remaining populations can spread to the dead zones. 2. Barriers: The most effective barrier is a large shape in the middle of the map but more complicated shapes can be better. The goal is to divide populations more, and make it harder for a new evolutionary advantage to propagate everywhere. Not the most effective tool, but an easy one. 3. Memory: This can be as simple as adding a neuron that appears both as an output and an input, the output from the last step becomes the input for the current step. A creature could add multiple of these with connections as they do in hidden layers. The goal is to let prey go into a more persistent run / emigration state when there are too many predators in a given area. 4. Reduce predator carrying capacity compared to prey: The easy way is to just reduce the food value of food from prey. The goal is to stop predators blanketing an area. Prey in emigration mode would ideally have a chance to run out of a risky area, but that's too difficult if the predator population is overwhelming. 5. Stratification: This is the most important one but also by far the hardest to do. Ideally there would be different plant types and physical properties for animals such that there are specialists for a lot of different things. In particular, it should be very difficult for a predator to be able to attack both large and small animals (too evasive, or too resistant). As with regional variation, the benefit is that even if one layer of the population collapses, creatures from another layer can adapt to make use of the new empty layer. 6. Simulation size: Bigger maps with bigger populations. The distance helps with the regional isolation aspect, and the larger populations help the statistics of small populations somewhere. It's often the most costly and least interesting improvement so it's last on my list.
Are you familiar with The Bibites? It checks a lot of these boxes. The dev isn't very active on YT or in the community, but it's free to download and play with.
I noticed the creatures have no way of knowing if they are being backstabbed or if their health is depleting. They have no short-term memory to allow them to notice their health is dropping and will only know that their health is currently high or low. You can probably create some more reactive AIs if you provide a way for them to have memory and/or extra information to state that they are in an exceptional situation (like isStarving or isBeingAttacked inputs). Adding something like a generic call output that others can hear as an input will also allow your AIs to communicate and evolve in interesting ways -- I venture to guess they can even mimic memory with a simple output/input like that.
honestly memory is the biggest thing. Like yeah, sound would help prey know when there was a predator near, and they are all doing the stupid spinning because they have no memory
The prey seem to stay where there's food and when it's gone, they still stay there... perhaps because it worked so great for them before and they continue past behavior. And then the predators come in and devastate the area. The predators are forced to move because the prey move. Maybe if the plants didn't all spawn together, but rather in small clusters. Or if the plants could die after a time and respawn a certain distance away. Something to force the prey to move to get food.
Proposal: make an elman network, BUT compute and update the hidden neurons one by one (so each node uses the new outputs of previous nodes in the same layer, and the old outputs of later nodes). This way, each node is its own layer, thus you get a very deep and wide net at the same time. The recurrent connections are also deeper than linear
A periodic forcing function might help stabilize your predator/prey relationship by allowing recovery of each. Something like plants grow best spring and summer thus prey grow best spring to fall and predators survive on fat in the fall/winter but prey burrows to hibernate and become the seeds of the next seasons population. It would take a lot of evolution to spontaneously generate that kind of complex behavior. Always enjoy your work, thank you for sharing.
Of all the possible improvements, I think you'd be best served by two things. 1. Plant resilience. The prey-plant interaction is quite basic. Plants don't normally get wiped out by grazers. They employ strategies like seed dispersal through feces, roots that regrow annually, and defenses like thorns/poison the limit which animals can feed. 2. Adaptation. Allowing animals to diversify only during spawning limits the effect of the mutation system. Consider allowing them to adapt at any time in response to stress.
great that you changed the colors again because the colors/contrast of the second video were a bit unpleasing to look at. i love this series, hopefully it continues. there are still some neat ideas that i could come up with that could be implemented. edit: to be fair...the colors of the first videos were by far the best. still fine to look at ;)
the predators learnt to follow other predators, meaning when the first one sees some prey, it looks like a big conga line starts up just predators following predators knowing that at the end of the chain is prey.
Memory is hard. I tried it once. Can you show the NNs that were evolved as the sim progresses? That'd would be cool to see. Great sim! I have some on my channel too.
One issue with balancing the simulation might be the way reproduction is working. Right now, it looks like it works the same for both species: amass enough energy, produce 1 offspring. In the real world, prey species like rabbits and mice don't have just one baby at a time. They give birth to multiple pups at a time. As well, your predator and prey species seem to have the same general mass. In the real world, prey species tend to be smaller, while predator species are larger. Prey species need to be able to reproduce using *less* energy than predators do, and when they do, they need to be able to make multiple offspring at a time.
Simulation could be extended by creating a "safe heaven" regions for different species. For example if there was a region where predators could not enter then preys would have slower chance of being eradicated. Another option is to simply clone/reproduce organisms to random places if their number fall below critical threshold.
id recomend adding an "insect" it would be a supplemental food source for the predators that appear randomly like plants and move around but at a much slower rate, and offers much less food. they would have minimal AI (basically "move away from red") and would not be subject to evolution. this would relive pressure off of the prey id also make the maps do a pac-man loop so they don't get trapped in corners
A size modifier could be cool, bigger means tougher but more energy needed, smaller prey might be harder to spot too. A speed modifier could also be good, faster is more energy intense. This combo could lead to a lot more diversity and perhaps longer stability before collapse.
Oh, I have been waiting so long for another one of these videos. It's so good to finally have one. I think these will be some nice additions for a future video: 1. The rate of plant growth should be proportional to rate at which they are being eaten (simulating seed dispersion). 2. Adding screen wrap. 3. Having states like `isBeingAttacked` etc. 4. Different types of pheromones.
Hey i just want to say that I think what your doing is super interesting, would love to see the programming that goes on behind it, but that may detract from the time you could use else where in this projects.
Amazing project! Love the content. Suggestion: consider making the predators a bit smarter. Currently, they're relying on numbers to hunt effectively, which isn't how predators typically operate-it's more characteristic of prey. This could prevent the current issue where prey populations explode, devour all the plants, and trigger a massive predator spawn. When plants are wiped out and predators are overly abundant, prey end up going extinct. Predators should focus on being efficient hunters, controlling prey populations EARLY to prevent plant depletion and unsustainable prey growth.
I'd love to see some addional complexity to the predators. Perhaps most predators avoid consuming other predators, but have a neuron for that, and have a neuron for cannibalism that can be switched on during mutation. Also a system for tracking lineage.
I love these! I'm sure you get asked this a lot, but what do you program these simulations on? And how do you manage performance with all those physics collisions???? Great video :)
I'm curious - how did you get this to be so performant? More than 600 AIs running at ~2 milliseconds per frame is awesome, with probably tens of thousands of raycasts
I think adding communication will extend the simulation a lot. Communication gives both predator and prey the ability to coordinate to find foods -> no more creature running in circle waiting for their reserve to deplete. Also having a kind of gene map at the end would be great, we can see what did the creatures learn after thousands of generation
seems like prey and predators should not be separated in two classes it could be an emergant behaviour from the neural net you could distinguish them by hashing the neural net and mapping that to a color you could see different types of strategies and groups emmerge they both need to be able to eat plants and other preys but the "genes" or neural net should dictate the ratio or how much enrergy you get from one
One thing that's fairly realistic and might be worth a try is penalizing larger NNs (based on some combination of number of neurons and of connections) by making agents with larger networks consume more energy. From the realism angle, this mirrors the fact that cognition requires a lot of energy of animals (and typically longer development time, etc.), while from the point of view of enhancing simulation stability, it may serve to reduce the effectiveness of the predators at late times. Likely some of the other suggestions in the comment section would have a more drastic effect on stability, but due to the naturalness of this idea and the fact I didn't see others mention it at a glance, I thought I'd put it out there.
Other things you could add. Breeding mechanic: Share 50% of genes with the closest member of the same species when reproducing. Add barriers to the map that only certain species can pass (at high energy cost).
I think the problem might be that the creatures don't alter their behavior based on circumstances. If you overall nerf the predators, in times of crisis they'll go extinct immediately, after all we saw them getting as low as under 20 a few times. But if you keep them as they are, they eventually drive the herbivores out of existence. Basically I'm saying that in real life animals alter how they behave when there's famine or bounty, you need a dynamically changing creature for it to survive. If all animals remained the same between spring and winter (as an example of bounty/famine), of course they'd go extinct.
I always love seeing complex behavior deriving from simple assumptions. If you want to extend the simulation a good idea would be changing up the physical environment. I feel like features like peninsulas create a safe haven for prey. It's sort of a buffer like a capacitor in electrical circuits smoothing out the current. I would also like to see you adding big plants like trees which can't be eaten by regular prey but can give coverage and slow down predators or hide from them. Later you could add big prey like elephants or giant sloths (which are extinct now) which would have fewer predators but they would be more expensive to maintain. The bigger prey could take down bigger plants which in turn could potentially give nutrients for smaller plants. I think that introducing these things would create a forest ecosystem.
love your videos. I dont know much about CS or coding but I love problem solving & seeing other do the same. Regarding your simulation here are some things that come to mind 1. 1% law - the amount of energy transfer from plant to prey & prey / predator to food should be 1%. this is how it works in real life maybe that'll nerf your predators a bit. 2. Looking at the parameters in 3:11 maybe add a gestation coeff. , size coeff. making them so that the prey can evolve into different forms and have various strategies of surviving. maybe you''ll get mice and elephants. 3. At 2:08 you have kept kills and split trackers, maybe add offspring trackers (Gestation Coeff. ?) and a timer to death (this can be the life co efficient). 4. Again at 3:11 there are zone 1 zone 2 and other nodes.dont understand what they are for (Memory?). Also how about simulating in a circular world or making the sides continuous with the other sides (like in the game - snake). 5. All co efficients must interact with each other with hard limits on some. If you are going to introduce other balancing mechanics, how about giving these a try.
This is awesome. Like every single video you make. It's always a pleasure to watch your work, this is so interesting, awesome to watch and inspiring at the same time for my projects ! Btw, I was wondering (if you have the time) if you could make a video on how to build neural networks, the one you use because... I tried to make it myself but it's really hard and im sure you could explain it easily ! Like back propagation algorithm etc... That would be awesome, but I dont know if it would match the channel theme since it would be a more coding video. That's just an idea actually. So thank you if you ready my comment (and sorry for the mistakes, im french😅)
Based on my own very similar work with artificial life, the observed group behavior is likely an artifact of the basic "find food" neural network path. Basically, agents follow anything of interest in the hope that is or will lead to food. It isn't complex social behavior, but it is still an interesting and welcomed development. I also agree it is very hard to balance this situation without ending in either a monoculture or extinction. One area of possible expansion would be to have multiple types of food. That would make the simulation slower, but increase diversity. Thanks for these AI-ecosystem experiments. Looking forward to more!
Based on all this boom-and-bust, I'd look at lowering the value of the food: prey should need much more food from plants to survive and reproduce, and similarly predators should need much more food from prey. Watching hundreds of predators squirming around indicates to me that there needs to be much less energy conservation from plant to prey to predator. We just don't see those kinds of out-of-balance numbers in nature.
I think the graphs really show that the predator reaction is much too high when prey is numerous in a way that feels unnatural. I would suspect a combination of prey food value and predator reproduction cost+time is a large contributing factor. Predator animals often take higher energy to produce and more time and there is a loss in energy transfer each step in a food chain. Also adding a physical size difference between prey and predator would help prey hide in the plants
It looks to me like the instability is coming from the sheer size of the fluctuations and how long the creatures are lasting after exhausting their food sources; when the plant supply in a region gets low, the prey consistently wipe it out completely and become an enormous population, then the predators come in an enormous wave and wipe them out with their own enormous population, leaving no survivors. Faster dieoff when the local food is exhausted might help, since it would give a better chance that they don't completely wipe out their food source first, and wouldn't cause a large spike of prey to create *such* a large spike of predators, making recovery easier. (The oscillations are absolutely to be expected, of course - that's more or less just standard Lotka-Volterra happening there.) The other possibility is to have caps on how dense the plants can get - that would limit how many prey you get, which limits how many predators you get, which makes the whole system more stable. (Or even just... reduce the food value of plants.); embrace the paradox of enrichment.
If you want to extend the simulation, you should honestly add more _limits_ to the actors. Stuff like the energy system and metabolism are good ideas, to ensure they can both survive longer periods without food and tend towards sedentary lifestyles when allowed. Besides this, it also allows meat-based foods to be more energy-dense and give more energy with less eating, and produce energy faster (so predators tend to be faster than prey while also able to survive (and forced to) eating less often than prey so they don't deplete the prey. This would then go hand-in-hand with ability to kill other predators so it might develop territorial behaviours (maybe even developing so it doesn't target ones within its own "group", however it would remember which ones belong to it)). But more than that, you need to prevent overpopulating when food is abundant only to then end up starving. You can do that in some ways, such as penalize overpopulation even further through "disease" or perhaps even inbreeding (so if an actor reproduces too much while remaining in the same area, its offspring will only find siblings, and so the next generation has wild mutations lowering their viability) might work? I think a better way to achieve it however, would be to add _seasons._ So the plants naturally give less (or even no) food at times, but then start giving an abundant amount again after a while (shorter than the time it would need to regrow if plants were wiped out entirely - particularly if remnants slowed it down by nibbling until predators found them). This should make overpopulation much less likely due to starving individuals dying during the winter, and well-fed ones surviving. And indirectly affect predators likewise as prey becomes less common in winter - particularly if you enable them to possibly learn to "hide" (burrows or whatever, with some cost beyond staying still to ensure it isn't spammed. Maybe a delay and cooldown to hide + short delay to unhide?) so predators must be closer to detect them (so if they find that food is scarce and season-sense say it is winter, they are likely to learn to conserve by staying still, and triggering the stealth bonus while staying still anyway). Aside from that, you really should try and "stagger" the introduction of the prey and predator groups, by first having the prey get to stabilize with the plants, and then make some of them turn into omnivores that can eat remains of other prey, followed by ability to kill the prey to eat it, followed by disabling the ability to eat plants for some (could be done by having the metabolism simulation optimize for extracting energy from plants vs meat, on a spectrum, where the actor's weights specify where it lies. Then it should happen naturally as it slowly develops the ability to make use of it). Main issue is that when a predator ends up successful enough to easily hunt, it will overpopulate and wipe out the prey. But this should be solvable if these mutations take long enough that the prey develop the ability to cope (hopefully). Other than that, "spreading out" the actors and plants such that they are more reliant on remaining efficient and overall unable to cover the entire map, might help (then they shouldn't just become large waves wiping out all food by converting it into a continuation of the shield wall)? Or might be enough to simply lower the rate of food -> reproduction so they need to eat for longer before they do. Finally, since your simulation is very limited in scope, maybe add spawning of duplicates of the last x prey/predator when they are wiped out, after a while? To let them pick up and resume from where they left off in their evolution. But to discourage them from taking "advantage" of that by simply speccing to outlast all others by staying still, you might also want to have a filter/bias towards actors that moved further in their lifetime (also emulates exodus of predators from other areas that had gotten wiped out)
I feel like rn abundance can support too large quantities of a population. Maybe consider letting creatures mature because reproducing e.g having to eat and also use up X quantities of food before food surplus can be used for reproduction Maybe this can be part of the evolutionary alg. by letting the creature change how long this takes. To make it worth while make each of these steps increases a new score fortitude. Fortitude increases health, storable energy, increases the damage threshold and how much damage a creature can do. So predictors that mature faster can only do less damage and may not be able to damage prey that invested in a lot of fortitude at all besides their young. On the contrary prey that doesn't mature for long can multiple quickly while it is also very vulnerable and unable to weather food shortages. Prey that matures for long on the other hand can at certain maturity ignore or fight off young predictors and out wait food shortage on the flip side that it needs to eat and wait a long time to be able to reproduce offsprings. You would need to feed the information of maturity (currently fortitude) as part of sight tho as it would massively influence behaviours
Wow, I've seen a few comments about how to improve the simulation, but this is the best by far that I've encountered. I love how you don't want to add a dozen new genes and totally rework the environment to implement more diversity.
Lovely ! It's sweet to see ideas I had before being made real. I wonder how you get decent performances with all those eye's ray checks ? I loved your earlier video on optimization, would love to see a new one on the matter. Idea : Pheromone system that could allow some form of group communication ?!
the code that defines predator and prey isn't much different at first, so perhaps randomly generating(at the start(and mutating ofc)) energy gained by consuming plants and others and having one creature to start off with and the plants, some species could organically emerge that get more energy from plants and go after plants, while others get more energy from eating others than plants and choose to hunt rather than eat the plants. there'll be those in between, but I'm curious what will be the dominant creature. is it perfectly balanced by the end? I'm betting mostly on predator side of scale with a bit of energy from plants so it can survive on plants. mutating and randomly generating the vision of the creatures with more vision requiring more energy overall, whether the "prey" side will prefer less or more vision or not.
Really enjoy seeing these videos. Very relaxing. Noticeably the predators population remains exceptionally high in comparison to the prey. Not sure if the predators also feast on the flesh of their own dead brethren. Perhaps allowing predators that prey on other predators based on size and by which must eat more prey items to multiply or acquire the same energy. Anything to help keep the predators population from being exceptionally high in comparison to the preys (larger predators, more surface area, harder to follow prey into bushes).
been following this since the first video of yours I saw. maybe predators (or prey) could turn into a nucleation site for plant spawns after it dies? like the carcass fertilizes the area after decomposing
You might try keeping the last N neural nets for each species, then if both die out place those back into the arena. Genetic algorithms benefit greatly from elites, and this is a vague approximation of that.
So the big swinginess problem seems to be due to predators reproducing far too rapidly. They're overreacting to fairly modest bumps in prey population by exploding wildly. Is reproduction rate part of your behavior weights, or is it hardcoded after getting a certain amount of food? I think it makes sense for it to be the former. Also, one thing you can seek to emulate from real ecosystems is that total biomass stays approximately constant in an environment: you have it set up so that plants input biomass into the system and energy use outputs biomass from the system, and the whole sim is just waiting for the flow from one to the other to stabilize, which it always will because entropy. You instead need to connect the ends together somehow so that biomass is fed into the beginning of the system from the end.
Makes me wonder about adding multiple predator/prey sizes. Small predators can only eat small prey, larger predators can eat larger prey and small predators. Also, what are the pros and cons of using raycast for vision instead of simply feeding them the info of the nearest X number of each object type, eliminating anything outside of what you would set as their FOV?
Have you thought about introducing an environmental oscillation in the system? Like seasons, where there is a periodical fluctuation of food availability independent of the population
How do they reproduce? On a timer? Just when ever they eat enough? An interesting thing you could add is how much they reproduce is a mutatable stat. Prey could go for a rat/rabbit strategy of have as many offspring as possible, or invest in a few high quality children. You'd think a 'do not reproduce' mutation would be a fast extinction, but if it can be a recessive gene where the parent still can have children then you have a bee/ant hive. But you'd need cooperation for that to have any utility.
@PezzzasWork -- I suggest relaxing those rigid roles somewhat, so that there is at least some potential for mutations to allow trade-offs such as predators or pray that can get some nourishment out of plants and also some nourishment out of prey, or perhaps plants that can move, but need to eat food to sustain their ability to do so you might also consider allowing some to evolve egg-laying, what's different amounts of time until the egg hatches, and have the eggs not be a food source for anything by default, but allow the possibility of evolving the ability to use eggs as a food source. Considering eggs as a life stage, you could possibly also allow some to evolve other life stages. Remember, Earth life isn't the only thing that involves. In fact life isn't the only thing that involves. Practically everything does. Look at the evolution of languages, societies, skills, landscapes, ecosystems, technology, and so on, and you should find plenty of inspiration.
I tried doing one of my own of these. I have a hard time maintaining a stable ecosystem, eventually the predators or prey die out. Reproduction is not asexual so I wonder how much that has to do with it.
I feel like adding plants didn't really solve the issue of the population being artificially limited but instead abstracts it out to the replenishment rate of plants
The programming/optimization side of this project has been fun and impressive to watch, but I think you should spend some more time looking at real world ecosystems/ecology for inspiration.
LOVE these AI simulated ecosystem videos. Thanks Pezzza! Keep up the great work!
Thank you!
@@PezzzasWork What did you use to make this?
@@Ibloop SFML for the graphics library; I'm pretty sure it's all covered in ua-cam.com/video/t0z3RojiKFg/v-deo.html&ab_channel=Pezzza%27sWork
@@PezzzasWork Please make a game
Can you make the simulation so thar when prey and predators die, the plants will get the nutritions from the soil to grow faster.
Amazing simulation! I think separating the world with some walls that have openings, to create speciation, could help reduce the amount of extinctions. I can imagine those waves which wipe out the majority of the prey (then consequently the predators) can be isolated to specific areas. Can't wait for part 4!
I think it's hard to balance because the plant growth is slower than the reproduction/maturation rate of the animals. IRL wild herbivores are part of the life cycle of many plants, getting eaten isn't bad, it fertilizes the soil and propagates seeds. Total loss of ground cover is not part of normal fluctuation in population levels, it's a natural disaster.
Growing on that, not all the energy can be transfered to the next level, meaning that a prey only uses a % of the energy of the consumed plant and predator gets only a % of the enrgy of eaten prey, this will reduce the growth of predators and prey, making prey food more abundant.
Each level of plant life gives different energy inputs, meaning that prey might choose to e
yes but herbivores doesn't eat hole plant and they are free range in bigger plane. and same time carnivores have harder time to hunt not every hunt successful many of them if they are not cooperate while hunting lover then 25%
Very nice. I've dabbled in the subject a bit. This is what I'd do to avoid extinctions (best benefit/cost first):
1. Regional variation: This can be as simple as the left of the screen has high reserve loss and the right has less. Or maybe the energy cost per move speed formula is different on part of the map. Ideally there would be a sharp change between these regional properties. The change in each property should be a neuron input. The goal is to have specialist populations in the regions so that migrants from a different region will tend to be outcompeted. It's important because it means that a population collapse in one region is less likely to affect the others, and when that happens the remaining populations can spread to the dead zones.
2. Barriers: The most effective barrier is a large shape in the middle of the map but more complicated shapes can be better. The goal is to divide populations more, and make it harder for a new evolutionary advantage to propagate everywhere. Not the most effective tool, but an easy one.
3. Memory: This can be as simple as adding a neuron that appears both as an output and an input, the output from the last step becomes the input for the current step. A creature could add multiple of these with connections as they do in hidden layers. The goal is to let prey go into a more persistent run / emigration state when there are too many predators in a given area.
4. Reduce predator carrying capacity compared to prey: The easy way is to just reduce the food value of food from prey. The goal is to stop predators blanketing an area. Prey in emigration mode would ideally have a chance to run out of a risky area, but that's too difficult if the predator population is overwhelming.
5. Stratification: This is the most important one but also by far the hardest to do. Ideally there would be different plant types and physical properties for animals such that there are specialists for a lot of different things. In particular, it should be very difficult for a predator to be able to attack both large and small animals (too evasive, or too resistant). As with regional variation, the benefit is that even if one layer of the population collapses, creatures from another layer can adapt to make use of the new empty layer.
6. Simulation size: Bigger maps with bigger populations. The distance helps with the regional isolation aspect, and the larger populations help the statistics of small populations somewhere. It's often the most costly and least interesting improvement so it's last on my list.
Are you familiar with The Bibites? It checks a lot of these boxes. The dev isn't very active on YT or in the community, but it's free to download and play with.
Factorio developer jumpscare
I noticed the creatures have no way of knowing if they are being backstabbed or if their health is depleting. They have no short-term memory to allow them to notice their health is dropping and will only know that their health is currently high or low. You can probably create some more reactive AIs if you provide a way for them to have memory and/or extra information to state that they are in an exceptional situation (like isStarving or isBeingAttacked inputs).
Adding something like a generic call output that others can hear as an input will also allow your AIs to communicate and evolve in interesting ways -- I venture to guess they can even mimic memory with a simple output/input like that.
honestly memory is the biggest thing. Like yeah, sound would help prey know when there was a predator near, and they are all doing the stupid spinning because they have no memory
an array of output neurons that carry their values to inputs neurons the next tick would be really useful
The prey seem to stay where there's food and when it's gone, they still stay there... perhaps because it worked so great for them before and they continue past behavior. And then the predators come in and devastate the area. The predators are forced to move because the prey move. Maybe if the plants didn't all spawn together, but rather in small clusters. Or if the plants could die after a time and respawn a certain distance away. Something to force the prey to move to get food.
Proposal: make an elman network, BUT compute and update the hidden neurons one by one (so each node uses the new outputs of previous nodes in the same layer, and the old outputs of later nodes). This way, each node is its own layer, thus you get a very deep and wide net at the same time. The recurrent connections are also deeper than linear
@@TheAechBombthats called RNNs and theyre a pain
I'm curious what makes the prey think backwards loop-de-loops landing directly into a predator's mouth is a solid strategy lmao
since moving forward and backwards is the same speed and prey has much bigger visual cone it probably helps to get out of the predators sight
A periodic forcing function might help stabilize your predator/prey relationship by allowing recovery of each. Something like plants grow best spring and summer thus prey grow best spring to fall and predators survive on fat in the fall/winter but prey burrows to hibernate and become the seeds of the next seasons population. It would take a lot of evolution to spontaneously generate that kind of complex behavior.
Always enjoy your work, thank you for sharing.
Of all the possible improvements, I think you'd be best served by two things.
1. Plant resilience. The prey-plant interaction is quite basic. Plants don't normally get wiped out by grazers. They employ strategies like seed dispersal through feces, roots that regrow annually, and defenses like thorns/poison the limit which animals can feed.
2. Adaptation. Allowing animals to diversify only during spawning limits the effect of the mutation system. Consider allowing them to adapt at any time in response to stress.
Glorious project! Love your videos!!
an omnivore would dominate your entire simulation
You mean a cannibal?
@@edwinschaap5532
are you a cannibal if you eat a cow?
you are both mammals...
you both have common ancestors
@@edwinschaap5532
his carnivores are also cannibals
that is, if you want to look at it that way...
@TAB_100no, they only eat the vegans, not each other.
@TAB_100a cow is another species. At 19:23 he talks about adding other predator species.
great that you changed the colors again because the colors/contrast of the second video were a bit unpleasing to look at. i love this series, hopefully it continues. there are still some neat ideas that i could come up with that could be implemented.
edit: to be fair...the colors of the first videos were by far the best. still fine to look at ;)
Personally these colours are the best so far, the original colours got real hard to tell apart at a glance when the creatures mixed together
FINALLY! I've wanted to see another one of these in FOREVER.
the predators learnt to follow other predators, meaning when the first one sees some prey, it looks like a big conga line starts up just predators following predators knowing that at the end of the chain is prey.
good example from 11:00 where the predators cant see the prey but can see other predators moving in one direction.
Memory is hard. I tried it once.
Can you show the NNs that were evolved as the sim progresses? That'd would be cool to see.
Great sim!
I have some on my channel too.
What memory architecture did you try? Elman? Neat? Gru/lstm? Fast weights?
You got some of the coolest videos on UA-cam. Thanks for posting this
Yesss the AI goat is back!!!
One issue with balancing the simulation might be the way reproduction is working. Right now, it looks like it works the same for both species: amass enough energy, produce 1 offspring. In the real world, prey species like rabbits and mice don't have just one baby at a time. They give birth to multiple pups at a time. As well, your predator and prey species seem to have the same general mass. In the real world, prey species tend to be smaller, while predator species are larger. Prey species need to be able to reproduce using *less* energy than predators do, and when they do, they need to be able to make multiple offspring at a time.
Simulation could be extended by creating a "safe heaven" regions for different species. For example if there was a region where predators could not enter then preys would have slower chance of being eradicated. Another option is to simply clone/reproduce organisms to random places if their number fall below critical threshold.
Get excited when ever you post, inspired me to try crafting a neat framework to build my own sims.
I was just thinking about your channel today and was gonna check for a video. Perfect timing!
This is such a treat of a video and has made my day! This series is one of my favorites on UA-cam!
id recomend adding an "insect"
it would be a supplemental food source for the predators that appear randomly like plants and move around but at a much slower rate, and offers much less food. they would have minimal AI (basically "move away from red") and would not be subject to evolution. this would relive pressure off of the prey
id also make the maps do a pac-man loop so they don't get trapped in corners
why donut world?
A size modifier could be cool, bigger means tougher but more energy needed, smaller prey might be harder to spot too. A speed modifier could also be good, faster is more energy intense. This combo could lead to a lot more diversity and perhaps longer stability before collapse.
Oh, I have been waiting so long for another one of these videos. It's so good to finally have one.
I think these will be some nice additions for a future video:
1. The rate of plant growth should be proportional to rate at which they are being eaten (simulating seed dispersion).
2. Adding screen wrap.
3. Having states like `isBeingAttacked` etc.
4. Different types of pheromones.
I would be interested in seeing what happens if you make food turn into plants if uneaten for a certain amount of time
Amazing work as always !
Thanks!
Pezzza's Videos Are Always Awesome!
IVE BEEN WAITING FOR THIS FOR YEARS!!! I LITERALLY LOOKED FOR THIS VIDEO YESTERDAY!!!
Took bro 2 years to come back 😭 🙏
Hey i just want to say that I think what your doing is super interesting, would love to see the programming that goes on behind it, but that may detract from the time you could use else where in this projects.
This stuffs cool af thanks for makin it ive been waiting forever for another one , happily of course
this would be so cool as a sandbox game to play
Amazing project! Love the content. Suggestion: consider making the predators a bit smarter. Currently, they're relying on numbers to hunt effectively, which isn't how predators typically operate-it's more characteristic of prey. This could prevent the current issue where prey populations explode, devour all the plants, and trigger a massive predator spawn. When plants are wiped out and predators are overly abundant, prey end up going extinct. Predators should focus on being efficient hunters, controlling prey populations EARLY to prevent plant depletion and unsustainable prey growth.
I'd love to see some addional complexity to the predators. Perhaps most predators avoid consuming other predators, but have a neuron for that, and have a neuron for cannibalism that can be switched on during mutation. Also a system for tracking lineage.
Does the ray tracing "see" the walls at all? I noticed some clustering near the corners once in a while
I would have really expected simulations of this kind to be more stable then they apperently are
Always excited to see a new video of yours.
I love these! I'm sure you get asked this a lot, but what do you program these simulations on? And how do you manage performance with all those physics collisions???? Great video :)
Is it available for download?
I'm curious - how did you get this to be so performant? More than 600 AIs running at ~2 milliseconds per frame is awesome, with probably tens of thousands of raycasts
I think adding communication will extend the simulation a lot. Communication gives both predator and prey the ability to coordinate to find foods -> no more creature running in circle waiting for their reserve to deplete.
Also having a kind of gene map at the end would be great, we can see what did the creatures learn after thousands of generation
omg!!!!! very excited. always love your work :)
Thank you!
I missed this series!! Id love to see more!
predators: Target in sight, switching to attack mode
prey: SPEEEEEEEEEEEEN😆
Man I don't even know how long I've been waiting for the next one in this series
seems like prey and predators should not be separated in two classes
it could be an emergant behaviour from the neural net
you could distinguish them by hashing the neural net and mapping that to a color
you could see different types of strategies and groups emmerge
they both need to be able to eat plants and other preys but the "genes" or neural net should dictate the ratio or how much enrergy you get from one
One thing that's fairly realistic and might be worth a try is penalizing larger NNs (based on some combination of number of neurons and of connections) by making agents with larger networks consume more energy. From the realism angle, this mirrors the fact that cognition requires a lot of energy of animals (and typically longer development time, etc.), while from the point of view of enhancing simulation stability, it may serve to reduce the effectiveness of the predators at late times. Likely some of the other suggestions in the comment section would have a more drastic effect on stability, but due to the naturalness of this idea and the fact I didn't see others mention it at a glance, I thought I'd put it out there.
Amazing video! The next best step would be to add a form of communication between individuals!
Other things you could add. Breeding mechanic: Share 50% of genes with the closest member of the same species when reproducing. Add barriers to the map that only certain species can pass (at high energy cost).
Will there be any analysis of their neural networks?
This looks sick man
I think the problem might be that the creatures don't alter their behavior based on circumstances.
If you overall nerf the predators, in times of crisis they'll go extinct immediately, after all we saw them getting as low as under 20 a few times.
But if you keep them as they are, they eventually drive the herbivores out of existence.
Basically I'm saying that in real life animals alter how they behave when there's famine or bounty, you need a dynamically changing creature for it to survive.
If all animals remained the same between spring and winter (as an example of bounty/famine), of course they'd go extinct.
When is the big big predators to hunt predators and prey and maybe plants but die faster and is slower (can do 2x predator damage has has 2x heath)
Do you have the source code in yout github?
Maybe, just look for it in his repos
10:59 "most predators move slowly" Then the literal Flash scoots on from North-West FREEEEOOOOOOOOOOOOOOOOOOOOWWWWWWWM
I'm so glad you added plants!
I always love seeing complex behavior deriving from simple assumptions.
If you want to extend the simulation a good idea would be changing up the physical environment. I feel like features like peninsulas create a safe haven for prey. It's sort of a buffer like a capacitor in electrical circuits smoothing out the current.
I would also like to see you adding big plants like trees which can't be eaten by regular prey but can give coverage and slow down predators or hide from them. Later you could add big prey like elephants or giant sloths (which are extinct now) which would have fewer predators but they would be more expensive to maintain. The bigger prey could take down bigger plants which in turn could potentially give nutrients for smaller plants.
I think that introducing these things would create a forest ecosystem.
love your videos. I dont know much about CS or coding but I love problem solving & seeing other do the same.
Regarding your simulation here are some things that come to mind
1. 1% law - the amount of energy transfer from plant to prey & prey / predator to food should be 1%. this is how it works in real life maybe that'll nerf your predators a bit.
2. Looking at the parameters in 3:11 maybe add a gestation coeff. , size coeff. making them so that the prey can evolve into different forms and have various strategies of surviving. maybe you''ll get mice and elephants.
3. At 2:08 you have kept kills and split trackers, maybe add offspring trackers (Gestation Coeff. ?) and a timer to death (this can be the life co efficient).
4. Again at 3:11 there are zone 1 zone 2 and other nodes.dont understand what they are for (Memory?). Also how about simulating in a circular world or making the sides continuous with the other sides (like in the game - snake).
5. All co efficients must interact with each other with hard limits on some.
If you are going to introduce other balancing mechanics, how about giving these a try.
I wonder what would happen if all 3 organisms have huegene-style colors and preferences
This is awesome. Like every single video you make. It's always a pleasure to watch your work, this is so interesting, awesome to watch and inspiring at the same time for my projects ! Btw, I was wondering (if you have the time) if you could make a video on how to build neural networks, the one you use because... I tried to make it myself but it's really hard and im sure you could explain it easily ! Like back propagation algorithm etc... That would be awesome, but I dont know if it would match the channel theme since it would be a more coding video. That's just an idea actually. So thank you if you ready my comment (and sorry for the mistakes, im french😅)
Based on my own very similar work with artificial life, the observed group behavior is likely an artifact of the basic "find food" neural network path. Basically, agents follow anything of interest in the hope that is or will lead to food. It isn't complex social behavior, but it is still an interesting and welcomed development. I also agree it is very hard to balance this situation without ending in either a monoculture or extinction. One area of possible expansion would be to have multiple types of food. That would make the simulation slower, but increase diversity. Thanks for these AI-ecosystem experiments. Looking forward to more!
Based on all this boom-and-bust, I'd look at lowering the value of the food: prey should need much more food from plants to survive and reproduce, and similarly predators should need much more food from prey. Watching hundreds of predators squirming around indicates to me that there needs to be much less energy conservation from plant to prey to predator. We just don't see those kinds of out-of-balance numbers in nature.
YESS! PEZZZA DROPPED A NEW VIDEO! Today is a good day.
I think the graphs really show that the predator reaction is much too high when prey is numerous in a way that feels unnatural. I would suspect a combination of prey food value and predator reproduction cost+time is a large contributing factor. Predator animals often take higher energy to produce and more time and there is a loss in energy transfer each step in a food chain. Also adding a physical size difference between prey and predator would help prey hide in the plants
It looks to me like the instability is coming from the sheer size of the fluctuations and how long the creatures are lasting after exhausting their food sources; when the plant supply in a region gets low, the prey consistently wipe it out completely and become an enormous population, then the predators come in an enormous wave and wipe them out with their own enormous population, leaving no survivors.
Faster dieoff when the local food is exhausted might help, since it would give a better chance that they don't completely wipe out their food source first, and wouldn't cause a large spike of prey to create *such* a large spike of predators, making recovery easier. (The oscillations are absolutely to be expected, of course - that's more or less just standard Lotka-Volterra happening there.)
The other possibility is to have caps on how dense the plants can get - that would limit how many prey you get, which limits how many predators you get, which makes the whole system more stable. (Or even just... reduce the food value of plants.); embrace the paradox of enrichment.
If you want to extend the simulation, you should honestly add more _limits_ to the actors. Stuff like the energy system and metabolism are good ideas, to ensure they can both survive longer periods without food and tend towards sedentary lifestyles when allowed. Besides this, it also allows meat-based foods to be more energy-dense and give more energy with less eating, and produce energy faster (so predators tend to be faster than prey while also able to survive (and forced to) eating less often than prey so they don't deplete the prey. This would then go hand-in-hand with ability to kill other predators so it might develop territorial behaviours (maybe even developing so it doesn't target ones within its own "group", however it would remember which ones belong to it)).
But more than that, you need to prevent overpopulating when food is abundant only to then end up starving. You can do that in some ways, such as penalize overpopulation even further through "disease" or perhaps even inbreeding (so if an actor reproduces too much while remaining in the same area, its offspring will only find siblings, and so the next generation has wild mutations lowering their viability) might work? I think a better way to achieve it however, would be to add _seasons._ So the plants naturally give less (or even no) food at times, but then start giving an abundant amount again after a while (shorter than the time it would need to regrow if plants were wiped out entirely - particularly if remnants slowed it down by nibbling until predators found them). This should make overpopulation much less likely due to starving individuals dying during the winter, and well-fed ones surviving. And indirectly affect predators likewise as prey becomes less common in winter - particularly if you enable them to possibly learn to "hide" (burrows or whatever, with some cost beyond staying still to ensure it isn't spammed. Maybe a delay and cooldown to hide + short delay to unhide?) so predators must be closer to detect them (so if they find that food is scarce and season-sense say it is winter, they are likely to learn to conserve by staying still, and triggering the stealth bonus while staying still anyway).
Aside from that, you really should try and "stagger" the introduction of the prey and predator groups, by first having the prey get to stabilize with the plants, and then make some of them turn into omnivores that can eat remains of other prey, followed by ability to kill the prey to eat it, followed by disabling the ability to eat plants for some (could be done by having the metabolism simulation optimize for extracting energy from plants vs meat, on a spectrum, where the actor's weights specify where it lies. Then it should happen naturally as it slowly develops the ability to make use of it). Main issue is that when a predator ends up successful enough to easily hunt, it will overpopulate and wipe out the prey. But this should be solvable if these mutations take long enough that the prey develop the ability to cope (hopefully).
Other than that, "spreading out" the actors and plants such that they are more reliant on remaining efficient and overall unable to cover the entire map, might help (then they shouldn't just become large waves wiping out all food by converting it into a continuation of the shield wall)? Or might be enough to simply lower the rate of food -> reproduction so they need to eat for longer before they do.
Finally, since your simulation is very limited in scope, maybe add spawning of duplicates of the last x prey/predator when they are wiped out, after a while? To let them pick up and resume from where they left off in their evolution. But to discourage them from taking "advantage" of that by simply speccing to outlast all others by staying still, you might also want to have a filter/bias towards actors that moved further in their lifetime (also emulates exodus of predators from other areas that had gotten wiped out)
exactly the video i needed to wind down after working 15 hours today :D
I feel like rn abundance can support too large quantities of a population. Maybe consider letting creatures mature because reproducing e.g having to eat and also use up X quantities of food before food surplus can be used for reproduction
Maybe this can be part of the evolutionary alg. by letting the creature change how long this takes. To make it worth while make each of these steps increases a new score fortitude. Fortitude increases health, storable energy, increases the damage threshold and how much damage a creature can do.
So predictors that mature faster can only do less damage and may not be able to damage prey that invested in a lot of fortitude at all besides their young.
On the contrary prey that doesn't mature for long can multiple quickly while it is also very vulnerable and unable to weather food shortages.
Prey that matures for long on the other hand can at certain maturity ignore or fight off young predictors and out wait food shortage on the flip side that it needs to eat and wait a long time to be able to reproduce offsprings.
You would need to feed the information of maturity (currently fortitude) as part of sight tho as it would massively influence behaviours
Before reproducing*
Wow, I've seen a few comments about how to improve the simulation, but this is the best by far that I've encountered. I love how you don't want to add a dozen new genes and totally rework the environment to implement more diversity.
Esto debería ser un juego haces un trabajo bien :)
Please again ! for the revenge of prey ! 💙
Lovely ! It's sweet to see ideas I had before being made real. I wonder how you get decent performances with all those eye's ray checks ? I loved your earlier video on optimization, would love to see a new one on the matter.
Idea : Pheromone system that could allow some form of group communication ?!
Yooo can i play this as well?
Love this series!
the code that defines predator and prey isn't much different at first, so perhaps randomly generating(at the start(and mutating ofc)) energy gained by consuming plants and others and having one creature to start off with and the plants, some species could organically emerge that get more energy from plants and go after plants, while others get more energy from eating others than plants and choose to hunt rather than eat the plants. there'll be those in between, but I'm curious what will be the dominant creature. is it perfectly balanced by the end? I'm betting mostly on predator side of scale with a bit of energy from plants so it can survive on plants. mutating and randomly generating the vision of the creatures with more vision requiring more energy overall, whether the "prey" side will prefer less or more vision or not.
Really enjoy seeing these videos. Very relaxing. Noticeably the predators population remains exceptionally high in comparison to the prey. Not sure if the predators also feast on the flesh of their own dead brethren. Perhaps allowing predators that prey on other predators based on size and by which must eat more prey items to multiply or acquire the same energy. Anything to help keep the predators population from being exceptionally high in comparison to the preys (larger predators, more surface area, harder to follow prey into bushes).
Even more so, if you make different foliage types of different density or resistances, could play further on the sizes effect on hunting/gathering
been following this since the first video of yours I saw.
maybe predators (or prey) could turn into a nucleation site for plant spawns after it dies? like the carcass fertilizes the area after decomposing
idea: make predators have eyes directly in front, and prey have eyes off to the sides
I love this kind of videos!
i was literally watching the older episodes 10 minutes ago
I was literally wanting to watch such calming to fall asleep.
This is amazin as always
You might try keeping the last N neural nets for each species, then if both die out place those back into the arena. Genetic algorithms benefit greatly from elites, and this is a vague approximation of that.
Great work! Do you use neataptic?
Yeeeees, the best serie is back!!!!!
So the big swinginess problem seems to be due to predators reproducing far too rapidly. They're overreacting to fairly modest bumps in prey population by exploding wildly. Is reproduction rate part of your behavior weights, or is it hardcoded after getting a certain amount of food? I think it makes sense for it to be the former. Also, one thing you can seek to emulate from real ecosystems is that total biomass stays approximately constant in an environment: you have it set up so that plants input biomass into the system and energy use outputs biomass from the system, and the whole sim is just waiting for the flow from one to the other to stabilize, which it always will because entropy. You instead need to connect the ends together somehow so that biomass is fed into the beginning of the system from the end.
Makes me wonder about adding multiple predator/prey sizes. Small predators can only eat small prey, larger predators can eat larger prey and small predators.
Also, what are the pros and cons of using raycast for vision instead of simply feeding them the info of the nearest X number of each object type, eliminating anything outside of what you would set as their FOV?
Have you thought about introducing an environmental oscillation in the system? Like seasons, where there is a periodical fluctuation of food availability independent of the population
How do they reproduce? On a timer? Just when ever they eat enough?
An interesting thing you could add is how much they reproduce is a mutatable stat.
Prey could go for a rat/rabbit strategy of have as many offspring as possible, or invest in a few high quality children.
You'd think a 'do not reproduce' mutation would be a fast extinction, but if it can be a recessive gene where the parent still can have children then you have a bee/ant hive. But you'd need cooperation for that to have any utility.
@PezzzasWork -- I suggest relaxing those rigid roles somewhat, so that there is at least some potential for mutations to allow trade-offs such as predators or pray that can get some nourishment out of plants and also some nourishment out of prey, or perhaps plants that can move, but need to eat food to sustain their ability to do so you might also consider allowing some to evolve egg-laying, what's different amounts of time until the egg hatches, and have the eggs not be a food source for anything by default, but allow the possibility of evolving the ability to use eggs as a food source. Considering eggs as a life stage, you could possibly also allow some to evolve other life stages. Remember, Earth life isn't the only thing that involves. In fact life isn't the only thing that involves. Practically everything does. Look at the evolution of languages, societies, skills, landscapes, ecosystems, technology, and so on, and you should find plenty of inspiration.
I love this series!
Normally there are different trophic levels
I tried doing one of my own of these. I have a hard time maintaining a stable ecosystem, eventually the predators or prey die out. Reproduction is not asexual so I wonder how much that has to do with it.
I feel like adding plants didn't really solve the issue of the population being artificially limited but instead abstracts it out to the replenishment rate of plants
what happened we nns of creatores? what was most complex nn? how they changed amongs populations? what was longest lifetime and so on
The programming/optimization side of this project has been fun and impressive to watch, but I think you should spend some more time looking at real world ecosystems/ecology for inspiration.
1:00 the old good 4-neighbourhood
itd be cool if you could introduce continents and animals which are specialized to each environment
This is amazing! Are you doing this in UE? Or is this custom software?
In order to balance it out... believe it or not... predators will have to fight amongst themselves.
Adding apex predator’s would also help stop all the prey from being eaten
Another banger of a video. Very cool.
Thank you fellow chicken 🐔 !