BlitzProg - 87th (C++)
I’ve had a wonderful time. Antiyoy is a game I am playing and have been playing for years to kill time, so naturally seeing this challenge was very inspiring for me! I had many ideas to improve my AI and didn’t have time to code everything, but overall I’m still quite happy with what I’ve come up with. I tried to go for legend this time, but alas, the gold boss was way too powerful to remotely get close. And the other players were so strong too!
Here are the strategies I used:
-
Started off by testing the waters using Wood 3 rules For each unit, order to move toward unclaimed space, or move toward enemy HQ if not possible. Also spend money accordingly. This got me promoted to bronze.
-
Porting to C++ from PHP, I made it so I was also updating my data as I was giving out orders, so it wouldn’t ask two units to move to the same place or buy over a space it just asked an unit to move to. This was enough to get into silver league.
-
I’ve ranked up in the silver league by implementing bought attacks. This means my AI would detect that buying a particular chain of level 1 units would end up cutting an enemy territory from their HQ. Another function would also calculate how to buy the game and do it if enough money available. (buying chain of units until HQ is reached).
The search for game win is made with Dijkstra. If a win is found, I backtrack to output the required kill commands. Cells are weighted according to the cost needed to buy an unit. Later in the development I found a way to integrate a discount for taking a tower, based on how much this would save money.
My search for territory uses Bruteforce: I call a function on each enemy cell that borders a cell I own, and pass it two diagonals and a binary number of given length. I test every binary number with every diagonals. For each bit of this binary number, if it’s zero, it tries to extend the chain horizontally, if it’s 1, it tries to, vertically. This will easily search all possible cuts from the cell I’m starting the attack, using two directions.
- Promoted to gold with implementation of defense. after moving my units, calculate which border cells the enemy could move to (or buy over my units if they have the gold) and try to place towers accordingly. This made it much harder for the enemy to take or split my territories and made it much simpler to tank until I had the money to finish the game.
The rest of the challenge was about trying to progress with the minimum goal to stay in the top 100. Some of what I did:
- checks to see if buying a level 2 unit over a level 1 would kill an attacking chain of units
- fixes for the tower defense logic for a few specific cases (like: don’t build right in front of a level 3)
- update my kill dijkstra so it works with downed towers (if you buy a lv3 over a tower it immediately stops protecting the cells behind it)
- Staller and stalled checks (need a lv3 to go to HQ). If we are stalling each others, I try to save money to buy a kill, and buy towers to increase the cost needed to kill me.
- Last minute pathfind so my units with no neighboring empty tiles don’t run in circles.
My weakest point was probably how I was moving around my units. I’ve lost many games because of how dumb my logic is, and the last improvement above barely improved it. (Decent tower placement helped a lot to save them, probably why my defense helped ranking up so much)
I lacked inspiration there and was never sure of the best logic to use there and most of the starting code stayed around until the very end of the challenge. I hope I can read other people’s strategies so I can see how I should have approached it.
Thanks for the challenge! 