/** Some nodes may have their biases updated. */ @Override public void descend(McRunnable runnable) { SearchNode node = getRoot(); assert node != null : "Fancy hash code: " + board.getFancyHash(); while (runnable.getBoard().getPasses() < 2) { selectAndPlayMove(node, runnable); final SearchNode child = table.findIfPresent(runnable.getBoard().getFancyHash()); if (child == null) { return; // No child } if (child.getTotalRuns() > biasDelay && !child.biasUpdated()) { child.updateBias(runnable); } node = child; } }
@Override public void fakeDescend(McRunnable runnable, short... moves) { runnable.copyDataFrom(board); final SearchNode node = getRoot(); assert node != null : "Fancy hash code: " + board.getFancyHash(); for (final short move : moves) { System.out.println("Passing " + move + " to runnable"); runnable.acceptMove(move); final SearchNode child = table.findIfPresent(runnable.getBoard().getFancyHash()); if (child == null) { return; // No child } if (child.getTotalRuns() > biasDelay && !child.biasUpdated()) { child.updateBias(runnable); } } }
/** Returns the root node (creating it if necessary). */ SearchNode getRoot() { return table.findOrAllocate(board.getFancyHash()); }
/** Copies data from that (the player's real board) to the local board. */ public void copyDataFrom(Board that) { board.copyDataFrom(that); fancyHashes[board.getTurn()] = board.getFancyHash(); }
/** * Accepts (plays on on this McRunnable's own board) the given move. * * @see edu.lclark.orego.core.Board#play(short) */ public void acceptMove(short p) { final Legality legality = board.play(p); assert legality == OK : "Legality " + legality + " for move " + coords.toString(p) + "\n" + board; fancyHashes[board.getTurn()] = board.getFancyHash(); }