ShapeUpdater implements TreeUpdater { @Override public void updateTree(Color winner, McRunnable runnable) { updater.updateTree(winner, runnable); if (winner != VACANT) { Board playerBoard = runnable.getPlayer().getBoard(); boolean win = winner == playerBoard.getColorToPlay(); int turn = runnable.getTurn(); Board board = runnable.getBoard(); HistoryObserver history = new HistoryObserver(board.getCoordinateSystem()); history.copyDataFrom(runnable.getHistoryObserver()); board.copyDataFrom(playerBoard); int k = 0; for (int t = playerBoard.getTurn(); t < turn; t++) { if (k == 20) { break; } k++; short p = history.get(t); long hash = PatternFinder.getHash(board, p, 3, history.get(t - 1)); shapeTable.update(hash, win); board.play(p); win = !win; } } } ShapeUpdater(TreeUpdater updater, ShapeTable shapeTable); @Override void clear(); @Override int getGestation(); @Override SearchNode getRoot(); @Override void updateForAcceptMove(); @Override void updateTree(Color winner, McRunnable runnable); ShapeTable getTable();  }
@Test public void testUpdateTree() { McRunnable runnable = player.getMcRunnable(0); Board board = runnable.getBoard(); runnable.acceptMove(coords.at("a1")); runnable.acceptMove(coords.at("b1")); long hash = PatternFinder.getHash(board, coords.at("c1"), 3, coords.at("b1")); double before = table.getWinRate(hash); runnable.acceptMove(coords.at("c1")); updater.updateTree(BLACK, runnable); runnable.copyDataFrom(player.getBoard()); runnable.acceptMove(coords.at("a1")); runnable.acceptMove(coords.at("b1")); hash = PatternFinder .getHash(board, coords.at("c1"), 3, coords.at("b1")); double after = table.getWinRate(hash); assertTrue(after > before); }