* Updates the algorithm's memory of the maze based upon the walls in the
* current cell.
*/
private void checkWalls()
{
MazeCell cell = robotLocation.getCurrentLocation();
Direction direction = robotLocation.getDirection();
if (robotLocation.isWallFront())
{
maze.setWall(cell.getX(), cell.getY(), direction.getIndex());
if (hasSameDirection(cell, Direction2.getDirection(direction)))
{
setDirection(cell, getDirection(cell) ^ Direction2.getDirection(direction).getIndex());
}
}
if (robotLocation.isWallLeft())
{
maze.setWall(cell.getX(), cell.getY(), direction.getLeft().getIndex());
setDirection(cell,
getDirection(cell) &
(Direction2.Mask.getIndex() ^ Direction2.getDirection(direction.getLeft()).getIndex()));
}
if (robotLocation.isWallRight())
{
maze.setWall(cell.getX(), cell.getY(), direction.getRight().getIndex());
setDirection(cell,
getDirection(cell) &
(Direction2.Mask.getIndex() ^ Direction2.getDirection(direction.getRight()).getIndex()));
}
if (robotLocation.isWallBack())
{
maze.setWall(cell.getX(), cell.getY(), direction.getOpposite().getIndex());
setDirection(cell,
getDirection(cell) &
(Direction2.Mask.getIndex() ^ Direction2.getDirection(direction.getOpposite()).getIndex()));
}
}