@Override public short bestPlayMove() { double mostWins = 1; short result = PASS; final ShortSet vacantPoints = board.getVacantPoints(); final SearchNode root = getRoot(); do { mostWins = root.getWins(PASS); // If the move chosen on the previous pass through this loop was // illegal (e.g., because it was never actually tried in a playout), // throw it out if (result != PASS) { log("Rejected " + board.getCoordinateSystem().toString(result) + " as illegal"); root.exclude(result); result = PASS; } for (int i = 0; i < vacantPoints.size(); i++) { final short move = vacantPoints.get(i); if (root.getWins(move) > mostWins) { mostWins = root.getWins(move); result = move; } } } while (result != PASS && !board.isLegal(result)); // Consider resigning if (root.getWinRate(result) < RESIGN_PARAMETER) { return RESIGN; } log( "Selected " + board.getCoordinateSystem().toString(result) + " with " + root.getWins(result) + " wins in " + root.getRuns(result) + " runs"); return result; }