/** Returns the best move to make from here during a playout. */ short bestSearchMove(SearchNode node, McRunnable runnable) { final Board runnableBoard = runnable.getBoard(); final MersenneTwisterFast random = runnable.getRandom(); short result = node.getWinningMove(); if (result != NO_POINT && runnableBoard.isLegal(result)) { // The isLegal() check is necessary to avoid superko violations return result; } float bestSearchValue = searchValue(node, PASS); result = PASS; final ShortSet vacantPoints = runnableBoard.getVacantPoints(); int start; start = random.nextInt(vacantPoints.size()); int i = start; final int skip = PRIMES[random.nextInt(PRIMES.length)]; do { final short move = vacantPoints.get(i); final float searchValue = searchValue(node, move); if (searchValue > bestSearchValue) { if (runnable.isFeasible(move) && runnableBoard.isLegal(move)) { bestSearchValue = searchValue; result = move; } else { node.exclude(move); } } // Advancing by a random prime skips through the array // in a manner analogous to double hashing. i = (i + skip) % vacantPoints.size(); } while (i != start); return result; }