AI Concepts - Robosturm/Commander_Wars GitHub Wiki

This page is more a reminder for myself and maybe an inspiration for other dudes writing an ai for tuurn based games like Advance Wars.

Island Maps

Matrix containing indexes for each island for a movementtype. An island contains all terrains the unit with the given movementtype can reach on it's on. For example a tank can not cross sea so his island is seperated by it, while a fighter can move over it. So the fighter island differs from a tank island. An Island can also be the sea area for a ship. In the matrix -1 represents a none crossable field while indexes with the same number represent the same island. Island Maps represent a fast way to calculate if a unit can reach another one without the need to fully expand a search algorithm like A*. Commander Wars uses them to find relativ fast units which need a transporter e.g. a lander to get to the enemy or a building.

Task Order

Commander Wars restarts and checks all actions from scratch while using an order like capturing -> attack with indirects -> attack with directs. The advantage is a more flexible ai based on changes on the map due to unit movement. The disadvantage is a way higher computionnal overhead if multiple units don't fit into the earlier task groups.

Finding for far away tasks (greater one turn)

Commander Wars uses an a*-algorithm as base and modifies it to a dijkstra algorithm for finding the closest task upon all possible tasks for a unit. The ai basically gets all atttackable units, transporters or buildings and finds the closest one with a dijkstra algorithm and moves toward that target.

AI-Calculations

The ai uses qt's signal and slot mechanism to know if it needs to calculate a new move or if it needs to wait till an action has been finished. A signal is fired everytime all active actions are done. The ai than calculates a new move and emits a new signal for doing the next action. Advantage the ai can use the current map state without the need to store virtual data about the upcoming game state resulting on the last action, since the action has been performed. Disadvantage the ai gets slower this is espacially observable on large maps like a 50 * 50 map.

Decision trees and Score functions vs neural networks

Commander Wars uses self learning decision trees for several task like detecting if a co-power should be used. The advantage is it can be easily enhanced by a modder or a programmer. The disadvante is a pretty fixed behviour with less varity in general. Eventhough CoW uses a random decision generator if multiple options are avaible for the final leaf. A scoring function overs more flexibility like the one for the normal ai for building units or co-units. Since multiple inputs can be used to be balanced and and added with different conditions. But they are much harder to implement and balance the different factors. Like the 14-Inputs for building a unit. However they are still a white box model of what the ai does. Neural-Networks would be a nice addition to use but they require a lot more engineering and initial overhead to make them run. So i skipped them for the start.