[Home]WallSmoothing/Optimal

Robo Home | WallSmoothing | Changes | Preferences | AllPages

Now that we've gotten warmed up on the /FancyStick wall smoothing - let's really cut it as close to the walls as possible (without slowing down). A pitfall of the other algorithms (theoretically speaking) is that they don't take into account that your bot can turn a lot tighter when it isn't going full speed. I'll come polish this post later (pressed for time), but here's a quick algorithm to give you the idea. I'm calling "drift" the distance your bot will travel toward the wall when it uses maximum accelleration *and* maximum turning angle. Even if you know you're not going to use max accelleration, I think it's best to smooth as thought you were; otherwise you're giving your enemy tips about your future plans. When this method gives you a "drift" that is shorter than your distance to the wall next tick, you need to turn now. The big challenge is, can you get this into a non-iterative solution? (which I believe will involve solving a recurrance relation, or a summation, whichever you like):

	// s: the speed you will travel to arrive at the NEXT tick
	// a: the angle you would like to travel to arrive at the next tick,
	//    before smoothing (which could be reversed from your bot's heading)
	double minDrift(double s, double a) {
		double r = 0.0;
		for (a += maxTurn(s); a < Math.PI; a += maxTurn(s)) {
			s += maxAccel(s);
			r += s * Math.sin(a);
		}
		return r;
	}

	double MIN_TURN = Math.toRadians(4.0);
	double TURN_RANGE = Math.toRadians(6.0);
	double maxTurn(double s) {
		return MIN_TURN + (TURN_RANGE * (1.0 - Math.abs(s) / 8.0));
	}
	
	double maxAccel(double s) {
		if (s < 0.0) {
			return 2.0;
		}
		if (s <= 7.0){
			return 1.0;
		}
		return 8.0 - s;
	}

Robo Home | WallSmoothing | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited October 7, 2006 4:19 EST by Simonton (diff)
Search: