How did you do it?

So, with the final submission closed, I’m really curious what strategies and algorithms everyone used in writing their bots.

On my side, I’ve just put up a blog post talking about my high level approach. https://www.offerzen.com/blog/coding-for-the-win-how-i-built-a-tower-defence-bot

The one line summary is that it’s a Monte Carlo Tree Search with a maximum depth of 1, written in Rust and iterated on until I could get it as fast as I possibly could.

How did everyone else do it?

3 Likes

This is awesome dude, thanks for the writeup and congrats with the win! Compared to this my bot was entirely manual and very basic. I did not program at all for the Tesla tower, and didn’t program at all to build any defences whatsoever except for the iron curtain. I went with offence is the best defence. :joy:

Most of my logic was basically surrounding mapping the state and giving a viability rating for each cell for each of the building types. (Or for ENERGY and ATTACK anyway). That viability rating would consist of different things such as the type of building that it would hit if it attacked, whether it could destroy that target before it would fire an opposing missile, how many ENERGY targets would be behind the initial target or how under threat it was etc.

My energy strategy was basically to make sure that I always have just enough energy available so that I would still be able to build ENERGY the following round. So basically make sure I never skip a round because of not having enough energy, but also build ATTACK as fast as possible without having extra unneeded energy.

Then I just wrote a simple bash script so that I could run different versions of the bot against each other for like 100 games at a time and get a summary of wins/losses and then I would manually analyse individual moves to tweak the weight of the viability ratings.

This was my first competition like this and I enjoyed this like crazy and learned a lot. I’m very happy with placing #11.

1 Like

For me, programming is a hobby. I tried to learn something new when doing this challenge, which was neural nets. I wrote a bot that would take 40 odd parameters and use these parameters as a strategy. These parameters were things like what buildings should get priority for building, where on the map buildings should be build, what to do when a missile was incoming ,etc. I had 9 bots at any one time. 3 bots would be the current leaders, 3 bots would take the current leaders strategies and vary only one parameter and lastly I would have 3 bots having a complete random strategy. I would then play the bots with the varying strategies and random strategies against the top 3 bots. If they would win, they took the top bots place. I ended up playing 19000 games.:grinning:

I played 4 games at a time, running 4 docker containers. I mounted a folder to all the docker containers where the logs and state files of each game was saved. Ironically enough, I set out to learn neural nets, but ended up learning docker instead. My bot sucked (as expected) but I now know how to use docker.

That’s what I call winning in life. :sunglasses:

Well done to the top 8. Looking forward to this weekend. :v:

1 Like

My strategy didn’t really follow any textbook AI approaches, but the best way to describe it is probably something that vaguely resembles a minimax approach written in Java.

My bot places a massive emphasis on destroying the opponent’s energy buildings - and for the most part, disregards damage to my own base and buildings in the process. The only time I would deliberately attack the opponent’s attack buildings was if they were about to destroy multiple energy buildings on my side, or if I had to go through them to get to the opponent’s energy buildings. My theory was that the best way to win would be to prevent my opponent from doing anything, by focusing on destroying their supply lines, so to speak.

Looking back at the code, I think there was one major flaw - instead of building the first attack building as soon as possible, my bot waits one extra round to build another energy building (and to see what the opponent is doing). The reasoning behind this was to prevent a scenario where both players build an attack building in the same row, and both buildings are immediately destroyed. I wanted to damage energy buildings instead. It seemed like a good idea at the time, but in hindsight, it puts me at an immediate disadvantage to any players who focus on destroying attack buildings. It was a killer strategy against previous versions of itself though.

2 Likes

Is it possible for Entelect to release the replays of the games played (especially Countdown to Zero Hour)… this year was exceptionally hard, evenly-matched and had worthy contenders right through… for instance my bot won against a 3rd ranked bot but still lost to a 70th ranked bot… so it would be nice to be able to see the replays of tactics that I missed…

Pretty please can we get access to the replays from countdown to zero hour!

1 Like

I also used a MCTS with something called a DUCT(Decoupled UCT) since it was a simultaneous move game, but I only managed to complete about 1000 games in 2 seconds.

Firstly I didn’t have an optimized simulator which cost a bunch in sim counts, I did however hack my MCTS a bit to try getting the most out of it.

Rather than considering all possible moves I had a custom eval layer which ignored some moves that was obviously bad. A normal MCTS would usually find the bad ones, but I had to few sims to get that far.

I only simulated up to 50 randomly, since my sim was slow it made sense to shorten the game.(I might have used 20 moves at some point).

and finally I didn’t have the time to do everything I wanted to, I didn’t implement Tesla or the iron curtain, and still had the old missile logic, I don’t know how much better it would have been though.

Got 28th which I’m okay with given that I didn’t play as hard as I would’ve liked to.

1 Like

Hi everyone,

We will look into the best way to give you access to the logs for the Countdown to Zero Hour. Please note this might take a bit of time since we have other responsibilities as well. We’ll give you feedback about any progress as it happens.

4 Likes

My bot also used MCTS with a depth search of 1:) I only got about 20 000 game simulations in the 2 seconds provided. I am quite impressed with the 400 000 you got per turn. Well done:slight_smile:

1 Like

My bot used Heuristics, At least I do not know if I used something fancy.

The simulation part of my bot was the following lines:
for(yT=0; yT<mapY;yT++){for(xT=0; xT<mapY;xT++){if(b[0][yT][xT]!=“N”||xT>=pZ){continue;}for(m=0; m<3;m++){end=false;scorelog="";
if(li(1,xT, yT)){continue}
sM(1, xT, yT, m);
for(r=1;r<=rM;r++){if(end==true){continue;}pR(1);
}
eM(1, xT, yT);
}}}

Basically just simulating every possible move for the 400 rounds.

So at the end I only simulated around 192 full games. And my bot generally ended in around 20MS.

In terms of tactics, I used 2 different scoring algorithms.

Firstly while I had an energy advantage I would go for the quickest kill.
If I would fall behind on energy I prioritized points.

The only sad thing here was I never added survive-ability. (I literally left both my opponents on 5 life when they killed me at comic con. ) and I did not bother defending. But it cannot be helped. I left my submissions and updates for last minute. and I got to go to the finals.

So that was basically my tactics. To give every possible move a score.

I did try going 2 levels deep but did not like the results as the opponent’s move would stuff me up. Because if you try and defend first often times you give your opponent a major advantage especially against aggro bots.

I definitely need to read up on Monte Carlo Tree search, I mean I thought I knew what it was until they started explaining it and I realized I had no idea what it was really.

Really amped for next year’s challenge, But with the launch of Artifact next month I should be good till the next challenge.

Also asked Entelect and they are allowing me to do a YouTube series on building a bot, Since Im doing hueristics It should be easy enough to do for any person as Im using a bunch of if statements and for loops (Will try and trim down on my array usage…).

This might take a while to get into place though as I am not built for video.

Anyways, I am digressing. Enjoy your day all. And I am hoping to bring it at the next challenge… I see the competition is getting much harder. Compared to the last 2 years. But its always so much fun.

1 Like

I used my own bastardized version of MCTS. 1 layer deep with a LOT of random heuristics and tweaks to guide the search. On average the bot explored about 150 thousand games played to the end with random moves after the first layer.
It was quite a challenge to get my java code to be both fast while still providing a lot of statistics to guide the search. I used Enums, EnumSets, EnumMaps and a lot of static arrays.
One interesting thing i changed was to heavily prefer a tower advantage over health. My bot did not care much at all about killing the opponent. The focus was to kill his towers.

1 Like

Here we can see how it was done… video of final…

3 Likes