slimemold particle simulation
A downloadable game for Windows
This is a slime mold simulation i have recreated with great inspiration from Sebastian Lagues' video: (https://youtu.be/X-iSQQgOd1A?t=616)
It uses the effect of emergence, in which a small agent follows a simple rules that dictate how the agent interacts with other agents and the environment.
When having multiple agents that all follow the same or similar rule set, complex and intelligent behavior emerges from those simple rules.
A common example of this are ant colonies (as described in the video):
Simplified, when an ant goes out to look for foot, it leaves behind a pheromone trail. when it found food, it takes a bit of it and to find the way back, it follows the pheromone trail it just laid out while leaving behind a new trail of a different pheromone. The first pheromone trail indicates "back to the nest" while the second pheromone trial indicates "food this way"
other ants can now follow the pheromone trail to find food and bring it back home, all while also laying their own version of the pheromone trails that are very similar to the original trail. but through a bit of randomness, slightly different trails emerge where the more efficient ways see more travel thus becoming stronger and other less efficient paths die out over time. Through this technique, over time the ant colony finds a near perfect path from the nest to the foot while the single ant only follows the strongest path it can see without being aware of the bigger structure.
This simulation functions a bit differently then the example with the ants
The Agent:
The agent is defined by 2 unique properties:
- The agents position
- The agents angle
And a number of properties that are the same for every agent:
- the speed at which they travel (pixels per second)
- the speed at which they turn (degrees per second)
- The distance from the position at which they sample [d] (pixels)
- the Angle to either side at which they sample [α] (degrees)
- the number of sampling points per sample [n] (pixels²)
In this simulation, each agent starts by drawing the pixel that corresponds to its position in the agents color (white per default), it then turns its angle based on the results of the sampling and moves in the new direction by its speed.
The way the Agent sees and interacts with the world around it is by sampling at 3 specific points. The first point is the sampling distance away in the direction the agent is looking (its angle) and two other points either side of that Agent by the specified angle.
In the picture, the red pixel is the agent itself, the 3 blue squares are the sampled areas with the light blue pixels being the center pixels. n=1 means that in each direction there is one pixel in each direction. so with n=1, there are 9 pixels per sample area, n=2 are 25, n=3 are 49 etc.
In each sample area there are (2·n-1)² sampled pixels.
The value of each pixel in one sample area gets added together and the three resulting values are compared. The agents changes its angle towards the strongest value (left, right or center) and a bit of random turn is added on top of that.
At the end of each frame frame, all pixels get diffused by blurring the pixels with a simple box-blur (to mimic trail diffusion) and a small value is subtracted from the r, g and b part of the pixel (to mimic trail evaporation)
How to control the simulation:
The webversion of the simulation has limited setup parameters, where only the number of agents can be changed, tho apply those changes, click the reload button when the simulation is running.
The Simulation can be controlled by a number of values, that can all be changed at runtime:
- Agent color: the color that the agent draws to the pixel of its position [rgb-color]
- Move Speed: The speed at which the agents are moving [px/s]
- Turn Speed: The speed at which the agents can turn at max [deg/s]
- Sense Ange: The angle at which the outer sensing areas are [deg]
- Sense Distance: The distance away from the agent the sensing areas are [px]
- Sensor Size: The size of the sensing areas (recommended to not go above 2 for performance reasons [px]
- Evaporation speed: The speed at which the trail evaporates (equivalent to trail color)
Having one value too high may cause the trail to not evaporate properly [rgb-color]
Shortcuts:
- Escape [esc]: Toggle the menu of the simulation
- Space: Start/Pause the simulation
- Hold R for 3 seconds: reset the save file of the simulation (May be needed to create the first save file when the simulation opens in a 1x1 window)
- Mousescroll: Zoom in and out of the simulation (may cause graphic glitches)
- Leftclick + drag: move around in the simulation
- F: toggle follow mode (camera follows around one randomly selected agent in the simulation)
- Left & Right arrow: select different agent for follow mode
Status | Released |
Platforms | Windows |
Author | justAnotherAnotherUser |
Genre | Simulation |
Download
Install instructions
To download and run the simulation, download the Win_Alpha0.2.2.zip file and extract the content to a location of your choosing, you can run the simulation by executing the particle_agent_simulation.exe.
The Simulation should now open. if that is not the case, check whether the simulation opened up in a 1x1 pixel wide window. is that is the case, make sure the simulation is focused and hold R for ca 3 seconds. It should now have created a new savefile with the default settings.
Leave a comment
Log in with itch.io to leave a comment.