Thrawn's Revenge

Imperial Civil War [Empire at War] => Discussion, Suggestions & Feedback => EaW and FoC Mods => Topic started by: demcalves on March 29, 2018, 08:59:33 AM

Title: Coding the AI
Post by: demcalves on March 29, 2018, 08:59:33 AM
I have a question about a line of code found in the source file for FOC. Under XML\AI\Goals there are many files like AI_Goals_Underworld_Galactic.xml that have code that looks like this for example:

<Corrupt_Planet>
      <AIGoalApplicationFlags> Enemy </AIGoalApplicationFlags>
      <GameMode>Galactic</GameMode>
      <Category>Infrastructure</Category>
      <Reachability>Any</Reachability>
      <Time_Limit>60.0</Time_Limit>
      <Build_Time_Delay_Tolerance>1.25</Build_Time_Delay_Tolerance>
      <Tracking_Duration>300.0</Tracking_Duration>
      <Per_Failure_Desire_Adjust>-20.0</Per_Failure_Desire_Adjust>         
   </Corrupt_Planet>

What I am curious about is if the tag <Corrupt_Planet> is hard-coded or not? If that's the case then does only the code inside the tags matter more?

Title: Re: Coding the AI
Post by: Mord on May 29, 2018, 01:51:01 PM
Very short answer:
No, the top-level Goal tags are not hardcoded. The code inside the Goal tag matters a lot, both to the Goal itself and to other code that refers to the Goal.

Somewhat longer answer:
If you're interested in the AI, you should read this (https://steamcommunity.com/sharedfiles/filedetails/?id=1171759326). You can create new goals with new top-level tags, but creating new goals by itself won't do anything for you. "Goals" are things the AI might like to do, but whether or not the AI will actually try to do them is governed by a "goalfunction" that links the goal to a perceptual equation. The perceptual equation is a way for the AI to evaluate the desirability of pursuing that specific goal at that specific moment. In your example, the goal "Corrupt_Planet" (AI_Goals_Underworld_Galactic.xml) is governed by the goalfunction also named "Corrupt_Planet" (AI_Goalset_Underworld_Galactic.xml) and the perceptual equation named "Should_Corrupt_Planet" (AI_Equations_Underworld_Galactic.xml). Once the AI has decided to pursue a Goal, it then uses a Plan to actually execute tasks in pursuit of that goal. The only Plan available to the AI in pursuit of the "Corrupt_Planet" goal is found in "AI_Plan_Underworld_DeploySaboteur.lua".