Package maze.model

Examples of maze.model.MazeCell


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


   private void modifiedFloodfill()
   {
      //Dimension size = maze.getSize();
      Vector<MazeCell> queue = new Vector<MazeCell>();
      Vector<MazeCell> badQueue = new Vector<MazeCell>();
      MazeCell cell;
      MazeCell here = robotLocation.getCurrentLocation();
      int currentDistance;
      boolean speedy;

      if ( (goal == TO_CENTER) && (speedRun == true) && (speedRunCapable == true))
      {
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

    */
   public RobotController(MazeModel model, RobotBase robotAI)
   {
      this.mazeModel = model;
      this.ai = robotAI;
      final MazeCell start = MazeCell.valueOf(1, this.mazeModel.getSize().height);
      this.robotModelMaster = new RobotModelMaster(this.mazeModel, start, Direction.North);
      this.robotModelClient = new RobotModel(this.robotModelMaster);
      this.initialize();
   }
View Full Code Here

    */
   private Direction getNeighborDirection(Direction direction)
   {
      try
      {
         final MazeCell there = robotLocation.getCurrentLocation().neighbor(direction);
         if (!there.isInRange(robotLocation.getMazeSize()))
            return null;
         else
            return this.getDirection(there);
      }
      catch (IllegalArgumentException e)
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

    * Returns the explored flag of the current location's neighbor in the given
    * direction.
    */
   private boolean getNeighborExplored(Direction direction)
   {
      MazeCell neighbor;
      MazeCell here = robotLocation.getCurrentLocation();
      Dimension size = maze.getSize();
      if ( (direction == Direction.North) && (here.getY() != 1))
      {
         neighbor = MazeCell.valueOf(here.getX(), here.getY() - 1);
      }
      else if ( (direction == Direction.South) && (here.getY() != size.getHeight()))
      {
         neighbor = MazeCell.valueOf(here.getX(), here.getY() + 1);
      }
      else if ( (direction == Direction.East) && (here.getX() != size.getWidth()))
      {
         neighbor = MazeCell.valueOf(here.getX() + 1, here.getY());
      }
      else if ( (direction == Direction.West) && (here.getX() != 1))
      {
         neighbor = MazeCell.valueOf(here.getX() - 1, here.getY());
      }
      else
      {
         return false;
      }
View Full Code Here

   /**
    * Returns the explored flag of the given location's neighbor.
    */
   private boolean getNeighborExplored(MazeCell here, Direction direction)
   {
      MazeCell neighbor;
      Dimension size = maze.getSize();
      if ( (direction == Direction.North) && (here.getY() != 1))
      {
         neighbor = MazeCell.valueOf(here.getX(), here.getY() - 1);
      }
View Full Code Here

    * MazeCell. This algorithm biases in the following order: Straight, North,
    * East, West, South
    */
   private Direction getBestDirection()
   {
      MazeCell here = robotLocation.getCurrentLocation();
      int bestDistance = getDistance(here);
      Direction bestDirection = null;

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

    * Returns the distance of the MazeCell adjacent to the passed MazeCell and
    * is adjacent in the specified direction.
    */
   private int getNeighborDistance(MazeCell here, Direction direction)
   {
      MazeCell neighbor;
      Dimension size = maze.getSize();
      if ( (direction == Direction.North) && (here.getY() != 1))
      {
         neighbor = MazeCell.valueOf(here.getX(), here.getY() - 1);
      }
View Full Code Here

TOP

Related Classes of maze.model.MazeCell

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.