Skip to content
Rubens de Oliveira Moraes Filho edited this page Apr 29, 2021 · 5 revisions

This command sends units to attack a specified units' group of the opponent.

Stand-alone application

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:

attack(<Type>,<Opponent Policy>)

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.

Attack Attack Attack Attack

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:

attack(<Type>,<Opponent Policy>, <unit>)

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.


In code (how to creat one)

CommandDSL ast_example = new CommandDSL("attack(Worker,closest)");

By translate method

ast_example.translate() --> print in Java console--> attack(Worker,closest)

By friendly translate method

ast_example.friendly_translate() --> print in Java console--> attack(Worker,closest)

By formated Structured DSL Tree Pre-Order Print method

BuilderDSLTreeSingleton.formatedStructuredDSLTreePreOrderPrint((iNodeDSLTree) ast_example); --> print in Java console--> c->attack(Worker,closest)

Clone this wiki locally