CodeBuster - Feedback & Strategy

Eventually I ended up 5th despite being 1st first half of the contest. I think the reason is that I didn’t pay enough attention to the small details and didn’t believe in herding :slight_smile: I spent about 25 hours in total on coding and watching the replays, 10 hours of this 25 were spent during the Saturday – one day before the contest has ended.

Most of the ideas were already mentioned in this topic, so I’ll try to keep this comment short.
0) I coded my exploration algorithm in the first hour after the contest has started and didn’t change it during the whole contest. I consider a grid on the playing area with step = 100. I have a set of “unseen” nodes of this grid which I update every turn. When my buster wants to pick up new target to go to, he selects the closest node from this set, but adding to all distances random number from 0 to 3000. I could not decide what is better: to explore large area with all busters walking alone, or to explore small part of the map with the group of busters in order to defend against opponent and to catch found ghosts faster, so this random change of the distance could lead to either of this scenarios.

  1. I had two modes: “usual” and “careful”. Second one was enabled if I see half or more of opponents’ busters near my base or there is one ghost left for my victory. In the “careful” mode the whole team worked as a support for the buster who was carrying the ghost. If my buster who is carrying a ghost finds himself significantly closer to base than it’s support guys, he waits for them.
  2. I didn’t try to steal ghost by sneaking at the opp base, because I’ve found it boring :slight_smile: But I did try to intercept enemies going to their base assuming they will use straight path, so I could not intercept Khao’s busters that moved along the walls.
  3. I didn’t come to the idea of chain zapping used by Hohol as I am not Dota player :slight_smile: Still, if I need to choose between stuning enemy busters with stun cooldowns equal to 0 and 5, I will choose one with cooldown=5, as buster with zero cooldown will use its stun anyway.
  4. I had absolutely no time to code during last Sunday. When I woke up in the morning, I saw matches vs Recar who proved that herding can be done efficiently. I tried to implement something similar, that I ended to code in my friend’s car and submitted when we arrived to our picnic location :slight_smile: After a few hours I decided to check how it’s doing and found some bugs that I fixed while my friends were playing frisbee.

Now some words about code organization.
I had base class for Entity and two derived classes for Ghost and Buster. All game information such arrays of busters, ghosts, base locations was stored in class Game. It could read information about new turn and update corresponding fields. I also had class GameAI which possessed tactical information such as behaviour mode, movingTargets, lists of enemy busters to intercept and so on. There was one main method named “makeDecisions” that subsequently called methods dedicated to particular activity. Part of it was as follows:

setSupportWhenEnemyNearby();
setInterceptors();
setBusting();
setStunEnemyBustingGhost();
setExplorers();
for (int index : movingToBase)
    setHerding(game.myBusters[index]);
setFancyChat();

Each method considered only busters that weren’t used in the previous methods (with a few exceptions, for example, for herding). Last one was the most useful method, of course :slight_smile:

I didn’t use any unit tests as I’m totally fine with controlling code of this small size (1.5k lines of code, including empty lines – about 50kb in total). I had a bunch of asserts here and there, though. Asserts are great way to prevent using some methods in the way you didn’t suppose to use them earlier :slight_smile: So for those of you who is thinking that unit tests are taking too much time to write I can suggest to try asserts. Nevertheless, I liked the way Hohol organized his testing: maybe I’ll try his recipe in the future.

I do not want to share my code as the game will be available for multiplayer soon, but I can answer any questions that you may have about some details of my implementation.

I enjoyed this contest a lot because I like to write team-oriented AI very much. This kind of games always include at least two levels of AI: high-level AI to determine current mode and goals for each unit and low-level AI which makes unit to achieve its goal in some optimal way. I hope similar contests will be conducted in the future :slight_smile:

10 Likes