-
Notifications
You must be signed in to change notification settings - Fork 105
Attack
This command sends units to attack a specified units' group of the opponent.
Attack is a simple command that sends all units of a specific type to attack a target defined by a policy. Attack can be interpreted (composed) as:
Type defines which unit the command will send to attack. Considering that your unit will attack another one, you need to indicate which unit will be the target. To simplify this process, there are seven policies to define the target. To clarify let's summarize the policies:
- Strongest: Select as target the opponent unit able to cause the biggest damage in the actual game. It means that the policy considers just the units that exist in the game.
- Weakest: Select as targeting the opponent unit able to cause less damage in the actual game.
- Closest: Select as targeting the opponent unit closest.
- Farthest: Select as targeting the opponent unit farthest.
- Less Healthy: Select as targeting the opponent unit with the smaller HP.
- Most Healthy: Select as targeting the opponent unit with the higher HP.
- Random: Select as targeting the opponent unit randomly.
Below, there are some pictures to illustrate how the attack works for each unit.
If you have any questions to understand the units shown in the pictures above, please look at Units Information or Game Definition.
Used in a Loop (For)
Attack can be used inside of the for structure by adding a <unit>
parameter into the parameter list. It changes the command like the example below:
When attack receives a <unit>
as a parameter, the command will try to use the specified unit to attack the opponent unit selected by the <Opponent Policy>
that respects the type defined by the parameter <type>
. If the attack command is able to set up the action for the specific unit, it will return a command for the unit. If not, any action will be returned.
CommandDSL ast_example = new CommandDSL("attack(Worker,closest)");
ast_example.translate()
--> print in Java console--> attack(Worker,closest)
ast_example.friendly_translate()
--> print in Java console--> attack(Worker,closest)
BuilderDSLTreeSingleton.formatedStructuredDSLTreePreOrderPrint((iNodeDSLTree) ast_example);
--> print in Java console--> c->attack(Worker,closest)