Focus Battle Resolution

The battle resolution can be stated 2 different ways:

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


An ant will kill an enemy ant if

an enemy in range

is surrounded by more (or the same) enemies than its target

If you don't understand either of those, don't worry, that's what the rest of this page is for.

The Intuitive Physical World Explanation

An ant is a very simple creature. In fact it will only take two actions on its own without an external command.

The first is to create another ant from food that is close enough to it. This action is of course quite complex for the ant, taking much fine and detailed work (which is why the food must be very close). The results though are quite simple; if the food is close enough it is turned into another ant of the same color. The only exception is when ants of differing colors manage to get close enough at the same time; the food is destroyed when both of them try and work with it.

The second action an ant will take is to fight with enemy ants. This is a much simpler action than "spawning" so can be carried out at a greater distance (although the details aren't completely known it involves much flailing of legs). The results can be a little more complex to understand than the "spawning" action.

The simplest case is when two lone ants of differing colors get close enough to each other and therefore must engage in combat. They will both focus solely on the other opposing ant. Being evenly matched in focus, both end up killing the other.

When a lone ant meets two opposing ants at the same time, it splits its focus between both enemies. They, of course, can concentrate on it completely. This means the lone ant, being more distracted, dies and the other two survive. So you can see for an ant to survive the opponents it is facing it must have more focus than they do. If any opponent is equally or less occupied the ant will die.

Ants do not distinguish between enemy colors. If ants of three different colors, say green, red and blue, came together so they could all reach each other, then each ant would have its attention split two ways and all three would die. But if a green ant has a red ant on one side and a blue ant on the other, where the red and blue ant can not reach each other, then the green ant would die because its attention is split while both the red and blue ants would focus solely on it.

Hopefully this helps you understand how ant fights work. In order for you to double check your understanding here is a slightly more complex example for you to work out the result:

There are two blue ants, Bob and Bill, and two red ants, Roy and Ralph wandering around. After moving, Bill has stepped close enough to fight with both red ants while Bob only moved close enough to fight with Roy. The question for you is which ants die and which survive?

No peeking at the answer below until you have come up with your own.

Bob  -> B..
Bill -> B.R <- Roy
        ..R <- Ralph

You got an answer already? Don't keep going without one.

The situation above is that the blue ant Bill and the red ant Roy have their attention split between two opponents. Bob and Ralph are able to concentrate on just one opponent, who happens to have his attention split. So Bill and Roy die while Bob and Ralph survive to fight another day.

Pretty easy right? Of course it is. Every fight works the same way, if an ant has its focus split up among less enemies than any of those enemy ants focus is split, it survives. Now you're ready to dive into the rest of this document that gives a little more technical explanation and several examples.

More Technical Description

Each ant may have some enemy ants in range. It is considered to be "occupied" with the task fighting those ants. Each ant may have a different number of enemies it is "occupied" by. Ants that are occupied by less enemies are considered to be more focused on their task of killing those enemies than an ants that is occupied by more enemies. Ants that are equally occupied are able to kill each other.

  • ant A is in range of ant B
  • ant A is occupied (or fighting) 2 enemies
  • ant B is occupied (or fighting) 4 enemies
  • ant B has more on his mind, is more distracted and less effective than ant A
  • ant A can therefore kill ant B
  • other stuff happens with the C ants, but we are just focusing on A and B
    • C would kill both A and B even if A and B were not next to each other

Each ant may have more than one ant that it can kill and it may also have more than one ant that it can be killed by. An ant may both kill another ant, and be killed in the same turn.

To try and calculate it by hand, just write the number of enemy ants surrounding each ant:

1 2 4 1

Then, if there is any ant is next to an enemy with an equal or lesser number, it will die:



These all assume attackradius2 = 5, which is the following shape (with some radii calculated for you):

.......    ...9...    .85458.
.xxxxx.    .52125.
.xxAxx.    9410149
.xxxxx.    .52125.    .85458.
.......    ...9...


  • Both ants die

    .....    .....    .....
    .A.B. -> .1.1. -> .x.x.
    .....    .....    .....


  • A dies

    ...B.    ...1.    ...B.
    .A... -> .2... -> .x...
    ...B.    ...1.    ...B.


  • All die

    ...B.    ...2.    ...x.
    .A... -> .2... -> .x...
    ...C.    ...2.    ...x.

Ant Sandwich

  • The B ant in the center dies
  • A and C both live

    .....    .....    .....
    A.B.C -> 1.2.1 -> A.x.C
    .....    .....    .....


  • B and C die

    ...B.    ...3.    ...x.
    .A.A. -> .2.2. -> .A.A.
    ...C.    ...3.    ...x.

Wall Punch

  • Many die

    AAAAAAAAA    013565310    AAxxxxxAA
    ...BBB... -> ...555... ->
    ...BBB...    ...333...    ...xBx...
  • The B ant lives because it is only attacked by the 3 center A ants, and each of those ants are more occupied. In turn, it participates in the death of the 3 center A ants.

    ???AAA???    ???565???    AAxxxxxAA
    ...???... -> ...???... ->
    ...?B?...    ...?3?...    ...xBx...
  • The A ants on the end live because they are only attacked by 1 B ant which is much more occupied.

    ?A???????    ?1???????    AAxxxxxAA
    ...B??... -> ...5??... ->
    ...???...    ...???...    ...xBx...

Bob & Bill vs. Roy & Ralph:

  • The top and bottom ants are not within range of each other
  • 1 of each dies

    ..B....    ..1....    ..B....
    ..B.R.. -> ..2.2.. -> ..x.x..
    ....R..    ....1..    ....R..


For an ant location x, define enemiesx as the set of enemy ants within the attack radius of x.

For an ant location a, a lives if enemiesaenemiesbforallbinenemiesa.

Similarly, for an ant location a, a dies if existsbinenemiesaenemiesageqenemiesb.


    // how to check if an ant dies
    for every ant:
        for each enemy in range of ant (using attackradius2):
            if (enemies(of ant) in range of ant) >= (enemies(of enemy) in range of enemy) then
                the ant is marked dead (actual removal is done after all battles are resolved)
                break out of enemy loop

        # we pre-calculate the number of enemies around each ant to make it faster

        # maps ants to nearby enemies
        nearby_enemies = {}
        for ant in self.current_ants.values():
            nearby_enemies[ant] = self.nearby_ants(ant.loc, self.attackradius, ant.owner)

        # determine which ants to kill
        ants_to_kill = []
        for ant in self.current_ants.values():
            # determine this ants weakness (1/power)
            weakness = len(nearby_enemies[ant])
            # an ant with no enemies nearby can't be attacked
            if weakness == 0:
            # determine the most powerful nearby enemy
            min_enemy_weakness = min(len(nearby_enemies[enemy]) for enemy in nearby_enemies[ant])
            # ant dies if it is weak as or weaker than an enemy weakness
            if min_enemy_weakness <= weakness: