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); }
/** 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 }
private void initPlayers(IAutoPlayer compPlayer) { computerPlayer = compPlayer; computerPlayer.setView(computerArea); humanPlayer = new HumanPlayer("Human"); humanPlayer.setView(humanArea); }