コード例 #1
0
ファイル: BoggleStats.java プロジェクト: jessehu-uho/Boggle
  public String wordTester(IAutoPlayer player, ILexicon lex, ArrayList<Integer> log, int count) {

    BoggleBoardFactory.setRandom(new Random(12345));
    log.clear();
    double start = System.currentTimeMillis();
    int hiScore = 0;
    BoggleBoard hiBoard = null;
    for (int k = 0; k < count; k++) {
      BoggleBoard board = BoggleBoardFactory.getBoard(5);
      player.clear();
      player.findAllValidWords(board, lex, MIN_WORD);
      log.add(player.getScore());
      if (player.getScore() > hiScore) {
        hiScore = player.getScore();
        hiBoard = board;
      }
    }

    double end = System.currentTimeMillis();
    int max = Collections.max(log);
    return String.format(
        "%s %s\t count: %d\tmax: %d\ttime: %f" + hiBoard.toString(),
        player.getClass().getName(),
        lex.getClass().getName(),
        count,
        max,
        (end - start) / 1000.0);
  }
コード例 #2
0
ファイル: BoggleGUI.java プロジェクト: nv23/Boggle
  /** 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
  }
コード例 #3
0
ファイル: BoggleGUI.java プロジェクト: nv23/Boggle
 private void initPlayers(IAutoPlayer compPlayer) {
   computerPlayer = compPlayer;
   computerPlayer.setView(computerArea);
   humanPlayer = new HumanPlayer("Human");
   humanPlayer.setView(humanArea);
 }