Up ] Playing ] Editing ] Object'opedia ] [ AI explained ] PBEM ]

Instructions: AI explained

AI or Artificial Intelligence might be a presumptous word for the HQGM AI. It's only a series of goal finding algorithms, that simulate intelligent behavior.

The AI for HQGM adresses Monster movement, attack, defense and spellcasting. Below is an explanation of the different approaches and is "nice to know" information for the curious.

Movement AI

Each monster has been assigned an Attack-type that tells from what locations they can perform an attack (relative to the heroes). The movement algorithm simply tries to take the monster to the optimal square that satisfies the goal (while respecting walls and barred squares). In addtion to the attacktype there are some movement types that handle movement after an attack has been made. These are the attacktypes  and movement types currently implemented (v.2.3)

a.k.a "adjacent". Takes the monster to the nearest free player-adjacent square with line-of-sight (LOS) to that player..
Moves to the nearest free player-diagonal square with LOS. Failing this it tries to use the normal rule.
Tries to move to a square with LOS and a distance>1 to the nearest player.
Moves up to half the monsters moves away from the nearest player after an attack. This tactic allows for other monsters to move in and make an attack too (or it simply annoys the player who has to move before he can attack :-) )

The above rules are limited to work within the explored sections of the board. There are two special rules that also work on unexplored sections i.e. monsters using these will move through undiscovered doors and secret passages.

Used for the Ice Gremlin monster. After a succesfull steal-attempt the Ice gremling will try to escape the heroes. If at the beginning of the monsters turn there is no LOS to any player it will have escaped and is removed from the board.
Try WoM quest 5 for this one. The monster will seek to uncover new areas, revealing the dungeon as it moves until it finds a fully revealed path to a player. any other monsters it encounters will be activated, simulating a massive call-to-arms once the path to the players has been cleared.
Attack AI

This is really basic "intelligence". When a monster has an attack position as described by its attack-type it will roll the appropriate number of combat dice. If more than one player is within reach it will choose one randomly. Most monsters only have one attack but some have double attacks (x+y) while archers have a ranged and a close combat attack (ranged / closecombat ). Finally the very special attacks such as "steal" (Ice Gremlin) "bonus attacks" (Orc berserker) and "hug" (Yeti) are handled with seperate routines.

Defense AI

The simplest of all. The monster rolls it's designated defense dies and the player indicates any BP loss. Various death cries have been created for the monsters depending on their defense strength and/or the amount of BP loss received in the last blow.


When a spellcaster is first encountered he sorts his spells so that summoning spells are cast first and then attack and defense spells at random. The caster will move according to the spells requirements (e.g. Chill requires a player adjacent square but Summon Orcs can be cast anywhere).
Once the spells are depleted the caster will resort to physical attacks.
The spell effects are NOT handled automatically except for monster healing spells, Escape spells and summoning spells. I know this is an area that could need improvement, but don't expect flashy spell effects soon. Players should use their imagination when a chaos spell has to be resolved (adding monsters, giving monsters extra attack dice temporarily etc.)