Debriefing WinterThrone2020 (CODE OF ICE AND FIRE)

Winter throne was unofficial contest which took place from 10th october 2020 and lasted for 10 days and ended on 20th october 2020.The contest game was choosen from voting system and the game was “a-code-of-ice-and-fire”.The contest ended now,You can look leaderboard here - []
Now you can share your strategies for others.
Get boosted for Fall challenge…


Thanks for organizing the event, it was the first time I played Code of Ice and Fire and it was one of the most fun games I tried so far. I took first place in progression leaderboard so I decided it would be nice to share some thoughts.

First of all, I liked this game because it allowed for a lot of freedom in contrary to, for example, Ocean of Code where everyone had to include very similar enemy-detection system. I feel like banking gold or towering up, aggressive vs defensive play were all viable depending how you wanted to approach the game and even then each of these could be implemented differently based on what you thought was important.

Before I dive into strategy I wanted to say a little about workflow. This is the first contest where I decided I was done with programming in one file. It is obviously a bad practice and sadly Codingame encourages it with its infrastructure but it is something we have to work with so I decided to spend some time and prepare my environment for this and future contests. It took less time than I expected it to, simple script to bundle up my files into 1 and CG-Sync to share the file with the IDE. My workflow is much better and I can finally spend more time coding instead of trying to find things in 2000 lines file. I know it sounds like a magic pill advertisement but it kind of is, if you are still stuck in this bad practice then try to move away from it and you won’t regret it. The only thing I regret is that I did this too late in this contest and my code was already too big of a mess to improve it and try to go for first place in the main leaderboard as well.

So now a little bit about strategy and functionality needed for your bot to succeed in this game. There is a lot you can make in a single turn and the game is very volatile so finding the best way of attacking and the best way of defense is very important. I feel like because there is so much that can happen it’s not really possible to make perfect simulation or search and also I am not trying to pretend that I can do this stuff in Java.
I feel like there was a few main aspects that were important to include into your bot:

  1. Finding direct kills from your current position - this one is pretty obvious, if you can find the kill then go for it. I used uniform cost search for this but I guess any Dijkstra-like algorithm will do the job. I guess you could get away with not including it if your bot was really good at everything else.
  2. Less important than 1) was finding direct kills that your opponent can do in the next turn. I feel like this is less important because if your enemy can have direct kill on you next turn you are usually in a losing position and these situations are not the easiest to defend. I coded some defensive tower placements and stuff but it never worked really well because you place things to defend and your opponent can just bank more money. I feel like in this situation best defense is offense to just try and get the game swing in your favour again.
  3. Any-shape cutting of your enemy and evaluation of the cuts themselves. I coded it twice and even the second time it was not good enough because I wasn’t sure how much optimization I will be able to put into this search. I definitely should have tried to go all-in here and just try to implement any-shape cutting from the start instead I started from simple straight lines and then second pass was adding branching to the straight lines which allowed me to do L-shape cuts. I am still not sure what is the most efficient way to search for any-shape cuts but it was definitely neccessary to do well in Legend and one of the reasons I gave up on improving my bot in the end. I was also finding only the best cut that was possible instead of multiple and I think that could’ve been very useful.
  4. Using algorithm from 3) to detect cuts that your opponent can do against you and protecting against it with towers or units. I feel like this should be the main logic for tower placement to protect yourself from valuable cuts that your opponent can do. Again as I wrote above I was only looking for the best cut so my bot missed important information now and then.
  5. Different evaluation of tier 3 units. I feel like this was quite important to code into your bot because using tier 3 units if you are not doing a big attack or direct kill is very detrimental to your position on the board. At the same time if you just left tier 3 units of your opponent alive in situations where they didn’t pose any danger could be devastating for his economy. Also something my bot was doing only semi-well.
  6. Last but not least it was important to efficiently take map and move to the center as fast as possible. There was a few approaches for this but at the end I used fixed spawns which you could call a ‘build-order’ for turn one. It would probably be a good idea to implement something like hungarian algorithm for this but I got away with some sorting for my units in order so units with only 1 zone to take would start first which dealt with the most important blocking situations.
  7. At some point in the game it is a very good idea to start banking money, sometimes even before both players bunker up with towers. I was playing around with logic around ~turn 8 where usually both players enter the middle of the map. I would try to avoid spending money if there wasn’t anything important to spend it on. On your next turns your potential for cuts grows and your opponent needs to take a lot more different attacks into account. This was good and bad at the same time because if you didn’t get benefit from banking the money then it’s better to spend it on taking land more efficiently.

There is a lot more I could talk about here but don’t want to make this post-mortem too long so people are still interested in reading. I feel like other parts that you could find important would be front-creation (where your and enemy units ‘hug’ in the middle of the map’), creating ‘formations’ which are harder to cut or just connecting your land in a way that is harder to find good cuts against. I saw some people pushing hard at the start of the game into enemy territory which if successful could set up a very nice mid and end-game. As I said - many different ways to approach the game and strategy around it. Overall, great game!


Liked the voting format. Expected tulips game since i never touched that before.

CIF would have been fine, but didn’t get time to do anything with it and when i got a few hours free to do something i wasn’t in mood anymore.

I see the chat was lively so I guess I missed out.