[Home]VelocityTrick

Robo Home | Changes | Preferences | AllPages

Showing revision 2
A failed experiment by Xero to see if velocity changes messed up guns. It ended up not only messing up the enemy gun but messing up my WaveSurfing. Here is the (now obsolete) code which goes in your onScannedRobot:
	double maxVel = Math.random();
	        if(maxVel < .1) {
			maxVel = 4;
		}
		else if(maxVel < .5) {
			maxVel = 5;
		}
		else if(maxVel < .6) {
			maxVel = 3;
		}
		else if(maxVel < .4) {
			maxVel = 6;
		}
		else if(maxVel < .7) {
			maxVel = 8;
		}
		else if(maxVel < .9) {
			maxVel = 7;
		}
		else if(maxVel > .8) {
		maxVel = 8;
	}
		out.println("Max velocity:" + maxVel);
		setMaxVelocity?(maxVel);

Well, you'll never end up reaching that maxVel < .4 part because the < .5 condition covers that. I've found it a lot better to just do maxVel=Math.random()*12+3; (12 because I've found it better to have the bot spend more time at full speed and 3 because you never set the speed below that in your code.) -- Alcatraz


Robo Home | Changes | Preferences | AllPages
Edit revision 2 of this page | View other revisions | View current revision
Edited April 27, 2006 14:17 EST by CMU-179539.RES.cmu.edu (diff)
Search: