Examples of MazeSpace


Examples of br.com.ema.maze.components.MazeSpace

     
      String line = fileLines.get(y);
     
      for (int x = 0; x < line.length(); x++) {
        char symbol = line.charAt(x);
        MazeSpace space = createSpace(symbol, x, y);
        maze.addSpace( space );
        if (symbol == 'E'){
          mazeConfiguration.setExitCoordinates(new Coordinates(x, y));
        }else if (symbol == 'S'){
          mazeConfiguration.setStartCoordinates(new Coordinates(x, y));
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

    updater.updateNearby(maze)
  }


  private MazeSpace createSpace(char symbol, int x, int y){
    MazeSpace result = new MazeSpace(x, y);

    switch (symbol) {
    case 'W':
      result.setDecoration(new MazeWall());
      break;
    }
   
    return result;
  }
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

  @Override
  public void executeStrategy(MazeCharacter mazeCharacter) {
    /*
     * get the destination and the actual space
     */
    MazeSpace destination = mazeCharacter.getDestination();
    if (destination == null) return;
    MazeSpace actualSpace = mazeCharacter.getActualSpace();
    if (actualSpace == null) return;

    /*
     * calculates the next step
     */
    MazeSpace newSpace = actualSpace.getMinOriginalRoute(mazeCharacter, destination, memoryInMiliseconds);
    if (newSpace == null) return;

    /*
     * update the actual step
     */
    actualSpace.removeCharacter(mazeCharacter);

    /*
     * setup the new step
     */
    mazeCharacter.setActualSpace(newSpace);
    newSpace.putCharacter(mazeCharacter);


  }
 
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

  @Override
  public void executeStrategy(MazeCharacter mazeCharacter) {
    /*
     * get the destination and the actual space
     */
    MazeSpace destination = mazeCharacter.getDestination();
    MazeSpace actualSpace = mazeCharacter.getActualSpace();
   
    /*
     * calculates the next step
     */
   
    MazeSpace newSpace = actualSpace.getMinRoute(destination);
   
    /*
     * update the actual step
     */
    actualSpace.removeCharacter(mazeCharacter);
   
    /*
     * setup the new step
     */
    mazeCharacter.setActualSpace(newSpace);
    if (newSpace != null){
      newSpace.putCharacter(mazeCharacter);
    }
  }
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

    int height = maze.getHeight();
    int width = maze.getWidth();
   
    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        MazeSpace space = maze.getSpace( x, y );
        if (space != null){
          space.addNearbySpace(maze.getSpace(x, y-1), Direction.NORTH);
          space.addNearbySpace(maze.getSpace(x, y+1), Direction.SOUTH);
          space.addNearbySpace(maze.getSpace(x+1, y), Direction.EAST);
          space.addNearbySpace(maze.getSpace(x-1, y), Direction.WEST);
        }
      }
    }
  }
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

 

  private void createSpaces(MazeParameters parameters, Maze maze) {
    for (int y = 0; y < parameters.getHeight(); y++) {
      for (int x = 0; x < parameters.getWidth(); x++) {
        maze.addSpace( new MazeSpace(x, y) );
      }
    }
  }
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

    int spacesQuantity = parameters.getWidth() * parameters.getHeight();
    double percentage = parameters.getWallPercentage() / 100D;
    int wallsQuantity = (int) (spacesQuantity * percentage);
    int wallsSetted = 0;
    while(wallsSetted < wallsQuantity){
      MazeSpace space = null;
      do {
        int y = (int)(Math.random() * parameters.getHeight());
        int x = (int)(Math.random() * parameters.getWidth());
        space = maze.getSpace(x, y);
       
      } while ((space.getDecoration() != null && space.getDecoration() instanceof MazeWall));
     
      space.setDecoration(new MazeWall());
      wallsSetted ++;
    }
  }
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

   
    Maze maze = factory.buildMaze(parameters );
   
    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        MazeSpace mazeSpace = maze.getSpace(x, y);
        assertNotNull( mazeSpace );
      }
    }
  }
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

    int wallPercentage = 0;
    MazeParameters parameters = new MazeParameters(width, height, wallPercentage, 0, new Coordinates(0, 0), new Coordinates(0, 0));
   
    Maze maze = factory.buildMaze(parameters );

    MazeSpace space00 = maze.getSpace(0, 0);
    MazeSpace space01 = maze.getSpace(0, 1);
    MazeSpace space10 = maze.getSpace(1, 0);
    MazeSpace space11 = maze.getSpace(1, 1);
    MazeSpace space20 = maze.getSpace(2, 0);
    MazeSpace space21 = maze.getSpace(2, 1);
   
    /*
     * 00 | 10 | 20
     * 01 | 11 | 21
     */
 
View Full Code Here

Examples of br.com.ema.maze.components.MazeSpace

    Maze maze = factory.buildMaze(parameters );
   
    int walls = 0;
    for (int y = 0; y < height; y++) {
      for (int x = 0; x < width; x++) {
        MazeSpace mazeSpace = maze.getSpace(x, y);
        if (mazeSpace.getDecoration() != null && mazeSpace.getDecoration() instanceof MazeWall){
          walls ++;
        }
      }
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.