示例#1
0
  /** Let the computer player take its turn. */
  public void computerPlay() {
    computerArea.setName("Thinking!");
    computerArea.paintImmediately(computerArea.getVisibleRect());
    int minLength = myBoardSize == 4 ? 3 : 4;
    computerPlayer.findAllValidWords(myBoard, myLexicon, minLength);

    computerArea.setName("Computer");
    for (String s : computerPlayer) {
      computerArea.showWord(s, myFinder.cellsForWord(myBoard, s), computerPlayer);
    }
    myBoardPanel.unHighlightAllDice(); // leave board unhighlighted when
    // done
  }
  @Override
  public void findAllValidWords(BoggleBoard board, ILexicon lex, int minLength) {

    clear();
    for (String word : lex) {
      if (word.length() < minLength) continue;
      List<BoardCell> list = myFinder.cellsForWord(board, word);
      if (list.size() > 0) {
        // found word
        add(word);
      }
    }
  }