Package pdp.scrabble.game

Examples of pdp.scrabble.game.Location


    {
  return charTab[loc.getV()][loc.getH()];
    }
   
    public boolean hasNeighbours(Location square, Direction dir) {
  Location prev=dir.applyReverseTo(square.clone()), next=dir.applyTo(square.clone());
  return (contains(prev) && !isFree(prev)) ||
    (contains(next) && !isFree(next));
    }
View Full Code Here


  model.update(board);
  allowedLetters[Direction.ACROSS.ordinal()].compute(Direction.DOWN);
  allowedLetters[Direction.DOWN.ordinal()].compute(Direction.ACROSS);

  if (model.isFree(Board.HORI_DIM/2, Board.VERT_DIM/2)) { // cas du premier coup : le centre est vide et doit etre couvert par le coup
      Location start = new LocationImpl(Board.HORI_DIM/2, Board.VERT_DIM/2);
      generateForSquare(Direction.ACROSS, start, model, letters);
      generateForSquare(Direction.DOWN, start, model, letters);
  }
  else {
      generate(Direction.ACROSS,letters);
View Full Code Here

  for (int i=0 ; i<Board.VERT_DIM ; i++)
      generateForRow(dir, i, model, letters);
    }

    private void generateForRow(Direction dir, int row, AIBoardModel board, Rack letters) {
  Location square = (dir.equals(Direction.ACROSS) ? new LocationImpl(row, 0) : new LocationImpl(0, row));
  while (board.contains(square)) {
      if(board.isAnchorSquare(square.getV(), square.getH()))
    generateForSquare(dir, square, board, letters);
      dir.applyTo(square);
  }
    }
View Full Code Here

      dir.applyTo(square);
  }
    }

    private void generateForSquare(Direction dir, Location square, AIBoardModel board, Rack letters) {
  Location prev = dir.applyReverseTo(square.clone());
  if (board.contains(prev) &&
    !board.isFree(prev)) {
      // must compute prefix word and find corresponding node in dawg
      StringBuilder str = new StringBuilder();
      int node = dawg.getRoot();
      Location prefix = dir.applyReverseTo(square.clone());
      while (board.contains(prefix) && !board.isFree(prefix)) {
    str.append(board.getCharAt(prefix));
    dir.applyReverseTo(prefix);
      }
      str.reverse();
View Full Code Here

      build.append(l.getName());
  registerMove(new ClassicMoveModel(word, first, dir, build.toString()));
    }

    private int getLeftPartMaxLength(AIBoardModel board, Location square, Direction dir) {
  Location prev = dir.applyReverseTo(square.clone());
  if (!board.contains(prev) ||
    model.isAnchorSquare(prev.getV(), prev.getH())) return 0;
  return getLeftPartMaxLength(board, prev, dir)+1;
    }
View Full Code Here

    AIBoardModel aiBoard = new AIBoardModel(board);
    for(int x =0; x<Board.HORI_DIM; x++)
      for(int y= 0; y<Board.VERT_DIM;y++)
        if(aiBoard.isAnchorSquare(x,y)){
          int posRelative = 0;
          Location posAbs = new LocationImpl(y,x);
          generate_aux(aiBoard,posRelative,posAbs,"",letters, gaddag.getTop());
        }
  }
View Full Code Here

      for (int j=0 ; j<Board.HORI_DIM ; j++)
    crossChecks[i][j] = new CrossCheck();
    }
   
    private Location beginingOfWord(Location square, Direction dir) {
  Location prev = dir.applyReverseTo(square.clone());
  if (!model.contains(prev) || model.isFree(prev))
      return square;
  else
      return beginingOfWord(prev, dir);
    }
View Full Code Here

  }
 
  // to compute for anchor square, we need to get back to the beggining of the word
  // and check for each letter if it forms a valid word
  else {
      Location currentSquare = beginingOfWord(square, dir);
      int currentNode = dawg.getRoot();
      while (!model.isFree(currentSquare)) {
    currentNode = dawg.getChild(currentNode, model.getCharAt(currentSquare));
    dir.applyTo(currentSquare);
      }
      for (Character c : Bag.AVAILABLE_LETTERS) {
    computeSquareForLetter(currentSquare.clone(), dir, currentNode, c);
      }
     
  }
    }
View Full Code Here

  return this.dir;
    }

    @Override
    public void play(Board board, Player p) {
  Location currentLoc = this.first.clone();
  for (int i=0 ; i<this.word.length() ; i++) {
      char c = this.word.charAt(i);
      if (board.isFree(currentLoc.getH(), currentLoc.getV())) {
    Letter currentLetter = null;
    if (Character.isLowerCase(c)) {
        currentLetter = p.getRack().getLetter(Bag.JOKER);
        p.getRack().removeLetter(currentLetter);
        currentLetter.setJokerChar(Character.toUpperCase(c));
    }
    else {
        currentLetter = p.getRack().getLetter(c);
        p.getRack().removeLetter(currentLetter);
    }
    board.setCaseLetter(currentLoc.getV(), currentLoc.getH(), currentLetter, true);
      }
      this.dir.applyTo(currentLoc);
  }
    }
View Full Code Here

TOP

Related Classes of pdp.scrabble.game.Location

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.