Is it possible to use machine learning to build the best bases in Clash of Clans?

1 minute read

If you are living under a rock for the past few years, then you probably don’t know about Clash of Clans. Clash of Clans is a strategy game for Android and iOS, published by Supercell back in 2012.

I’ve been playing it for many years, given its addictive nature. Here is a simple introduction, within the game, you have different defenses and other players attack your base to steal your gold and other resources. Every player’s base layout is different, and you basically have to build your base strategically to defend successfully from attacks and protect your resources. There are many sites where users have posted their own base layouts based on their effectiveness. The base layouts show the max level of the defenses and sometimes do not exactly defend so well, this got me thinking: How to build the perfect base?

Not a perfect base

Can we use artificial intelligence please?

Yes! Definitely! It is possible, but (there’s always a but), it won’t be easy as we don’t have access to the game code and there is no emulator for the game. During my bachelors and masters, I have studied machine learning and artificial intelligence. It’s possible to make a evolving neural network for this given problem, if you feed it attributes of all the buildings and defenses available in the game and observing the fitness of the network based on the function of damage to the base. There are different heros and troops available on each Town Hall level within the game, and many different defense structures along with the blocking structures such as walls and other buildings. Each defense structure and troop has different level of power and range of tiles. It makes the problem statement huge. Perhaps its easy to solve this problem using maths only, without any visualizations.

Some years ago, I also saw this video of AI playing a single level of mario:

So, its definitely possible, but somewhat difficult. There are some frameworks also, so far, I found this framework called universe which is no longer maintained. I will comeback to this after my exams. Let me know if there is any other framework available or how would you solve this problem?

Note: I am not affiliated in any way with Supercell

Leave a comment