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: 6125
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
Categories, Functions, Expressions, and Values
I'm pretty sure you all know of the categories; Infrastructure, Offense, Defense, Information, MajorItem, Hero, StoryArc, and Always. Each have a budget, which are broken down into Goal functions, which are made up of Goals and Functions; Functions are made up of Expressions, which are made up of Values. It's basically just a bunch of organized Algebra, put into a simple form.

Now, you must understand, not all "budgets" are made up of credits, but more so just numbers without an indentifier (They're not "X Credits", "X Dollars", or "X Inches", and what not). The one with the highest are the one the AI will do first. Such as, if the AI is faced with two planets, it'll formulate the values and whichever one is higher, it'll attack that one. (Ex: Coruscant has a value of 10000 and Byss has a value of 9000, the AI will attack Coruscant first). What it attacks the planet with is defined in the Lua source; unfortunately, you can't tell the AI "The higher the value, the more ships you send!" Doesn't work like that; it has to attack the planet first and study the outcome. The only way to do such a thing is by increasing the desire with the Per_Failure_Desire_Adjust tag (It can increase or decrease).

Okay, so does the AI just choose the Category with the highest value too? Not that I know of. But, that kinda be stupid way for the AI to work, don't you agree? The categories don't compete, because they do entirely different things; functions inside a category compete. The categories competing would be like a shampoo company competing with a gas company; they don't even sell the same things.

So, yes, it is possible to simplify the expressions to the point that the resulting budget is doesn't surpass 4 integers, which would make the AI faster (I can't tell you how much faster it'll get).

So, where are these categories defined? In the templates, found in XML/AI/Templates. The categories that are on are defined in the <Turn_On> tag. Be catious, though; you must keep all templates up-to-date.

How variables are used in expressions
Now that we (hopely) know a little on how the AI is structured, let me tell you how exactly variables work: they are basically text to be replaced by a number. They are floating point numbers, I believe.

But, are they just numbers? Do they just mean anything? No. The value is determined by any number of functions defined in Empire at War's game engine (the library that defines what means what). For example, Variable_Target.Health will return that target's current health; Variable_Target.StarbaseLevel will return the planet's current space station level. "Health" is a function; "StarbaseLevel" is a function; they take the Target and return the specified information.

Links / Downloads

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

Add comment

Please enter your message below. Max 10000 characters.