colececil [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=124079 Ant &amp; Mouse House <p> <table><tr><td> <a href="/bbs/?pid=175915#p"> <img src="/bbs/thumbs/pico8_ant_n_mouse_house-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=175915#p"> Ant n' Mouse House</a><br><br> by <a href="/bbs/?uid=124079"> colececil</a> <br><br><br> <a href="/bbs/?pid=175915#p"> [Click to Play]</a> </td></tr></table> </p> <p><strong>An ant simulator on PICO-8.</strong></p> <p><em>(This project is dedicated to the memory of all the fearless ants who lost their lives upon invading my home. May they rest in peace.</em> 🥀<em>)</em></p> <h2>Background</h2> <p>I created this project with the goal of simulating the way real-life ants find and gather food. It's fascinating that while individual ants have limited intelligence and simple behavior, they're extremely proficient at solving problems and adapting to changing conditions when acting as a group.</p> <p>This all came about when I had some ants invading my house in May 2025, which simultaneously triggered both frustration and fascination as I tried to figure out how they kept getting in, even as I plugged up various tiny crevices they were entering through. I don't like killing things, but I eventually had to resort to using poison bait traps to keep them out of my home. While the fascination sparked by that experience is what inspired this project, I've come to feel it's also given me a way to honor the ants as living beings that I share the planet with (despite the killing). Maybe that's silly, but I think it's important to have a certain level of reverence for all life, and to contemplate the ways in which we're all interconnected.</p> <h2>Gameplay</h2> <p>Calling this a &quot;game&quot; may be a little bit of a stretch, as there isn't really a goal, other than learning about ant behavior and being entertained by watching what they do. But I've found it to be quite enjoyable, and I hope you do as well!</p> <p>There are two different modes to choose from:</p> <ul> <li><strong>Active:</strong> Walk around the room as a mouse (the rodent type, not the computer type) and nibble on cheese, dropping crumbs on the floor for the ants to gather. This mode lets you choose where and when to drop crumbs, allowing you to experiment with how the ants react to different situations.</li> <li><strong>Passive:</strong> The mouse is controlled automatically and drops crumbs in random locations throughout the room. This mode is great to have just running in the background while you're doing something else, to give you a little bit of extra entertainment.</li> </ul> <p>In both modes, you can toggle between a regular view and a &quot;blacklight&quot; view. The blacklight view lets you see the otherwise invisible pheromone trails the ants are creating and following.</p> <h2>Controls</h2> <p><strong>In menus:</strong></p> <ul> <li><strong>Up/Down:</strong> Navigate between menu items.</li> <li><strong>X (on PICO-8 controller) / X (on keyboard)</strong>: Select / proceed.</li> </ul> <p><strong>In both game modes:</strong></p> <ul> <li><strong>O (on PICO-8 controller) / Z (on keyboard):</strong> Toggle the blacklight (to see pheromone trails).</li> <li><strong>- (on PICO-8 controller) / Enter (on keyboard):</strong> Bring up the pause menu. (If you want to mute the game, you can do so from here.)</li> </ul> <p><strong>In Active mode only:</strong></p> <ul> <li><strong>Up/Down/Left/Right:</strong> Move the mouse around the room.</li> <li><strong>X (on PICO-8 controller) / X (on keyboard):</strong> Make the mouse nibble on cheese (to drop crumbs on the floor).</li> </ul> <h2>Explanation of Ant Behavior</h2> <p><em>(<strong>Disclaimer:</strong> The information below describes how the ants behave in this specific simulation, and not necessarily how they behave in real life. While I've tried my best to make it as realistic as possible based on my research and observations, I don't claim to be an expert on ant behavior. The ant behavior in this simulation is most certainly a simplification of real ant behavior, and it could also potentially deviate from real ant behavior in key ways.)</em></p> <p><strong>When an ant is searching for food:</strong></p> <ul> <li>If it doesn't currently detect any pheromones, it will perform a &quot;random walk&quot;. This entails choosing a random direction (constrained within a predefined angle from the direction it's facing), walking that direction for a predefined period of time, then choosing another random direction, and so on.</li> <li>If it detects pheromones within its area of perception (which is constrained within a predefined angle from the direction it's facing, and within a predefined distance from the ant), it will choose a direction to walk based on the locations and concentrations of pheromones within its area of perception.</li> <li>If it detects multiple pheromone trails within its area of perception, it will randomly choose one of them to follow. It will avoid switching to a different pheromone trail for a predefined period of time after choosing one, unless it no longer detects the original trail.</li> <li>It maintains an ordered list of &quot;waypoints&quot; as it walks, where the first waypoint is the location of the nest. Every time the ant starts following a pheromone trail, loses a pheromone trail, or switches between pheromone trails, it will add that location to the end of its list of waypoints.</li> <li>If it detects a food source (by being within a predefined radius of it), it will head straight toward it, ignoring any pheromones. It will take a piece of food and then start heading back to the nest.</li> <li>If it exceeds a predefined time limit without finding food, it will start heading back to the nest without food.</li> </ul> <p><strong>When an ant is returning to the nest:</strong></p> <ul> <li>If it's carrying food, it will emit pheromones at a constant rate while it walks. The pheromones it emits are specific to the food source it came from, and other ants carrying food from the same source will emit the same type of pheromones. If there are already pheromones of the same type in the ant's current location, their concentration will be increased in that location. Multiple types of pheromones with different concentrations can coexist independently in the same location.</li> <li>If it detects pheromones, it will follow them in a similar manner as when it's searching for food. However, there are some key differences in the case where the ant is returning to the nest: <ul> <li>Its area of perception is centered on the direction toward the nest, instead of being centered on the direction the ant is facing. (I found this helps keep the ant moving toward the nest.)</li> <li>If it's currently following a pheromone trail, it won't switch to a different pheromone trail unless it loses the one it's following.</li> <li>When it first detects pheromones while it's not currently following a pheromone trail, if one of the pheromone trails it detects matches the food source it came from, it will select that one. Otherwise, it will randomly select one.</li> </ul></li> <li>If it doesn't currently detect any pheromones, it will walk toward the last waypoint on its list that's closer to the nest than the ant's current location.</li> </ul> <p><strong>Some notes on pheromones:</strong></p> <ul> <li>They evaporate over time, so if ants aren't continuing to add them to a given trail, that trail will eventually disappear.</li> <li>They evaporate more quickly at higher concentrations, and they evaporate more slowly at lower concentrations.</li> </ul> https://www.lexaloffle.com/bbs/?tid=152217 https://www.lexaloffle.com/bbs/?tid=152217 Mon, 20 Oct 2025 03:23:34 UTC