aima.core.environment.wumpusworld.action.TurnLeft Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
The newest version!
package aima.core.environment.wumpusworld.action;
import aima.core.agent.impl.DynamicAction;
import aima.core.environment.wumpusworld.AgentPosition;
/**
* Artificial Intelligence A Modern Approach (3rd Edition): page 237.
*
* The agent can TurnLeft by 90 degrees.
*
* @author Federico Baron
* @author Alessandro Daniele
* @author Ciaran O'Reilly
*/
public class TurnLeft extends DynamicAction {
public static final String TURN_LEFT_ACTION_NAME = "TurnLeft";
public static final String ATTRIBUTE_TO_ORIENTATION = "toOrientation";
//
private AgentPosition.Orientation toOrientation;
/**
* Constructor.
*
* @param currentOrientation
*/
public TurnLeft(AgentPosition.Orientation currentOrientation) {
super(TURN_LEFT_ACTION_NAME);
switch (currentOrientation) {
case FACING_NORTH:
toOrientation = AgentPosition.Orientation.FACING_WEST;
break;
case FACING_SOUTH:
toOrientation = AgentPosition.Orientation.FACING_EAST;
break;
case FACING_EAST:
toOrientation = AgentPosition.Orientation.FACING_NORTH;
break;
case FACING_WEST:
toOrientation = AgentPosition.Orientation.FACING_SOUTH;
break;
}
setAttribute(ATTRIBUTE_TO_ORIENTATION, toOrientation);
}
/**
*
* @return the orientation the agent should be after the action occurred.
* Note: this may not be a legal orientation within the
* environment in which the action was performed and this should be
* checked for.
*/
public AgentPosition.Orientation getToOrientation() {
return toOrientation;
}
}