DEBUG0("No states with max. " << minMinTotalMoves << " minTotalMoves.");
DEBUG1("No states with max. " << minMinTotalMoves << " minTotalMoves in queue.");
int findBest(int maxMoves) {    DEBUG0("--- findBest ---");    int numNodes = 0;    ++searchIndex;    while (true) {	DEBUG0("Looking for states with max. " << minMinTotalMoves	       << " minTotalMoves, starting from " << searchIndex	       << " (" << states.size() << " states).");	bool alreadyRestarted = false;	while (true) {	    for (; searchIndex < states.size(); ++searchIndex) {		if (states[searchIndex].isOpen) {		    if (states[searchIndex].minTotalMoves() <= minMinTotalMoves) {			if (states[searchIndex].minTotalMoves() != minMinTotalMoves)			    DEBUG0("*** WEIRD ***");			DEBUG0("Best at " << searchIndex			       << ". Looked at " << numNodes << " states.");			return searchIndex;		    }		}		++numNodes;	    }	    DEBUG0("Arrived at end of states.");	    if (alreadyRestarted)		break;	    DEBUG0("Finding first open state.");	    for (; firstOpen < states.size() && !states[firstOpen].isOpen;		 ++firstOpen) { }	    if (firstOpen == states.size()) {		DEBUG0("No open node left at all!");		return 0;	    }	    DEBUG0("First open: " << firstOpen << '.');	    searchIndex = firstOpen;	    alreadyRestarted = true;	}	DEBUG0("No states with max. " << minMinTotalMoves << " minTotalMoves.");	if (++minMinTotalMoves > maxMoves) {	    DEBUG0("No states within limit of " << maxMoves << " moves.");	    return 0;	}	searchIndex = firstOpen;    }}