Player { public short bestMove() { stopThreads(); final short move = book.nextMove(board); if (move != NO_POINT) { return move; } if (cleanupMode) { if (!findCleanupMoves()) { return PASS; } } else if (board.getPasses() == 1 && coupDeGrace) { if (canWinByPassing()) { return PASS; } findCleanupMoves(); } if (!timeLeftWasSent) { startThreads(); try { Thread.sleep(msecPerMove); } catch (final InterruptedException e) { e.printStackTrace(); System.exit(1); } stopThreads(); } else { timeManager.startNewTurn(); msecPerMove = timeManager.getMsec(); log("Allocating " + msecPerMove + " msec"); do { startThreads(); try { Thread.sleep(msecPerMove); } catch (final InterruptedException e) { e.printStackTrace(); System.exit(1); } stopThreads(); msecPerMove = timeManager.getMsec(); } while (msecPerMove > 0); } long playouts = 0; for (McRunnable runnable : runnables) { playouts += runnable.getPlayoutsCompleted(); } Logging.log("Turn : " + board.getTurn() + " Playouts : " + playouts); return descender.bestPlayMove(); } Player(int threads, CopiableStructure stuff); Legality acceptMove(short point); short bestMove(); void clear(); void descend(McRunnable runnable); void endGame(); double finalScore(); ShortSet findDeadStones(double threshold, StoneColor color); Board getBoard(); FinalScorer getFinalScorer(); McRunnable getMcRunnable(int i); int getPlayoutCount(); SearchNode getRoot(); TimeManager getTimeManager(); void ponder(boolean pondering); void setCleanupMode(boolean cleanup); void setColorToPlay(StoneColor stoneColor); void setCoupDeGrace(boolean enabled); void setMsecPerMove(int msec); void setOpeningBook(OpeningBook book); void setRemainingTime(int seconds); void setTimeManager(TimeManager time); void setTreeDescender(TreeDescender descender); void setTreeUpdater(TreeUpdater updater); void setUpHandicap(int handicapSize); @SuppressWarnings("boxing") void setUpSgfGame(List<Short> moves); boolean shouldKeepRunning(); @Override String toString(); boolean undo(); void updateTree(Color winner, McRunnable mcRunnable); ShortSet getLiveStones(double threshold); @SuppressWarnings("boxing") String goguiSearchValues(); @SuppressWarnings("boxing") String goguiGetWins(); @SuppressWarnings("boxing") String goguiGetWinrate(); @SuppressWarnings("boxing") String goguiGetRuns();  }
@Test public void testTableOverflow() { player = new PlayerBuilder().msecPerMove(2000).threads(8).boardWidth(5).memorySize(1).openingBook(false).build(); player.bestMove(); }