CodeBusters undocumented rules

Here are a couple of rules that I found through experimentation that I can’t find stated in the rules description:

  • 0 ≤ ghostStamina ≤ 40

  • If a ghost has 0 stamina (released from captivity) then it will not run away from ghostbusters.

The second one, in particular, bit me. I occasionally had busters too close to a ghost, but they wouldn’t move. They were just waiting for that ghost to run away so that it would be in range. It took me a while to figure out what was going on. Once I got it, I jumped up quite a bit in the ranking.

Any other rules you’ve found that you care to share?

  • danBhentschel

I’m trying to understand how ghosts are really moving …

In the rules it is stated that they move when at least one buster is in the 2200 range. But that is not the case. They move the turn after. So you could say they just move at the same time. But no. Because if you bust a ghost, it won’t move for this turn …

And if anybody know how a ghost behave when he must move outside of the map, i’ll be glad to know.

1 Like

I think this is how ghosts behave:

  • Compute the next position according to current position of busters
  • Update busters positions (MOVE orders)
  • Update the position of the ghosts that aren’t busted

For the position of the ghosts:

def moveAwayFromBarycenter(ghost, x, y):
  dx = ghost.x - x
  dy = ghost.y - y
  norm = (dx ** 2 + dy ** 2) ** .5
  if norm > 1e-2:
    dx = dx / norm * 400
    dy = dy / norm * 400
  ghost.x = min(16000, max(0, int(ghost.x + dx)))
  ghost.y = min(9000, max(0, int(ghost.y + dy)))

To add some details about this information, here is what I found:

  • Initial ghostStamina ∈ {3, 15, 40}
  • Ghosts do not run away if a buster stands at the same position (which is what happens after a release). I am not sure this is related to the ghost having 0 stamina, because I noticed a ghost starts moving again as soon as the buster that released it moves too.
1 Like

Oh and ghosts run away when you try to stun someone (not bust)
EDIT: not sure, need to check

1 Like

This is mentioned in the rules :smiley:

STUN followed by a buster’s id will make the buster shoot a bolt of lightning […] Being stunned or attempting to stun will cause a buster to release any ghost he may be carrying.

1 Like

Nothing new here, just a recap of that I’ve read on the forum and chat.

Version 3


A round contains 2 turns, one for each agent, an agent being a player’s AI (also called a team in this particular challenge). Since this game has a turn limit of 400, that means 200 for each agent or 200 rounds (simultaneous turn based games are not the more common variety, hence the awkward terminology).


:gear: Agent 0 elaborates its orders.


:gear: Agent 1 elaborates its orders.


:gear: All players’ orders are resolved simultaneously.

:zero: For each ghost on the map which can be seen by one or more busters, whatever its stamina, assign a MOVE order to flee away from the nearest buster or, if there are more than one at the same distance, from their barycenter (not considering visible busters at a greater distance). In case the nearest buster or the barycenter shares the same position as the ghost, it goes nowhere and stay at the same place.

:one: Resolve BUST orders, taking care of min/max ranges and reducing each ghost stamina by the number of busters trying to catch it this turn, down to zero but not beyond. If a ghost’s stamina reach 0 and if a team has more busters trying to catch it than the other team, remove the ghost from the map to give it to the nearest buster of this team, otherwise leave it at its position (it won’t move this turn, whatever its planned fleeing movement).

:two: Resolve STUN orders, taking care of cooldowns and ranges. If a stunner carry a ghost, the ghost is released at the stunner’s position. Note that the cooldown value is a bit misleading since it defines the number of turns between two stuns for a same buster (per instance, a cooldown of 1 would mean that a stun is possible each turn). In addition, note that it is perfectly valid to stun an already stunned buster: stun effects aren’t cumulative though and the new stun will simply replace the existing one. Lastly, it is also valid for a buster to stun a buster of the same team or even themself.

:three: Resolve MOVE orders for the ghosts not busted this turn and busters still on the map, even if they have been stunned this turn (they keep their momentum before falling stunned at the end of the turn). In case a stunned buster carries a ghost, the ghost is released at the end of the move. When an entity’s position ends outside of the map, its position is simply clamped back to the map. So, for instance, a ghost next to a “wall” won’t move when approached perpendiculary to this wall.


This is definitely not what I was seeing. I replayed the same scenario over and over until I could figure out what was happening, and then I created a unit test that recorded the situation so that I could easily devise a solution:

My buster at (8826, 1221) gets stunned by opponent and drops the ghost he is carrying. I have another buster nearby at (9200, 1500) who stuns the opponent’s buster on the exact same turn. The ghost is visible to both of my busters, and also to the opponent’s buster. Unfortunately, I didn’t record the position of the opponent’s buster, but it was not on the opposite side of the ghost. The three busters formed a triangle.

The ghost, on top of my stunned buster at (8826,1221), did not move for several turns in a row, despite the proximity of three busters, and my buster was too stupid at the time to back away from the ghost to get it. I guess I was a bit hasty in assuming that the stamina of the ghost was significant. I just couldn’t think of any other explanation. Perhaps @Delgan is correct in that ghosts don’t run if there is a buster at the same position? If so, then I need to change my logic. :slight_smile:

  • danBhentschel

I think that ghosts only run from movement?
If all busters are stunned then the ghost stays still. As soon as someone moves in the 2200 circle the ghost will move away from them?

I need to reword my sentence: “In case all the busters the nearest buster(s) share the same position as the ghost, it goes nowhere and stay at the same place.” If there is more than one buster stacked with the ghost, the flee to from barycenter (of the busters at distance zero, not the others) rule gives the same result as the flee from a single nearest buster: both lead to no movement since there is not defined direction to follow.

Okay. I’ll buy that. For illustration:

And I have changed my logic to expect the described behavior.

  • danBhentschel

According to the rules, it should be away from the barycenter, non?

(That said, it seems the situation of equal distance is extremely rare, so of no big importance).

You are right, I’ve corrected my two messages (and my code by the way) to reflect this. Although, as you’ve said, this situation doesn’t happen frequently.