Explanation of Empire At War's AI "engine"
|
1 vote |
Basic expression syntax
It's quite simple, really. You basically just follow the order of operations found in math. All you really need to know are the operators:
* = Multiply/can be used as a form of an "If" statement
+ = Add
- = Minus/Subtract
/ = Divide
> Greater than
< = Less than
() = Blocks of expressions which end up as one value
# = Unknown/I'm not sure what this operator means
The mulitply, I think, is the hardest to get used to, but it's quite easy. It can be used to multiply or an "If" statement. How? Well, remember how each function returns a value? Well, if one expression in that function require something and that requirement isn't met, then it returns 0; if it's true, then returns 1. Something such as this...
(Variable_Self.BaseLevel > 0)
...will return 0 if it's false and 1 if it's true. What's the point? The multiplication. If the statement is false and it's multiplied by something, then the result is 0. For example:
<Allowed_To_Retreat_From_Space>
Game.IsCampaignGame
*
Variable_Self.CanRetreat
*
(1.0 - Variable_Self.IsFaction {Parameter_Faction = "Pirates"})
</Allowed_To_Retreat_From_Space>
If Game.IsCampaignGame returns 0, then the function returns a 0, no matter what the other values are. If Variable_Self.CanRetreat returns 0, but Game.IsCampaignGame and (1.0 - Variable_Self.IsFaction {Parameter_Faction = "Pirates"}) return 1, the whole thing is 0: 1 * 0 * 1 = 0.
It's quite simple, really. You basically just follow the order of operations found in math. All you really need to know are the operators:
* = Multiply/can be used as a form of an "If" statement
+ = Add
- = Minus/Subtract
/ = Divide
> Greater than
< = Less than
() = Blocks of expressions which end up as one value
# = Unknown/I'm not sure what this operator means
The mulitply, I think, is the hardest to get used to, but it's quite easy. It can be used to multiply or an "If" statement. How? Well, remember how each function returns a value? Well, if one expression in that function require something and that requirement isn't met, then it returns 0; if it's true, then returns 1. Something such as this...
(Variable_Self.BaseLevel > 0)
...will return 0 if it's false and 1 if it's true. What's the point? The multiplication. If the statement is false and it's multiplied by something, then the result is 0. For example:
<Allowed_To_Retreat_From_Space>
Game.IsCampaignGame
*
Variable_Self.CanRetreat
*
(1.0 - Variable_Self.IsFaction {Parameter_Faction = "Pirates"})
</Allowed_To_Retreat_From_Space>
If Game.IsCampaignGame returns 0, then the function returns a 0, no matter what the other values are. If Variable_Self.CanRetreat returns 0, but Game.IsCampaignGame and (1.0 - Variable_Self.IsFaction {Parameter_Faction = "Pirates"}) return 1, the whole thing is 0: 1 * 0 * 1 = 0.
Links / Downloads
Hits | Added | |
---|---|---|
NameSpace and TestFunction (Page 6) | 2607 | February 25, 2008 - 3:19 |
News article pertainting to tutorial | 3063 | February 25, 2008 - 3:07 |
The original thread | 2978 | February 25, 2008 - 3:06 |