} else if (atomNo < lastMove.atomNo) {
if (atomNo < lastMove.atomNo) {
static bool dfs(IDAStarMove lastMove) {    DEBUG0(spaces(moves) << "dfs: moves =  " << moves << " state = " << state);    if (state.minMovesLeft() == 0)	return true;		// not true for all heuristics, but for this one    if (moves + state.minMovesLeft() > maxMoves)	return false;    IDAStarPackedState* cachedState =	cachedStates.find(IDAStarPackedState(state.positions()));    if (cachedState != NULL) {	DEBUG0("found" << state << " in cache");	if (cachedState->minMovesFromStart < moves)	    return false;	else if (cachedState->minMovesFromStart > moves)	    cachedState->minMovesFromStart = moves;	if (moves + cachedState->minMovesLeft > maxMoves)	    return false;    }    if (nodesGenerated - lastOutput > 2000000) {	lastOutput = nodesGenerated;	cout << state << endl	     << " Nodes: " << nodesGenerated	     << " cached: " << cachedStates.size()	     << " / " << cachedStates.capacity()	     << " moves = " << moves	     << " nodes/second: "	     << (int64_t) (double(nodesGenerated) / timer.seconds())	     << endl;    }    // generate all moves...    for (int atomNo = 0; atomNo < NUM_ATOMS; ++atomNo) {	Pos startPos = state.position(atomNo);	for (int dirNo = 0; dirNo < 4; ++dirNo) {	    Dir dir = DIRS[dirNo];	    DEBUG0(spaces(moves) << "moving " << atomNo << " @ " << startPos		   << ' ' << dir);	    Pos pos;	    for (pos = startPos + dir; !state.isBlocking(pos); pos += dir) { }	    Pos newPos = pos - dir;	    if (newPos != startPos) {		DEBUG0(spaces(moves) << "moves to " << newPos);		IDAStarMove move(atomNo, dir, startPos, newPos);		if (moves > 0) {		    if (atomNo == lastMove.atomNo && dir == -lastMove.dir)			continue;		    } else if (atomNo < lastMove.atomNo) {			// this is only allowed if the two moves are not independent.			if (!(between(lastMove.p1, lastMove.p2, lastMove.dir, newPos)			      || newPos + dir == lastMove.p2			      || between(startPos, newPos, dir, lastMove.p1)			      || newPos == lastMove.p2 + lastMove.dir))			    continue;		    }		}		state.apply(move);		++moves;		++nodesGenerated;		if (dfs(move)) {		    solution.push_front(Move(atomNo, startPos, newPos, dir));		    return true;		}		--moves;		state.undo(move);	    }	}    }