Class MoveAction

    • Field Detail

      • PARAMETER_DIRECTION

        public static final java.lang.String PARAMETER_DIRECTION
        The move direction parameter.
        See Also:
        Constant Field Values
      • PROPERTY_LASTPOS

        public static final java.lang.String PROPERTY_LASTPOS
        The last position property (only for hunters).
        See Also:
        Constant Field Values
      • DIRECTION_LEFT

        public static final java.lang.String DIRECTION_LEFT
        The move direction left.
        See Also:
        Constant Field Values
      • DIRECTION_RIGHT

        public static final java.lang.String DIRECTION_RIGHT
        The move direction right.
        See Also:
        Constant Field Values
      • DIRECTION_UP

        public static final java.lang.String DIRECTION_UP
        The move direction up.
        See Also:
        Constant Field Values
      • DIRECTION_DOWN

        public static final java.lang.String DIRECTION_DOWN
        The move direction down.
        See Also:
        Constant Field Values
      • DIRECTION_NONE

        public static final java.lang.String DIRECTION_NONE
        Placeholder for "no move" action.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MoveAction

        public MoveAction()
    • Method Detail

      • perform

        public java.lang.Object perform​(java.util.Map parameters,
                                        IEnvironmentSpace space)
        Performs the action.
        Specified by:
        perform in interface ISpaceAction
        Parameters:
        parameters - parameters for the action
        space - the environment space
        Returns:
        action return value
      • getDirection

        public static java.lang.String getDirection​(Grid2D space,
                                                    IVector2 sourcepos,
                                                    IVector2 targetpos)
        Get the best way to go towards a direction.
        Parameters:
        space - The 2D space to move in.
        sourcepos - The source position.
        targetpos - The target position.
        Returns:
        The way to go (if any).
      • getAvoidanceDirection

        public static java.lang.String getAvoidanceDirection​(Grid2D space,
                                                             IVector2 sourcepos,
                                                             ISpaceObject[] objects)
        Move to stay away from the given objects.
        Parameters:
        space - The 2D space to move in.
        sourcepos - The source position.
        objects - The objects to avoid.
        Returns:
        The direction to go ('none', if no move at all is better than moving in any direction).
      • evaluateMoves

        public static java.lang.String evaluateMoves​(Grid2D space,
                                                     IVector2 sourcepos,
                                                     MoveAction.IMoveEvaluator eval)
        Get the best move.
        Parameters:
        space - The 2D space to move in.
        sourcepos - The source position.
        eval - The move evaluator.
        Returns:
        The direction to go ('none', if no move at all is better than moving in any direction).
      • getPossibleDirections

        public static java.lang.String[] getPossibleDirections​(Grid2D space,
                                                               IVector2 sourcepos)
        Get the possible moves.
        Parameters:
        space - The 2D space to move in.
        sourcepos - The source position.
        Returns:
        The directions to go (i.e. all possible directions excluding 'none' or an array with only 'none').