Green Rollover Red Rollover Arrow Rollover Focused Userbar Register Button Rollover Red Button Rollover
Welcome Guest ( Log In / Register )

Explanation of Empire At War's AI "engine"

Avatar of Drieick

Drieick

Category: Coding
Level: Intermediate
Created: Monday February 25, 2008 - 3:03
Updated: Monday May 5, 2008 - 22:43
Views: 6128
Summary: Taken from the forums, a tutorial on EAW's AI

Rating

Staff says

5.0

Members say

-

Average

5.0/5.0

1 vote

Page 1 2 3 4 5 6
The difference between a goal function, a goal, and a function
Functions are what determines the value of a goal function; goal functions are used to determine what action the AI will take in whichever category. Functions are just expressions - they can be a single line, dozens of lines, or they can be a single number; doesn't matter, as long as there's a number.

How does Empire at War know which function to use? Through the goal functions. The goal functions specify which goal to use and which function to use. What is the difference? A goal describes where the function will be used; i.e., in Galactic mode. The function just defines the goal functions' value.

Basically, you the a goal function, which is made up of a goal - which describes how the goal function and function will be used - and the function, which provides the goal function with a value.

How to use a function and implementing scripts inside other functions
Once you understand the expressions' basic syntax, using functions is quite easy.

You can call a function inside a function, just like any other scripting langauge. Basically, it's just this: Function_FunctionName.Evaluate. Without Evaluate, there's no return value, and thus, a syntax error. The function can return a binary value (0 or 1) or an actual number; for example, 246.

Lua scripts can be used as well. The syntax to call a Lua script is just this: Script_FileNameTheScriptIsIn.Evaluate. Evaluate has a different purpose here: it calls the Lua function "Evaluate", which of course, returns a value. If the "Evaluate" function has parameters or arguments, you can define those in the XML as well, by using this: Script_FileNameTheScriptIsIn.Evaluate{Parameter_Script_String = VALUE}. The number of Parameter_Script_String depends on how much arguments the Evaluate function in the Lua script require.

Links / Downloads

 HitsAdded
NameSpace and TestFunction (Page 6)2447February 25, 2008 - 3:19
News article pertainting to tutorial2915February 25, 2008 - 3:07
The original thread2842February 25, 2008 - 3:06

Add comment

Please enter your message below. Max 10000 characters.