Package maze.model

Examples of maze.model.Direction


    */
   @Override
   public RobotStep nextStep()
   {
      RobotStep next;
      Direction nextDirection;
      Direction currentDirection = robotLocation.getDirection();
      if (moveQueue.isEmpty())
      {
         if (getExplored() == false)
         {
            checkWalls();
            setExplored();
         }
         if (atGoal() == true)
         {
            if ( (goal == TO_CENTER) && (speedRunCapable == false))
            {
               speedRunCapable = true;
               blockOutCenter();
            }
            goal = !goal;
            floodfill();
         }
         nextDirection = getBestDirection();
         turbo = getNeighborExplored(nextDirection);
         if (nextDirection == currentDirection)
         {
            next = RobotStep.MoveForward;
         }
         else if (nextDirection == currentDirection.getLeft())
         {
            next = RobotStep.RotateLeft;
            moveQueue.add(RobotStep.MoveForward);
         }
         else if (nextDirection == currentDirection.getRight())
         {
            next = RobotStep.RotateRight;
            moveQueue.add(RobotStep.MoveForward);
         }
         else
View Full Code Here


    * East, West, South
    */
   private Direction getBestDirection()
   {
      MazeCell here = robotLocation.getCurrentLocation();
      Direction current = robotLocation.getDirection();
      //int bestDistance = getDistance(here);
      Direction bestDirection = null;

      if (hasSameDirection(here, Direction2.getDirection(current)))
      //&& (robotLocation.isWallFront() == false))
      {
         bestDirection = current;
View Full Code Here

    * 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()));
      }
   }
View Full Code Here

         //Goals are not poisoned
         return false;
      }

      MazeCell here;
      Direction whereFrom = dir.getOpposite();

      if (dir.equals(Direction.North))
      {
         here = cell.plusY(-1);
      }
View Full Code Here

   /**
    * This sets the direction for the understanding for the current cell.
    */
   private void setDirection()
   {
      Direction wayBack = robotLocation.getDirection().getOpposite();
      MazeCell here = robotLocation.getCurrentLocation();
      ballOfString[here.getX() - 1][here.getY() - 1] = wayBack;
   }
View Full Code Here

    */
   @Override
   public RobotStep nextStep()
   {
      RobotStep next;
      Direction nextDirection;
      Direction currentDirection = robotLocation.getDirection();
      if (moveQueue.isEmpty())
      {
         if (getExplored() == false)
         {
            checkWalls();
            setExplored();
         }
         if (atGoal() == true)
         {
            if ( (goal == TO_CENTER) && (speedRunCapable == false))
            {
               speedRunCapable = true;
               blockOutCenter();
            }
            goal = !goal;
            floodfill();
         }
         nextDirection = getBestDirection();
         turbo = getNeighborExplored(nextDirection);
         if (nextDirection == currentDirection)
         {
            next = RobotStep.MoveForward;
         }
         else if (nextDirection == currentDirection.getLeft())
         {
            next = RobotStep.RotateLeft;
            moveQueue.add(RobotStep.MoveForward);
         }
         else if (nextDirection == currentDirection.getRight())
         {
            next = RobotStep.RotateRight;
            moveQueue.add(RobotStep.MoveForward);
         }
         else
View Full Code Here

    */
   private Direction getBestDirection()
   {
      MazeCell here = robotLocation.getCurrentLocation();
      int bestDistance = getDistance(here);
      Direction bestDirection = null;

      if ( (bestDistance > getNeighborDistance(here, robotLocation.getDirection())) &&
          (robotLocation.isWallFront() == false))
      {
         bestDirection = robotLocation.getDirection();
View Full Code Here

    * 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 (robotLocation.isWallLeft())
      {
         maze.setWall(cell.getX(), cell.getY(), direction.getLeft().getIndex());
      }
      if (robotLocation.isWallRight())
      {
         maze.setWall(cell.getX(), cell.getY(), direction.getRight().getIndex());
      }
      if (robotLocation.isWallBack())
      {
         maze.setWall(cell.getX(), cell.getY(), direction.getOpposite().getIndex());
      }
   }
View Full Code Here

      {
         try
         {
            //Get the robots current position.
            final Point srcLocation = this.view.getCellCenterInner(model.getCurrentLocation());
            final Direction srcDirection = model.getDirection();
            final double srcRotation = srcDirection.getRadians();

            robot.nextStep(); //Move robot.

            //Get the robots new position.
            final Point destLocation = this.view.getCellCenterInner(model.getCurrentLocation());
            final Direction destDirection = model.getDirection();
            //Set our new rotation based on which way we turned.
            final double destRotation;
            if (srcDirection.getLeft() == destDirection)
               destRotation = srcRotation - Math.PI / 2;
            else if (srcDirection.getRight() == destDirection)
View Full Code Here

            }
         }
      }
      else if (understandingDir != null)
      {
         Direction local;
         for (int i = 1; i <= model.getSize().width; i++)
         {
            for (int j = 1; j <= model.getSize().height; j++)
            {
               here = MazeCell.valueOf(i, j);
View Full Code Here

TOP

Related Classes of maze.model.Direction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.