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 SummaryNested Classes Modifier and Type Class Description static interfaceMoveAction.IMoveEvaluatorInterface for evaluating moves.
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringDIRECTION_DOWNThe move direction down.static java.lang.StringDIRECTION_LEFTThe move direction left.static java.lang.StringDIRECTION_NONEPlaceholder for "no move" action.static java.lang.StringDIRECTION_RIGHTThe move direction right.static java.lang.StringDIRECTION_UPThe move direction up.static java.lang.StringPARAMETER_DIRECTIONThe move direction parameter.static java.lang.StringPROPERTY_LASTPOSThe last position property (only for hunters).- 
Fields inherited from class jadex.commons.SimplePropertyObjectpcs, properties
 - 
Fields inherited from interface jadex.extension.envsupport.environment.ISpaceActionACTOR_ID, OBJECT_ID
 
- 
 - 
Constructor SummaryConstructors Constructor Description MoveAction()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringevaluateMoves(Grid2D space, IVector2 sourcepos, MoveAction.IMoveEvaluator eval)Get the best move.static java.lang.StringgetAvoidanceDirection(Grid2D space, IVector2 sourcepos, ISpaceObject[] objects)Move to stay away from the given objects.static java.lang.StringgetDirection(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.Objectperform(java.util.Map parameters, IEnvironmentSpace space)Performs the action.- 
Methods inherited from class jadex.commons.SimplePropertyObjectaddPropertyChangeListener, getProperties, getProperty, getPropertyNames, hasProperty, removePropertyChangeListener, setProperties, setProperty, toString
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface jadex.commons.IPropertyObjectgetProperty, getPropertyNames, hasProperty, setProperty
 
- 
 
- 
- 
- 
Field Detail- 
PARAMETER_DIRECTIONpublic static final java.lang.String PARAMETER_DIRECTION The move direction parameter.- See Also:
- Constant Field Values
 
 - 
PROPERTY_LASTPOSpublic static final java.lang.String PROPERTY_LASTPOS The last position property (only for hunters).- See Also:
- Constant Field Values
 
 - 
DIRECTION_LEFTpublic static final java.lang.String DIRECTION_LEFT The move direction left.- See Also:
- Constant Field Values
 
 - 
DIRECTION_RIGHTpublic static final java.lang.String DIRECTION_RIGHT The move direction right.- See Also:
- Constant Field Values
 
 - 
DIRECTION_UPpublic static final java.lang.String DIRECTION_UP The move direction up.- See Also:
- Constant Field Values
 
 - 
DIRECTION_DOWNpublic static final java.lang.String DIRECTION_DOWN The move direction down.- See Also:
- Constant Field Values
 
 - 
DIRECTION_NONEpublic static final java.lang.String DIRECTION_NONE Placeholder for "no move" action.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
performpublic java.lang.Object perform(java.util.Map parameters, IEnvironmentSpace space)Performs the action.- Specified by:
- performin interface- ISpaceAction
- Parameters:
- parameters- parameters for the action
- space- the environment space
- Returns:
- action return value
 
 - 
getDirectionpublic 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).
 
 - 
getAvoidanceDirectionpublic 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).
 
 - 
evaluateMovespublic 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).
 
 - 
getPossibleDirectionspublic 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').
 
 
- 
 
-