SAI Example 2

beginrem

This example will show four strategies to illustrate how Advisory conditions work

Symbols (The quotes are literal) :

"-"   Difference

">-" DifferenceGreater

"<-" DifferenceSmaller

"/"   Quotient

">/" QuotientGreater

"</" QuotientSmaller

endrem

rem ------------ THE CONDITIONS ------------------------

rem -= Check if Friendly has more than half the control points on the map =-

rem    This is a heterogenuos condition that uses division. We don't need to

rem    know ahead of time How many control points there are.

rem    This is done by dividing the number of friendly control points

rem    by the number of enemy ones, then checking if the result >= 0.5

 aiStrategy.createHeterogeneousCondition evenOrBetterOnFlags Crisp ">/" Both ControlPoint ControlPoint

aiStrategy.TargetValue 0.5

aiStrategy.setConditionStrength Advisory

rem -= Check if there is at least one enemy control point

aiStrategy.createConstantCondition enemyHasAtLeastOneControlPoint Crisp ">-" Enemy ControlPoint 1

aiStrategy.setConditionStrength Required

rem -= Check if enemy has no control points =-

aiStrategy.createConstantCondition friendlyHasAllControlPoints Crisp "-" Enemy ControlPoint 0

aiStrategy.setConditionStrength Required

rem -= Check if there is at least one neutral area =-

aiStrategy.createConstantCondition atLeastOneNeutral Crisp ">-" Friendly NumberOfNeutralAreas 1

aiStrategy.setConditionStrength Required

rem -= Check if there are no neutral areas  =-

aiStrategy.createConstantCondition noNeutrals Crisp "-" Friendly NumberOfNeutralAreas 0

aiStrategy.setConditionStrength Required

rem  --------- The PREREQUISITES  -----------------------

aiStrategy.createPrerequisite attackTheEnemyHarderPrereq

aiStrategy.addCondition evenOrBetterOnFlags 9.95

aiStrategy.addCondition enemyHasAtLeastOneControlPoint 0.05

aiStrategy.createPrerequisite attackTheEnemyPrereq

aiStrategy.addCondition enemyHasAtLeastOneControlPoint 5.0

aiStrategy.createPrerequisite attackTheNeutralsPrereq

aiStrategy.addCondition atLeastOneNeutral 5.0

aiStrategy.createPrerequisite defendTheMapPrereq

aiStrategy.addCondition friendlyHasAllControlPoints 2.5

aiStrategy.addCondition noNeutral 2.5

rem ------------ THE STRATEGIES -------------

aiStrategy.createStrategy attackTheEnemyHarder

aiStrategy.Aggression 0.95

aiStrategy.NumberOfAttacks 3

aiStrategy.NumberOfDefences 0

aiStrategy.setStrategicObjectsModifier ControlPoint 15.0 Neutral

aiStrategy.setStrategicObjectsModifier ControlPoint 30.0 Hostile

aiStrategy.setPrerequisite attackTheEnemyHarderPrereq

aiStrategy.createStrategy attackTheEnemy

aiStrategy.Aggression 0.9

aiStrategy.NumberOfAttacks 2

aiStrategy.NumberOfDefences 0

aiStrategy.setStrategicObjectsModifier ControlPoint 10.0 Neutral

aiStrategy.setStrategicObjectsModifier ControlPoint 20.0 Hostile

aiStrategy.setPrerequisite attackTheEnemyPrereq

aiStrategy.createStrategy attackTheNeutrals

aiStrategy.Aggression 0.9

aiStrategy.NumberOfAttacks 2

aiStrategy.NumberOfDefences 0

aiStrategy.setStrategicObjectsModifier ControlPoint 20.0 Neutral

aiStrategy.setStrategicObjectsModifier ControlPoint 10.0 Hostile

aiStrategy.setPrerequisite attackTheNeutralsPrereq

aiStrategy.createStrategy defendTheMap

aiStrategy.Aggression 0.25

aiStrategy.NumberOfAttacks 0

aiStrategy.NumberOfDefences 3

aiStrategy.setStrategicObjectsModifier ControlPoint 10.0 Owned

aiStrategy.setPrerequisite defendTheMapPrereq

rem ----------- ASSIGN THE STRATEGIES TO BOTH TEAMS ------------------

ai.addSAIStrategy 1 attackTheEnemy

ai.addSAIStrategy 1 attackTheNeutrals

ai.addSAIStrategy 1 defendTheMap

ai.addSAIStrategy 1 attackTheEnemyHarder

ai.addSAIStrategy 2 attackTheEnemy

ai.addSAIStrategy 2 attackTheNeutrals

ai.addSAIStrategy 2 defendTheMap

ai.addSAIStrategy 2 attackTheEnemyHarder