I have been designing “AI” for my world at war(previously RISK) project. At first it thought I should use some form of machine learning for the AI so that it would learn from player interaction. I explored this idea but after some testing and realizing how long it would take before the AI would be good at the game and how much processing time it would take I dismissed this idea and went with the idea to design a pseudo AI which decides the course of action upon hard coded weights. These weights are decided by doing some math and exploring the game board state. It took quite a while before I had something I was happy with. I started where the game starts, which is picking countries. Once I had that down I started on the algorithm for placing reinforcements on the countries you own and then moved on to design the algorithm for picking a move/attack. I am not done yet, but right now the AI can play against itself with 2 to 8 players and eventually one victor remains which owns every country.
The difficulty was not in the coding aspect of designing this algorithm, more in which things are important in the game, so the AI makes smart decisions on what countries to pick at the start, where to place reinforcements and which attacks to do. Is completing a continent more beneficial than blocking a continent? Is a country which is easy to defend better than one with a lot of attacking opportunities? I feel like I have the algorithm considering the obvious considerations and am happy with how it functions. I will still make some improvements, though. Maybe it should be a little more random, or maybe it should be a little smarter, but for today I have done enough.