private void rec(State s, int i, int remDelay, StateBuffer out) {
		moves[i].clearCache();
		if(i == moves.length-1) {
			moves[i].execute(remDelay);
			if(metric.getMetric() != 0)
				out.addState(Gameboy.curGb.createState(true));
		} else if (!moves[i].isDelayable()) {
			moves[i].execute(0);
			rec(curGb.newState(),i+1,remDelay,out);
		} else if (i == lastDelayableMove) {
			moves[i].execute(remDelay);
			rec(curGb.newState(),i+1,0,out);
		} else {
			for(int stepDelay=0;stepDelay<=remDelay;stepDelay++) {
			  curGb.restore(s);
				moves[i].prepare(stepDelay, true);
				moves[i].doMove();
				rec(curGb.newState(),i+1,remDelay-stepDelay,out);
			}
		}
	}