A visually interesting resource simulation

edited October 2015 in Share Your Work

I'm a big fan of random walkers, colors, and working with probabilities. Check out some of the images below. You can find the code on GitHub @ https://github.com/asmith33/ResourcesSim

Agents being loaded.. Start-Gray

The simulation starts by adding 'agents.' These agents collect energy from the map and store that energy as their own. There are three kinds of energy on the map. These energies are provided by three different colored regions. Each agent has a limited ability to harvest a particular resource. Agents are always losing energy due to movement, and will eventually die. The longer they live, the more chances they have to reproduce. Every time they reproduce, they have a chance of mutating. If their attributes mutate during reproduction, their child will have become slightly better at harvesting one color of resource, and slightly worse at harvesting another.

Resource areas.. Resources

Grid (stores energy). Notice the dark spots in the center. Those are bins who's energies are being used/eaten/removed by agents. I took this picture near the beginning of a simulation, so the agents are still all in the center. Grid

As the agents develop specialties, they begin to dominate regions.. Mid-NoPred

There is also an area for parameter adjustments, press 'w' to open the window. These adjustments take a bit of time to work into the simulation because you are actually changing the parameters of new agents, so, the current agents must reproduce before you begin to see the changes. Also, this area highlights the key mappings. Window

And predators.. Predators gain energy by harvesting agents. They have limited intelligence -- they choose which bin to move to based on population densities of the bins immediately adjacent to their current position. In their current form, they hunt based on energy levels. They are more successful at hunting agents with low energies.

predators shown with agents predators-with-agents

and a few moments later after they have cleaned out the center.. predators-with-agents1

and predators shown without agents predators-alone

Well, that's about it. There are several ways to watch the simulations. I generally only show agents and predators. But, watching the grid is pretty revealing of the story as well.

I've had quite a lot of fun working on/watching this simulation over the last couple of weeks.

If you see an obvious (or not obvious) optimization, let me know! The more dots the better, in my opinion.

One last image.. the simulations 'steady-state' solution (with predators). steady-state

Sign In or Register to comment.