Those working on this mod do so in their own free time and for no pay.
Show your support for them by enabling ads on this site!

Author Topic: Coding the AI  (Read 3981 times)

0 Members and 2 Guests are viewing this topic.

March 29, 2018, 08:59:33 AM

Offline demcalves

  • Stormtrooper Captain
  • ***
  • Posts: 18
  • Approval: +0/-0
    • View Profile
Coding the AI
« 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?


May 29, 2018, 01:51:01 PMReply #1

Offline Mord

  • Stormtrooper Captain
  • ***
  • Posts: 23
  • Approval: +3/-0
  • Princess Leia has had enough of your shit.
    • View Profile
Re: Coding the AI
« Reply #1 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. 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".
« Last Edit: May 29, 2018, 01:55:20 PM by Mord »

 

Those working on this mod do so in their own free time and for no pay.
Show your support for them by enabling ads on this site!