Ant Colony Simulator (not really a game)

Here’s the link, check it out if you feel like it: http://code.kevinworkman.com/Ants/

As a final project in my AI class, I developed a program that hopefully introduces non-programmers to the artificial intelligence principle of emergence in ant colony optimization.

Basically, the program models how real-life ants cooperate to find food. Even though each individual ant is pretty dumb, the colony as a whole shows intelligent behavior. Through pheromones and some very simple rules, ants work together to respond to dynamic environments (which you can change on the fly).

http://code.KevinWorkman.com/Ants/spiral.png

The program’s source is available, and it might serve as a base for another programmer to implement something more game-like. This could be the beginnings of a tower defense game, or just a better version of the open environment I’ve started here.

I’m submitting this later today, so any feedback on stuff that isn’t obvious is appreciated. Also, if anybody using a mac could do a quick “this works”, I’d appreciate it. My professor uses a mac, but I don’t have one to test on.

I’ve also posted this here and here.

Can we see an applet? :slight_smile: Nevermind, found it on the right.

I’ve been trying to figure out a clean, obvious way to indicate that a user on my site should click one of those options to run the programs. Really obvious things are usually ugly, and really nice-looking things are hard to notice. Putting them on the right is the best I could come up with, but I’m very open to suggestions!

My first thought was “Meh.” but after watching it for a few minutes, I realized how awesome it is. I’ve always been fascinated by games that play themselves. Why not evolve it a little to make the food resources limited, allow ants to reproduce into more of themselves and add random map generation? You could even make different ant factions that can fight against each others and make the ants leave pheromone trails of danger, e.t.c. You also need better graphics. >_> It’s very hard to see the flow of the “game” when the ants teleport between tiles. A smooth movement from tile A to tile B would make a huge difference!

Wasn’t too hard to find. I really like the “require all” trick for finding a hamilton circuit.

While they do converge on a path eventually, I do find that that individual ants still tend to move a little more erratically than other ant simulators I’ve seen. Before weighting for trails, do you have them moving in a completely random direction each turn, or do you have them favor moving forward?

Thanks! The original purpose of this was not to be a game, but to serve as a final project for school, so I shied away from / didn’t have time for game-type stuff. Same excuse for graphics and smoother animations. :slight_smile:

However, one of my goals was to build up a code base that I or somebody else could build on to implement something like a game, or to go the opposite direction and implement a more scientific version of this. I went for the middle ground so that it was usable for as many people as possible. I actually seriously consider the fact that you stayed interested for a couple minutes and then thought “now what if this was added…” a great success.

The “require all” option was initially a stab at modelling the traveling salesperson problem. It’s not strict in that it doesn’t enforce the rule that ants can’t travel through the same food twice, but I think they come up with some interesting solutions. They also come up with some ridiculous solutions, but that’s part of the fun, right?

And yeah, good observation on the ants’ movement. They move completely randomly until they find a pheromone, at which point they either weigh them or choose the best option (depending on the trail strength). I considered having them prefer forward movement (or even making their direction preference be an adjustable parameter), but I decided against it.

Wow I almost did not see the time fly by! I kept playing around with it and making many different paths :stuck_out_tongue:
Great job!

One of the ultimate games I want to create is an MMORPG game where all content is generated and controlled by an AI similar to this. Think about it; a game where towns and cities are naturally formed around places with lots of people and travelers; a game where towns need resources to survive and can actually disappear if they are destroyed or they become too unpopular, e.t.c. Players take the role of a single person in this world, and can do whatever they want to try to become successful, or ruin other peoples work. I tried to experiment with a very simple AI for a small community which built houses for people to live in, gathered wood for house construction and gathered food for keeping the population alive. I had a very hard time getting it balanced. It always massed a single resource too much or built too many houses, and then I realized it was because they were communists! I realized the problem was that a central AI controlled how many people to assign to resource gathering and how many houses to build, and it’s very hard for “the state” to determine optimal numbers for this! A swarm approach (AKA ant colonies) is MUCH more effective at adapting to changes and other stuff than a supermind overviewing everything, because it is simply put to difficult to determine an optimal strategy. Let the drones do the work and it should be able to adapt to anything in a much more realistic and simple way!

Gah! You’re distracting me with insanely interesting ideas!!! T___T

Very nice idea
both of you ;D

Thank you! Anything that wastes other people’s time is a great success, haha.

Wow, that definitely sounds fascinating. I’d love to hear more about it if you get something workable going.

Eve.

Never played it. I’m a cheapskate.

This is probably where Dwarf Fortress’s Adventure Mode is heading in, oh, another 20 years. I only ever play Fortress Mode myself, and it also has some pretty interesting emergent behaviors, though not a lot of direct interaction between dwarfs except when they’re killing each other…

Nice simulator, great job! Tried several maze construction strategies… :slight_smile: And yes, they’re still searching for food :slight_smile:

And it’s little bit like Majesty (at least older one). You can stimulate heroes by money (not always), and you never know, will reach your mage level 7 or not :slight_smile:

Thanks! If you feel like it, you might try playing with the simulation parameters to encourage them to solve a maze. Something like setting the max pheromone slider to a high value and the dropoff and evaporation sliders really low might help them solve it better.