コード例 #1
0
ファイル: BoggleGUI.java プロジェクト: nv23/Boggle
  /** Get ready for a new game, given a letter list specification of the Boggle board. */
  public void newGame() {
    myBoard = BoggleBoardFactory.getBoard(myBoardSize);
    mySeconds = 0;
    myProgress.setValue(0);

    // set up views for new game

    if (myBoardSize == 4) {
      if (myBoardPanel != myBoardPanel4) {
        myBoardPanel = myBoardPanel4;
        getContentPane().remove(myBoardPanel5);
        getContentPane().add(myBoardPanel, BorderLayout.CENTER);
      }
    } else {
      if (myBoardPanel != myBoardPanel5) {
        myBoardPanel = myBoardPanel5;
        getContentPane().remove(myBoardPanel4);
        getContentPane().add(myBoardPanel, BorderLayout.CENTER);
      }
    }

    myBoardPanel.newGame();
    humanArea.setReady();
    computerArea.setReady();
    myBoardPanel.unHighlightAllDice();
    wordEntryField.setReady();
    ((JPanel) getContentPane()).revalidate();
    repaint();
    myTimer.start();
  }
コード例 #2
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);
  }