@Override
	public boolean doMove() {

		int startSteps = curGb.stepCount;
		prepareMovement();

		while(true) {
			if(!check) {
			  curGb.step(dir); // walk
				break;
			} else {
				State s = curGb.newState();
				int add = Util.runToAddressNoLimit(0, dir, curGb.pokemon.walkSuccessAddress, curGb.pokemon.walkFailAddress);
				if(add != curGb.pokemon.walkSuccessAddress) { // test if we are in the walk animation
					System.err.println("moving failed ("+(curGb.stepCount - startSteps)+")");
					if((curGb.stepCount - startSteps) > 20) {
						System.out.println("moving failed too often, giving up!");
						return false;
					}
					curGb.restore(s);
					curGb.step(); // wait frame
					prepareMovement(); // find next walk frame
					continue;
				}
				curGb.step(); // finish frame
				if(avoidEncounters) {
					State finished = curGb.newState();
					Util.runToAddressNoLimit(0, 0, curGb.pokemon.doWalkPreEncounterCheckAddress);
					add = Util.runToAddressNoLimit(0,dir, curGb.pokemon.doWalkPostEncounterCheckAddress, curGb.pokemon.encounterCheckMainFuncEncounterAddress);
					if(add == curGb.pokemon.doWalkPostEncounterCheckAddress) {
					  curGb.restore(finished);
						break;
					}
					curGb.restore(s);
					System.out.println("WalkStep: avoiding encounter ("+(curGb.stepCount - startSteps)+")");
					curGb.step(); // wait one more frame
		      curGb.delayStepCount++;
					prepareMovement(); // find next walk frame
					continue;
				} else
					break;
			}
		}
		return true;
	}