DEBUG0("--mark--");
deque<Move> aStar2(const State2& start, int maxMoves) {    DEBUG1("MAX_STATES = " << MAX_STATES);    DEBUG1("MAX_HASHES = " << MAX_HASHES);    states.clear();    states.push_back(State2());	// 0 reserved for 'empty'    states.reserve(MAX_STATES);    hashTable.clear();    //hashTable.resize(PRIME_LIST[0]);    //hashTable.resize(98317);    hashTable.resize(MAX_HASHES);    minMinTotalMoves = 0;    firstOpen = 1;    searchIndex = firstOpen;    numOpen = 0;        static long long totalNodes = 0;    long counter = 0;        DEBUG1("start state: " << start);    hashInsert(start);    ++totalNodes;    while (true) {	int bestIndex = findBest(maxMoves);	DEBUG0("bestIndex: " << bestIndex);	if (bestIndex == 0)	    break;	//State2& best = states[bestIndex];	DEBUG0("best: " << states[bestIndex]);	states[bestIndex].isOpen = false;	--numOpen;	if (counter++ % 100000 == 0)	    cout << "best: " << states[bestIndex]		 << "\n  open: " << numOpen		 << "\nstates: " << states.size()		 << " \t(" << (states.size() * sizeof(State2)) / 1000000		 << "M/" << (states.capacity() * sizeof(State2)) / 1000000		 << "M)\nhashes: " << hashTable.size()		 << " \t(" << (states.size() * sizeof(int)) / 1000000		 << "M/" << (hashTable.capacity() * sizeof(int)) / 1000000		 << "M)\n";	vector<Move> moves = states[bestIndex].moves();	for (vector<Move>::const_iterator m = moves.begin();	     m != moves.end(); ++m) {	    DEBUG0("--mark--");	    DEBUG0("moving " << states[bestIndex] << ' ' << *m);	    State2 newState2(states[bestIndex], *m);	    newState2.predecessor = bestIndex;	    DEBUG0("New state: " << newState2);	    int minMovesLeft = newState2.minMovesLeft();	    if (minMovesLeft == 0) { // special property of our heuristic...		cout << "Found solution.\n"		     << "\nstates: " << states.size()		     << " \t(" << (states.size() * sizeof(State2)) / 1000000		     << "M/" << (states.capacity() * sizeof(State2)) / 1000000		     << "M)\nhashes: " << hashTable.size()		     << " \t(" << (states.size() * sizeof(int)) / 1000000		     << "M/" << (hashTable.capacity() * sizeof(int)) / 1000000		     << "M)\n";		deque<Move> solution;		State2* pNode = &states[bestIndex];		State2* pNextNode;		bool done = false;		while (!done) {		    if (pNode->predecessor == 1) // start node			done = true;		    pNextNode = pNode;		    DEBUG0("predecessor of " << *pNode			  << " is " << pNode->predecessor);		    pNode = &states[pNode->predecessor];		    vector<Move> moves = pNode->moves();		    for (vector<Move>::const_iterator m = moves.begin();			 m != moves.end(); ++m) {			if (State2(*pNode, *m) == *pNextNode) {			    solution.push_front(*m);			    break;			}		    }		}		solution.push_back(*m);		return solution;	    }	    if (newState2.minTotalMoves() > maxMoves) {		DEBUG0("State2 exceeds move limit.");		continue;	    }	    if (newState2.minTotalMoves() < minMinTotalMoves) {		// This can't happen if the heuristic is admissible		DEBUG1("minTotalMoves of " << newState2.minTotalMoves()		       << " smaller than previous minMinTotalMoves of "		       << minMinTotalMoves);		assert(0);	    }	    if (states.size() == MAX_STATES) {		DEBUG1("State table full; giving up.");		return deque<Move>();	    }	    hashInsert(newState2);	    DEBUG0("inserted" << newState2);	    ++totalNodes;	}    }    DEBUG1("Queue empty; no solution possible.");    return deque<Move>();}