Log In  
[ :: Read More :: ]

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)

[ :: Read More :: ]

Hi all! Hobby programmer trying out PICO-8 for the first time. Get ready for some hot* lithosphere-on-aesthenosphere action!

I decided to port an old project of mine, a cellular-automaton-based tectonics simulator. It's based on the algorithm used in the 1990 Maxis software toy SimEarth, but has slowly departed from that.

Press Z to toggle map/globe. Press X to start/stop spinning. Left and right change map views to see what the magma is up to underneath, and down pauses the simulation.

Cart #tectonics-0 | 2021-03-19 | Code ▽ | Embed ▽ | No License

Not sure if I'll do any more polishing on this or not, but I'm happy to implement optimizations if there are any that seem obvious to the initiated. I'm especially annoyed by the laggy controls -- any tips on how I should best fetch button state in a slow-running program like this?

The code is messy, in part because I'm new to PICO-8 and Lua, in part because I ported it from a very different language, and in part because I don't mind being a little sloppy! Let me know if I can clear anything up for you.

Thanks for checking it out, and I hope you enjoy.

*1000°+ C

P#89200 2021-03-19 03:14 ( Edited 2021-03-19 03:23)