by Luis Guzman
THE GAME AI
If you want to support|
this site, please ...
Although I think that Pg2 AI is not bad at all, the AI for OpenGen was developed from scratch instead of trying to replicate the Pg2 AI.
Currently there are two playable versions of the AI: 0.91 (2013) and 2.0 (2014). The version to be used can be defined in the scenario (to play standalone) and in the campaign file (to play campaign). AI setting in Scenario/Campaign can be defined as "Default" to use the default ai version defined in the game executable. Once the scenario is loaded the player, can force to use a different AI version, but this option was added for testing purposes and could be disable in future releases.
Default AI version in game executable is 0.91 (2013), to allow scenarios made before AI 2.0 to play as designed, but Suite will create campaigns and scenarios to use Ai 2.0 by default
Next sections refer to AI version 2.0 as that version is what should be used.
How the AI works
The AI lacks of a strategical analysis phase in the current implementation, so it figures objectives and actions based on the information available at start of the AI player turn, not remembering the enemy positions at the end of the previous turn.
All AI units are assigned a Stance, either at design time in Suite, or by assigning the Stance defined for the AI player when the scenario is loaded.
When AI turn starts, the AI first set up a list of all the Important Hexes (IH), a list of the known enemies and a list of its own units. Then loads the custom config file/s if any, and create the list of valid units available to purchase in that turn, storing also the cheapest purchasable ground and air unit. Once the general data for the turn is set up, the AI start doing its work using this sequence or ai-phases:
AI tries to keep their units alive, thus when any unit is short of ammo/fuel the AI either resupplied or moved to a safer position to resupply in next turn. For air units requiring fuel, the AI checks, when activating the plane, if it should fly toward a supply position to avoid crashing a the end of the turn or later.
And when units have loses below a threshold defined as percent of unit's base strength, the AI will reinforce/move to a safer position, to avoid losing them.
When AI has to scan units, it create a list of units likely to take actions, sorted by different criteria according the task to do, then each unit in the list is activated and a Tactical Map is set up pondering the goodness of each possible position/combat for the unit.
Players can enable to record the AI turn to a text file (ai_turn.log) which is saved into the Efolder's OPENLOG subfolder, which is a handy tool to analyze how AI worked out its turn.
Suite can set (at design times) some modifiers (Units View ..AI Tab) in order to change any AI unit behavior.
Some terms used
The scenario file includes a flag to know if unit's OH is assigned at design time or later by AI engine. The OH set at design time is released when the unit is closer than the distance set at design time to release it, and then the next OH will be assigned by the AI engine. If unit has assigned (not released yet) an OH from design time, AI engine does nothing.
When the OH is not assigned at design time, the AI figures the best OH every time the unit is activated.
The first thing AI checks is if unit should retreat using an EH, then it assigns the closer EH as the unit's OH if any exist. Notice that maybe there is an enemy unit in the EH, but the EH never is captured, so AI keeps seeing it as a EH to escape through it.
If the unit's stance is defensive and anchored or holding a VH, the AI assigns that hex as the OH (thus the unit won't move), otherwise (not anchored nor guarding VH), the AI checks for the closer VH in danger and if any, that VH is assigned as the unit OH. If no VH is in danger, the closer owned VH is assigned as the OH.
If unit's stance is aggressive the closer VH controlled by enemy is assigned as OH and if enemy doesn't control any, the closer enemy unit's position is selected as the OH
For planes (either air units, or ground units embarked in air transport) the AI engine use a different logic to assign OH.
The Tactical Map
Once created the list of units according a given criteria, the AI activates each unit in the list to conclude which is the best action/s to do.
When activating the unit, the AI does: