Dbmaj7 [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=52626 Hungry Bobs <h1>Hungry Bobs</h1> <h2>A Lil Evolution Sim</h2> <p> <table><tr><td> <a href="/bbs/?pid=89610#p"> <img src="/bbs/thumbs/pico8_hungrybobs-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=89610#p"> hungrybobs</a><br><br> by <a href="/bbs/?uid=52626"> Dbmaj7</a> <br><br><br> <a href="/bbs/?pid=89610#p"> [Click to Play]</a> </td></tr></table> </p> <p>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.</p> <p>Although the Als are happy to just appear and disappear when the simulation says so, the Bobs are somewhat more complex critters:</p> <ul> <li>Bobs move around the toroidal petri dish at a constant speed</li> <li>When hungry or curious, Bobs will change direction and swim off somewhere else</li> <li>When a Bob approaches an Al close enough, it will eat the Al and gain its energy</li> <li>When a Bob has enough energy, it will bud a new baby Bob and pass on its genome</li> </ul> <p>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!</p> <h2>The Bob Genome</h2> <p>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:</p> <h3>Color</h3> <p>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.</p> <h3>Hunger Threshold</h3> <p>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!</p> <h3>Birth Threshold</h3> <p>When a Bob has energy above (Birth threshold) + (Birth energy), they'll split off a baby Bob in a random direction.</p> <h3>Birth Energy</h3> <p>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.</p> <h3>Curiosity</h3> <p>Every tick, each Bob has a small chance of wiggling in a random direction. The probability of this happening is that Bob's &quot;curiosity.&quot; Curious Bobs might find new food sources this way, but depending on the environment, they might also waste energy changing their direction.</p> <h3>Speed</h3> <p>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?</p> <p>In addition to costs for moving and changing direction, Bobs suffer a small constant energy cost every turn. Such is the cost of metabolizing.</p> <h2>Simulator Parameters</h2> <p>I spent some time trying to find parameters that balance the sim between a few factors, to make it fun and interesting to watch:</p> <ul> <li>Enough hardship that the Bobs face selective pressure, but not so much that they always go extinct</li> <li>Enough variety in the initial genome</li> <li>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!</li> <li>The right <em>combination</em> of parameters to make the evolution of interesting strategies visible.</li> </ul> <p>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:</p> <ul> <li>food_energy (how much energy is in an Al)</li> <li>doom_energy (constant metabolic costs)</li> <li>move_energy (energy lost to friction)</li> <li>bob_energy_init (the Bobs' &quot;head start,&quot; which can encourage genetic diversity)</li> </ul> <p>*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> https://www.lexaloffle.com/bbs/?tid=42182 https://www.lexaloffle.com/bbs/?tid=42182 Thu, 16 Sep 2021 22:34:49 UTC Tectonics Simulator <p>Hi all! Hobby programmer trying out PICO-8 for the first time. Get ready for some hot* lithosphere-on-aesthenosphere action!</p> <p>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 <a href="https://en.wikipedia.org/wiki/SimEarth">SimEarth</a>, but has slowly departed from that.</p> <p>Press <strong>Z</strong> to toggle map/globe. Press <strong>X</strong> to start/stop spinning. <strong>Left</strong> and <strong>right</strong> change map views to see what the magma is up to underneath, and <strong>down</strong> pauses the simulation. </p> <p> <table><tr><td> <a href="/bbs/?pid=89200#p"> <img src="/bbs/thumbs/pico8_tectonics-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=89200#p"> tectonics</a><br><br> by <a href="/bbs/?uid=52626"> Dbmaj7</a> <br><br><br> <a href="/bbs/?pid=89200#p"> [Click to Play]</a> </td></tr></table> </p> <p>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?</p> <p>The code is messy, in part because I'm new to PICO-8 and Lua, in part because I ported it from a <em>very</em> 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.</p> <p>Thanks for checking it out, and I hope you enjoy.</p> <p>*1000&deg;+ C</p> https://www.lexaloffle.com/bbs/?tid=42072 https://www.lexaloffle.com/bbs/?tid=42072 Fri, 19 Mar 2021 03:14:34 UTC