DurativePlanner

public class DurativePlanner implements Serializable

An implementation of basic planning methods extended to the case of actions that take time to act.

Constructors

DurativePlanner

public DurativePlanner(State state)

Methods

calculateAttackDuration

public static int calculateAttackDuration(Unit u, Unit target)

This is a temporary debug method, remove it when you are done

calculateDepositDuration

public static int calculateDepositDuration(Unit u, Unit townhall)

Calculate the duration of a

Parameters:
  • u
  • townhall

calculateGatherDuration

public static int calculateGatherDuration(Unit u, ResourceNode target)

A simple calculation for determining the amount

Parameters:
  • u
  • target

calculateMaxMoveDuration

public static int calculateMaxMoveDuration(Unit u)
Calculate the maximum move possible for a Unit.
These values must tie to
Parameters:
  • u – The unit whose maximum move we are probing.

calculateMoveDuration

public static int calculateMoveDuration(Unit u, int startingx, int startingy, Direction d)
Calculate the move duration for a unit.
These values must tie to
Parameters:
  • u
  • startingx
  • startingy
  • d

calculateProductionDuration

public static int calculateProductionDuration(Unit u, Template t)

This is a temporary debug method, remove it when you are done

getDirections

public MovePlan getDirections(Unit u, int startingx, int startingy, int endingx, int endingy, int tolerancedistance, boolean isFirstMove)
Uses A* to calculate the directions to arrive at the specified
location.
Returns a path if and only if there is a valid path.
When you wish upon A* ...
Parameters:
  • u – The unit being moved. Necessary for calculating durative actions
  • startingx
  • startingy
  • endingx
  • endingy
  • tolerancedistance – The distance at which to stop trying to seek (IE, 0 is on top of it, 1 is next to it, etc) Note that the distance should count diagonals as 1 dist
  • isFirstMove – Whether this is the first move in a larger plan (and thus that the current progress toward a move should be included)
Returns:

A move plan with the success, path, and final x and y coordinates.

planAttack

public LinkedList<Action> planAttack(Unit actor, Unit target)

Uses getDirections(StateView,int,int,int,int,int,boolean) to get directions to the specified place and planMove(Unit,LinkedList) to follow them. then adds an attack command.

Parameters:
  • actor
  • target
Returns:

A series of actions that move the actor to the target and attacks the target

planAttack

public LinkedList<Action> planAttack(int actor, int target)

planBuild

public LinkedList<Action> planBuild(Unit actor, int targetX, int targetY, UnitTemplate template)

Plan a compound build action in which the unit moves to a target and then

Parameters:
  • actor
  • targetX
  • targetY
  • template

planBuild

public LinkedList<Action> planBuild(int actor, int targetX, int targetY, int template)

planDeposit

public LinkedList<Action> planDeposit(Unit actor, Unit target)

Plan a compound deposit action in which the unit moves next to the target town hall and then deposits into it

Parameters:
  • actor
  • target
  • distance

planDeposit

public LinkedList<Action> planDeposit(int actor, int target)

planFail

public LinkedList<Action> planFail(int actor)

planGather

public LinkedList<Action> planGather(Unit actor, ResourceNode target)

Plan a compound gather action in which the unit moves next to the target node and then gathers from it.

Parameters:
  • actor
  • target
Returns:

A series of actions that move the actor to the target and gathers from the target

planGather

public LinkedList<Action> planGather(int actor, int target)

planMove

public LinkedList<Action> planMove(Unit actor, int x, int y)

Uses getDirections(int,int,int,int,int,boolean) to get directions to the specified place and planMove(Unit,LinkedList) to follow them.

Parameters:
  • actor
  • x
  • y

planMove

public LinkedList<Action> planMove(int i, int x, int y)

planPermanentFail

public LinkedList<Action> planPermanentFail(int actor)

planProduce

public LinkedList<Action> planProduce(Unit actor, Template template)

planProduce

public LinkedList<Action> planProduce(int actor, int template)