Rule based systems (RBS) provide game developers the opportunity to approach AI within a game based on real world player interaction. Given a set of context based rules and known facts, which can be gathered through the environment, expert systems are able to simulate human behaviour within the scope of a specific area domain.
The advantage of introducing a rule based system within a game is the ease of implementation when compared to other AI techniques. In addition, it is easier to manage and modify, as the rules are modular. One of the earliest implementation within the video game industry can be seen in Master of Orion, a turn based strategy named released in 1993. The game was one of the first to be classified as a 4X strategy game, a term coined by Alan Emrich, known as the designer of computer games, whilst previewing the game in its early days. This stands for eXplore, eXpand, eXploit and eXterminate, and this is the easiest way to describe the objective of the game given that the player needs to conquer a galaxy or a map dominated by a handful of AI bots.
Using RBS, the AI responds to player behaviour and interactions based on known facts within the game world. For instance, let’s consider Civilisation V, a popular modern 4X title released by Firaxis Games. The game AI can be described as a really complex rule based system, as there are several input parameters which can fire up different rules within a game. Furthermore, the AI needs to be aware of other AI controlled civilisations and also players.
In order to design an RBS, a current state of technology or attributes to a civilisation needs to be stored and updated each turn. In Civilisation V, this can include resources, treaties, alliances, trades etc. Furthermore, using sensors such as scouts, the AI will be informed and update its database from world observations. With all of these attributes combined, the AI will be able to determine, based on a set of rules, what the next move should be.
Based on discovery, a strategy starts forming to counteract both player and AI advancements. The problem with expert systems is that through edge cases or possibly even bugs, they can become exploitable. In RBS, it is possible to assign weighting to a rule, as an avoidance mechanism for conflict resolution, in the case where more than one rule matches a certain criteria. The weighting allows the AI to give more importance to a certain rule to be fired first, depending on the game designer’s choice.
In Civilisation V, Mahatma Ghandi, the peaceful ruler of India, was able to launch nukes when at war with other players. Ghandi is known as a peaceful ruler, and this behaviour should not have been possible. However, given that the game makes use of a rule based system, a bug related to a democratic choice affected the aggression weighting of civilisations. In Ghandi’s case, when a player opts for democracy, the aggression is reduced by 2. Given Ghandi is a peaceful leader, the developers set the aggression to 1 for India’s ruler, and the aggression range for the game was from 1-255. Aggression cannot be represented as a negative number, and the system sets the weighting to 255 for India, turning Ghandi into the most aggressive ruler within the game.