Package jadex.micro.examples.hunterprey
Class MoveAction
- java.lang.Object
-
- jadex.commons.SimplePropertyObject
-
- jadex.micro.examples.hunterprey.MoveAction
-
- All Implemented Interfaces:
IPropertyObject
,ISpaceAction
public class MoveAction extends SimplePropertyObject implements ISpaceAction
Action allowing a creature to move.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MoveAction.IMoveEvaluator
Interface for evaluating moves.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DIRECTION_DOWN
The move direction down.static java.lang.String
DIRECTION_LEFT
The move direction left.static java.lang.String
DIRECTION_NONE
Placeholder for "no move" action.static java.lang.String
DIRECTION_RIGHT
The move direction right.static java.lang.String
DIRECTION_UP
The move direction up.static java.lang.String
PARAMETER_DIRECTION
The move direction parameter.static java.lang.String
PROPERTY_LASTPOS
The last position property (only for hunters).-
Fields inherited from class jadex.commons.SimplePropertyObject
pcs, properties
-
Fields inherited from interface jadex.extension.envsupport.environment.ISpaceAction
ACTOR_ID, OBJECT_ID
-
-
Constructor Summary
Constructors Constructor Description MoveAction()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
evaluateMoves(Grid2D space, IVector2 sourcepos, MoveAction.IMoveEvaluator eval)
Get the best move.static java.lang.String
getAvoidanceDirection(Grid2D space, IVector2 sourcepos, ISpaceObject[] objects)
Move to stay away from the given objects.static java.lang.String
getDirection(Grid2D space, IVector2 sourcepos, IVector2 targetpos)
Get the best way to go towards a direction.static java.lang.String[]
getPossibleDirections(Grid2D space, IVector2 sourcepos)
Get the possible moves.java.lang.Object
perform(java.util.Map parameters, IEnvironmentSpace space)
Performs the action.-
Methods inherited from class jadex.commons.SimplePropertyObject
addPropertyChangeListener, getProperties, getProperty, getPropertyNames, hasProperty, removePropertyChangeListener, setProperties, setProperty, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jadex.commons.IPropertyObject
getProperty, getPropertyNames, hasProperty, setProperty
-
-
-
-
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
-
-
Method Detail
-
perform
public java.lang.Object perform(java.util.Map parameters, IEnvironmentSpace space)
Performs the action.- Specified by:
perform
in interfaceISpaceAction
- Parameters:
parameters
- parameters for the actionspace
- 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').
-
-