Jump to content

[WIP] Alien Strategy AI rework


Daemonjax

Recommended Posts

XCOM Strategic Alien AI Rework

 

  • The current AI operates mostly randomly, with some scripted elements thrown in mainly for plot advancement.

  • At no time does the AI even attempt to implement any kind of strategy try to win at the Strategic level.

  • There's no decision-making involved, except to make things even easier for the player on lower difficulty levels.

 

That doesn't even qualify as an AI. How many times would you want to play a chess game against another player that makes mostly random moves, except to actively set you up with an uneven trade that almost always works in your favor? This mod aims to change that by implementing an AI that can make strategic decisions using Game Theory.

 

The AI will try to win by generating missions (using limited resources) with the highest chance of success to:

  1. Generate panic to increase its resource pool for future operations.

  2. Disrupt XCOM plans (satellite coverage, continent bonuses, tactical preparedness)

  3. If the AI is doing poorly on the Strategic level, it will consider shifting resources to punish xcom on the tactical level, and vice versa.

     

    Decision selection will be based on finding Nash Equilibriums – Mixed Strategies using probabilities based on statistical analysis of information that the AI could reasonably know or infer (e.g. it knows you have a satellite over a country when you shoot down UFOs there, not by simply calling the function HasSatelliteCoverage()) and proper weighting for the expected utility of potential increased panic offset by potential lost resources.

 

The following are ideas that may change and/or be expanded upon. Where possible, draw inspiration from the original 1994 game:

 

I. Alien AI Goals

 

A. Create Alien Base(s)

  • The Alien Base is the Alien equivalent to XCOM's base.

  • Some time after XCOM chooses its starting country, the Alien AI will also choose a country to place its alien base in. The Alien AI will also receive some kind of bonus based upon the country selected (just like XCOM does).

  • Whenever selecting an Alien Base location, it will not choose a country that it knows has satellite coverage.

  • New alien bases can (only?) be created when the old base is destroyed – the creation of a new Alien Base becomes a high priority.

  • Some bonuses the AI receive can help directly within the Strategic or Tactical game, so the AI may delay the choice until near the end of the first month to make a better decision.

  • The presence of an Alien base will generate a large amount of panic in that country each month, and that country will most likely drop out of the Council.

  • The AI will aggressively search for and shoot down satellites over countries containing the alien base.

 

B. Increase Panic

  • The AI must know that it needs to generate X amount of panic to remove Y number of countries from the Council in order to attain victory.
  • There are 16 counties, with panic ranging from 1 (16 min) to 5 (80 max). The AI doesn't need to generate the full 80 points to win, and it should know that as well.
  • Whenever panic increases, the Alien AI gets additional points that it can spend on subsequent missions.
  • When a country withdraws from the council, they receive additional points for that country every month (just like xcom does for satellite coverage).
  • When they control each country in a continent they get another bonus (similar to what XCOM gets).

 

I'm currently in the R&D stage, but I already have a fairly good idea of how to accomplish the above, and will be throwing up all my notes and code changes here.

 

 

List of potential unused/Repurposeable variables and functions:

 

XComGameStrategy.upk

XGStrategyAI

var array<int> m_arrUFOsShotDown: Dynamic array of size 8, which can be resized for additional data storage.

 

var int m_iAlienMonth ....: Incremented in XGStrategyAI.EndOfMonth(), but I don't think it's actually used anywhere.

var int m_iTerrorCounter: Used in XGStrategyAI.AIAddNewObjectives() only to ensure terror missions occur only every other month.

 

function XComGame.XGGameData.ECountry ChooseOverseerTarget().........................: Used to purposefully have the AI make a bad decision.

function array<XComGame.XGGameData.ECountry> DetermineBestOverseerTargets(): Used to purposefully have the AI make a bad decision.

function bool IsGoodOverseerTarget(XComGame.XGGameData.ECountry eTarget)......: Used to purposefully have the AI make a bad decision.

function array<int> DetermineBestHuntTargets().......................................................: Doesn't seem to be used anywhere.

function int GetNumResistingContinents()..................................................................: Seems to only be used in DetermineBestHuntTargets() (which doesn't seem to be used anywhere).

function bool IsGoodUFOMissionChoice(TUFO kUFO)..................................................: Used only to unintelligently restrict choice.

 

 

Other notes:

 

1) This function seems to be the only one with tasty local variables suitable for making calculations:

function NormalizeValues(out array<TAlienChance> arrPossibles)
{
local int iTotal, iChance;
local float fFactor, fChance, fTotal;
...

 

}
2) There's no array of floats to subvert anywhere (that I can find), so I may have to store float information in fractional form (pairs) using arrays of ints, or change an existing array of ints to be an array of floats (better). How hard would it be to change array<int> m_arrUFOsShotDown into a float array? Queston asked (and answered) here: http://forums.nexusmods.com/index.php?/topic/2551689-changing-class-variable-type/ Also, the struct TSatellite does contain an array of Vector2D, which contains two floats... so I could use that (XGHeadquarter's TSatellite[] m_arrSatellites accessible from XGStrategyAI via HQ().m_arrSatellites).
I'm currently recreating the existing strategy-level AI (if you want to call it that) in Java (I'm really just interested in the logic of it, so it's not going to have a fancy GUI). Once that's done I'll be in a better place to implement and test new code... I'll throw it up on google code when it's done-ish.
Edited by Daemonjax
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...