Log In  

Hungry Bobs

A Lil Evolution Sim

Cart #hungrybobs-0 | 2021-09-16 | Code ▽ | Embed ▽ | No License

This little ecosystem is composed of a population of colorful B(l)obs, and their food source, the green Al(gae)s. Unlike environments on Earth, where energy is constantly being lost as heat and gained from sunlight or chemical or geological activity, the Bobs and Als form a quasi-closed* system. New Als will only grow if there is enough free energy available, energy which must have been lost by Bobs going about their daily metabolic business.

Although the Als are happy to just appear and disappear when the simulation says so, the Bobs are somewhat more complex critters:

  • Bobs move around the toroidal petri dish at a constant speed
  • When hungry or curious, Bobs will change direction and swim off somewhere else
  • When a Bob approaches an Al close enough, it will eat the Al and gain its energy
  • When a Bob has enough energy, it will bud a new baby Bob and pass on its genome

Over time, tiny mutations in the Bobs' genes will cause changes in their behavior and in the ecosystem as a whole. You may observe arbitrary changes getting passed around over time -- genetic drift -- or you may see the Bobs adapt to their changing environment -- evolution by natural selection!

The Bob Genome

The Bobs are constantly competing for scarce resources! Little tweaks in their genome may make the difference between a happy Bob and a dead one. Here are the genes they pass on when they reproduce:


Each Bob has a color, which does not impact its behavior at all. It's just handy to be able to see at a glance which Bobs are (probably) related to each other. You may see one color come to dominate, especially after population bottlenecks, but mutations will slowly introduce new colors.

Hunger Threshold

When a Bob's energy drops beneath this threshold, they'll start looking for the nearest Al. If it's too high, they'll waste energy changing direction to get food they don't need; too low, and it might be too late!

Birth Threshold

When a Bob has energy above (Birth threshold) + (Birth energy), they'll split off a baby Bob in a random direction.

Birth Energy

Bobs transfer this much energy to their baby Bob if they reproduce. One evolutionary strategy might be to reproduce often and let the little buggers fend for themselves (low BE). Another might be to reproduce rarely, but invest a lot of energy in the offspring (high BE). The birth threshold determines how much energy they keep for themselves in these scenarios, offering new strategic possibilities.


Every tick, each Bob has a small chance of wiggling in a random direction. The probability of this happening is that Bob's "curiosity." Curious Bobs might find new food sources this way, but depending on the environment, they might also waste energy changing their direction.


Alas, Bobs only have one gear. They are born at one speed and die at that speed. Fast Bobs might get to nibble that Al first, but there's a cost: the faster you move, the more energy you use. Observe the graph of mean speed over time -- in many populations this, will rise and fall; what environmental pressures might cause this?

In addition to costs for moving and changing direction, Bobs suffer a small constant energy cost every turn. Such is the cost of metabolizing.

Simulator Parameters

I spent some time trying to find parameters that balance the sim between a few factors, to make it fun and interesting to watch:

  • Enough hardship that the Bobs face selective pressure, but not so much that they always go extinct
  • Enough variety in the initial genome
  • The right amount of energy available: we want keep a sizeable population of Bobs alive, but not so many as to make the PICO-8 buckle under the weight of my underoptimized code. It gets bad around 30 Bobs, and the most successful populations will definitely exceed that, so watch out!
  • The right combination of parameters to make the evolution of interesting strategies visible.

You're encourages to tweak the parameters in the code and find new environments for the Bobs and Als! Experiment with the balance a little and see what you can do. Post your findings on the BBS. Good places to start:

  • food_energy (how much energy is in an Al)
  • doom_energy (constant metabolic costs)
  • move_energy (energy lost to friction)
  • bob_energy_init (the Bobs' "head start," which can encourage genetic diversity)

*Organisms can actually borrow from the energy budget for a little while to make computation easier, but if I checked the code right, it should even out in the long run.

P#89610 2021-09-16 22:34 ( Edited 2021-09-16 22:35)


I wrote this little poem in honor of your cart:

hungry bobby

P#99079 2021-10-24 00:23

Fascinating stuff - I love the breakdown of the bob genome in your description & seeing evolution take place over time using the mean charts. Incredible work!

I was planning to model a DNA system in my pond sim & similarly look forward to seeing changes over time as predator and prey evolve in competition with each other. Many years ago, I modeled this DNA system into a mouse-colony simulator and after dozens of thousands of ticks, you could observe the average lifespan of the colony increase as the mice became better suited to their environment. It blew my mind!

My DNA model for sexual reproduction was dead-simple:

  1. Store a list of parameters in a DNA object.
  2. Upon birth - foreach parameter of the child's DNA, assign it one of the following:
    • the fathers parameter
    • or the mothers parameter
    • or the average of the father & mothers parameter
    • or a random mutation (can be defined however you see fit)

Assigning probability to each bullet point is advised - but other than that, it's amazing how simple the rules to (digital) evolution are...

Anyways, your work here is inspiring & I look forward to digging in to tweak some bob params in the future :D

P#99081 2021-10-24 05:35

my world is being taken over by white bobs... now red

P#101880 2021-12-07 16:08

very cool ;)

P#101950 2021-12-07 19:15

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2023-06-10 15:03:50 | 0.012s | Q:23