First off, playing with more than two players (or teams) adds a formidable amount of complexity to Powargrid. Determining the game state and choosing which opponent to attack becomes much more difficult, since you don't just have to evaluate which target can most easily be reached, but also which opponent is the most dangerous to you. Attacking a weaker opponent can be bad for you if that gives a more dangerous opponent time to build up superior defenses or (worse) pull ahead on the number of power plants.
So sometimes you want to refrain from attacking. Or perhaps you want to put weapons down that threaten a player's base without actually charging them, awaiting the opportune moment or forcing them into a (temporary) alliance with you.
Which brings me to the social aspect, which is an even harder problem to tackle than the one above. While entering into formal(ish) alliances is rare in games like these, informal, spontaneous unspoken ones are quite usual. I usually see those as a small version of 'live and let live' arrangements that sometimes emerged during WWI, including all the fragility and vulnerability to (perceived) missteps those had. Luckily Powargrid is a lot less lethal.
Both the tactical and the social aspects are needed in an AI, at least to a certain degree, to prevent the AI from being too stupid, too frustrating or both. An AI that consistently attacks the weakest player and then gets overrun itself is no fun.
As an example, take a look at the gameplay GIF I included in the last blog post:
Perhaps not surprisingly, I recorded this GIF by playing (with blue) against three Skrimish AIs. And since my aim was to create a nice-looking GIF, I didn't even fully exploit the tendency of the AIs to go after each other. I hope this gives you a feel for why creating a Powargrid AI fit for multimultiplayer games is difficult :).
In this mission, we solved this by defining sections of the grid that are forbidden in the pathfinder. Michiel expanded our A* algorithm for this purpose (for more about that, see this blog post). In the picture above, the path yellow has used to get to blue's base is forbidden for green. The forbidden tiles for yellow lie on the outside of the grid.
While this is a good solution for A Piece of Paradise, it would be a hell of a job to implement this in a general sense. Hardcoding this into each AI for every map, every starting position and every possible distribution of players in teams is obviously way too much work. But writing something general is difficult, espectially if you want the AIs to be able to communicate about this. Also, sometimes it can be a very good move to block your team mates, since that may save them from an incoming attack.
So this is also a difficult nut to crack. And even then we're only looking at the first step of cooperation.
I guess that the short blog post turned out to be a bit longer than I'd thought, but I hope you liked it :).
-Willem-
PS; don't hesitate to let us know if there are Powargrid features you'd really like to see or if there is a subject you'd like us to address in a blog post.