Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combat strategy for ants

This question refers to the Google-sponsored AI Challenge, a contest that happens every few months and in which the contenders need to submit a bot able to autonomously play a game against other robotic players. The competition that just closed was called "ants" and you can read all its specification here, if you are interested.

My question is specific to one aspect of ants: combat strategy.

The problem

Given a grid of discrete coordinates [like a chessboard] and given that each player has a number of ants that at each turn can either:

  1. stay still
  2. move east / north / west / south,

...an ant will be killed by an enemy ant if an enemy ant in range is surrounded by less (or the same) of its own enemies than the ant [equivalent to: "An ant will kill an enemy ant if an enemy in range is surrounded by more (or the same) enemies than its target"]

A visual example:

enter image description here

In this case the yellow ants are going to move west, and the orange ant, not being able to move away [blue tiles are blocking] will have two yellow ants "in range" and will die (if the explanation is still not clear, I invite you to visit the link above to see more examples and explained scenarios).

The question

My question is substantially about complexity. I thought to this problem extensively, but I still couldn't come up with an acceptable way to calculate the optimal set of moves in a reasonable time. It seems to me that for finding the best possible set of moves for my ants, I should evaluate the outcome for every possible scenario, but since battles can be pretty crowded with ants, this would mean that computation time would grow exponentially (5^n, with n being the number of ants involved).

Another limitation of this approach is that the solution being worked on doesn't improve its effectiveness proportionally to the time spent computing, so arbitrarily interrupting its execution might leave you with a non-acceptable solution.

I suspect that a good solution might be found via some geometrical considerations in combination with linear algebra, (maybe calculating some "centres of gravity" for groups of ants?) but I could not pass the level of "intuition" on this...

So, my question really boils down to:

How should this problem be approached to find [nearly] optimal solutions in a computation time of ~50-100 ms on a modern machine (this figure is derived by the official contest rules)?

If you are interested by the problem and need some inspiration, I highly recommend to watch some of the available game replays.

like image 599
mac Avatar asked Dec 20 '11 11:12

mac


People also ask

Does combat work for ants?

Combat Ant Killing Baits are formulated with a powerful insecticide that will kill the queen and exterminate the entire colony of ants. These easy-to-use, child-resistant, no-mess baits need no activation. Simply place them where you see ants and Combat will protect your home from ants for up to three months.

How do you outsmart ants?

Use Combat® baits and gels to build your arsenal in the war against ants. Unlike sprays that kill the pests you see, Combat® ant killing baits and gels kill ants at the source and prevent them from coming back. Ants take the bait back to the colony, where it's shared, destroying the colony and the queen.

How do ants fight wars?

If you look at Ants as societies, there are two ways that they can engage in what we call “Wars”. One of them is more similar to the way that humans think of having wars – battles among the colonies of the same species. The other type involves interactions between different species of ants.


2 Answers

I think your problem can be solved by turning the problem around. Instead of calculating the best moves - per ant - you could caclulate the best move candidates per discrete position on your playing board.

  • +1 for a save place
  • +2 for a place that results in an enemy dying
  • -1 point for a position of certain death

That would scale in a linear way - but have some trade off in not providing best individual movement.

Maybe worth a try :)

like image 68
light_303 Avatar answered Oct 13 '22 01:10

light_303


Tricky indeed. You may find some hints in Bee algorithms. This is a set of algorithms to use swarm cooperation and 'reasonable computation time'. Bee algorithms can for instance be used to roughly (!) solve the traveling salesman problem. I expect that these algorithms can provide you with the best solution given computing time.

Of course, the problem can be simplified using geometry: relative positions of ants in a neighbourhood are more important than absolute positions. And also light_303's solution is complementatry to the search pattern I propose.

like image 32
Adriaan Avatar answered Oct 12 '22 23:10

Adriaan