[Home]HaikuRamFire

Robo Home | Changes | Preferences | AllPages

I expect this ones been done before... i could cheat and put the fire() in the turnRight(), and then i would have a line for a onHitRobot? to make it ram multiple times... -- Tango

package tango.haiku;
import robocode.*;

public class HaikuRamFire extends AdvancedRobot
{
	String TargetName;
	public void run() {
		setTurnGunRight(Double.POSITIVE_INFINITY);
		setAhead(Double.POSITIVE_INFINITY);		
	}


	public void onScannedRobot(ScannedRobotEvent e) {
			fire(3);
			turnRight(e.getBearing()); 
	}

}

The way I would probably do it is in run, do turnRight(Double.POSITIVE_INFINITY); and in onScannedRobot, do setAhead(e.getDistance()), do my firing, and then turnLeft(getTurnRemaining?()) ;-) The other HaikuRamFire (yes, someone has made one), does some kind of setTurnRightRadians?(e.getBearing()), that way he always goes a little past his opponent. -- Kawigi

Yes, i saw the other one. He's mixing degrees and radians and trying to claim it's a feature, but i don't really get it... :-/ -- Tango

Since degrees are larger than radians, he's over-correcting, to make sure he always sees the opponent again (even if they went the other direction). The way I described is just another way to do the same thing. -- Kawigi

wouldn't POSITIVE_INFINITY, or just e.getBearing()+20, be much easier? -- Tango


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited September 1, 2003 11:35 EST by Tango (diff)
Search: