Player { public boolean undo() { if (board.getTurn() == 0) { return false; } final boolean alreadyRunning = keepRunning; stopThreads(); final ShortList movesList = new ShortList(board.getCoordinateSystem() .getMaxMovesPerGame()); for (int i = 0; i < historyObserver.size() - 1; i++) { movesList.add(historyObserver.get(i)); } board.clearPreservingInitialStones(); updater.clear(); for (int i = 0; i < movesList.size(); i++) { board.play(movesList.get(i)); } if (alreadyRunning) { startThreads(); } return true; } 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 testUndo() { String[] before = { ".....", "..O..", ".....", "..#..", ".....", }; player.clear(); assertFalse(player.undo()); player.getBoard().setUpProblem(before, BLACK); player.acceptMove(at("e3")); long fancyHash = player.getBoard().getFancyHash(); player.acceptMove(at("e1")); assertTrue(player.undo()); assertEquals(fancyHash, player.getBoard().getFancyHash()); String[] after = { ".....", "..O..", "....#", "..#..", ".....", }; assertEquals(asOneString(after), player.getBoard().toString()); }