davidrmiller / biosim4

Biological evolution simulator
Other
3.1k stars 435 forks source link

Energy cost system (updated) #66

Open apatho opened 2 years ago

apatho commented 2 years ago

Added a system that enables assigning an energy cost to performed actions, neural net nodes, and connections, which are then deducted from a starting energy pool. Individuals that run out of energy die. This enables adding various interesting evolutionary pressures, such as tradeoff between "brain size" and movement, or between "violent" and "pacifist" approaches.

Cost of actions is divided into three categories: movement actions, kill action, and others. Could be extended to more categories, or even separate setting for each action, but that seemed excessive.

I also included some reporting around neural net size and energy consumption, to enable graphing changes in "brain size". These parts could be easily left out of the PR if they are not a good fit for upstream.

Further ideas that can be built on top of this:

energy sensory neuron so that decisions can be made based on available energy some kind of energy source (food) - would enable simulations where agents are competing for resources (other than space)

Note: this is an update of my original PR, I rebased the branch and deleted the old one, which is why the PR was closed. Sorry for the confusion. Compared to the original PR, indivs that run out of energy die - turns out this is a more useful behavior when building further functionality on top of this. It also makes the implementation a bit simpler.

davidrmiller commented 2 years ago

Interesting changes, thanks for the thought you put into this.

CrazyVoid commented 5 months ago

I had an thought about something like this, but also adding an food element into the world.

Like for an example, gen 0 could start with 100 energy. do all their actions survive etc.

but if they find food, have some type of reward where they replenish an amount of energy. i feel like this would encourage the development of more connections as the creatures will have more energy to do stuff.

But we would need to code genes to be able to detect food. etc

davidrmiller commented 5 months ago

Hi @CrazyVoid, thanks for the comment, and thanks again to @apatho for submitting code for an energy cost system. (I apologize, @apatho, for sitting on this PR for so long.) Agreed, it would be interesting to experiment with such a system.

I didn't include a food or energy model in the original program because I thought it might be a distraction from the basic principle of "whatever reproduces, reproduces." I was concerned that some viewers of the video might infer that natural selection is somehow related specifically to food or energy, whereas I wanted to show that it's more general than that. Same reason I didn't model weather/exposure, injury/healing, etc.

Rather than incorporating this PR into this repository, I would prefer to see this implemented in a fork where it can be maintained with the attention it deserves, so I will refer interested parties to apatho's branch at https://github.com/apatho/biosim4/tree/energy-cost-updated. If you are aware of other forks with a food or energy model, let us know here.

CrazyVoid commented 5 months ago

I perfectly understand, when i seen the video, my mind obv raced with the possiblities as an coder my self.

I'll look at that branch, but i did want to say thanks for the work you did do, its very well written and clean!

apatho commented 5 months ago

No worries @davidrmiller , it makes sense to keep this repo 1:1 with the video. Feel free to close this PR.

@CrazyVoid there's some rudimentary work on a food system in the https://github.com/apatho/biosim4/tree/work branch in my fork, but it is a very rough work in progress. There's a signal layer for food and I hardcoded the peeps' signal detectors to use that layer IIRC. I encountered an issue that the presence of food didn't really translate well to movement towards the food for some reason, and then I lost interest a bit. But feel free to build on it. Just be aware that that branch is not really cleaned up as it contains work in progress code.