[Home]History of CrazyTrackerSource

Robo Home | Changes | Preferences | AllPages


Revision 5 . . December 28, 2005 22:52 EST by Bayen [Cleaned up my code a lot]
Revision 4 . . (edit) December 28, 2005 12:02 EST by GrubbmGait [just added tags]
  

Difference (from prior major revision) (no other diffs)

Removed: 13,14d12
boolean ally = true; //will we work together with other
//Crazy? robots?

Removed: 17,19d14
static int targetStrategy = 1; //1 is Linear
//2 is Head On Targeting
int misscount; //how many times my shots missed

Changed: 25,26c20,21
setAdjustGunForRobotTurn(true);//allow gun to move
//freely
setAdjustGunForRobotTurn(true);//allow gun and radar
setAdjustRadarForGunTurn(true);//free movement

Removed: 36,45d30
//ensure that we don't fire upon other
//Crazy? robots
if(e.getName().length() >= 5 && getOthers() > 1){
if((getName().subSequence(0,5))
.equals(e.getName().subSequence(0,5))){
if(ally==true){//if they have fired at us, we will
return; //not ally with them
}
}
}

Removed: 56d40
if(targetStrategy == 1){

Changed: 93c77,78
double theta = Utils.normalAbsoluteAngle?(Math.atan2(predictedX
double theta =
Utils.normalAbsoluteAngle?(Math.atan2(predictedX

Removed: 104,170d88
if(targetStrategy==2||getOthers()>3){
// Calculate exact location of the robot
double absoluteBearing =
getHeading() + e.getBearing();
double bearingFromGun? =
normalRelativeAngle(absoluteBearing -
getGunHeading?());
// If it's close enough, fire!
if (Math.abs(bearingFromGun?) <= 3) {
turnGunRight?(bearingFromGun?);
// We check gun heat here, because calling fire()
// uses a turn, which could cause us to lose track
// of the other robot.
if (getGunHeat() == 0)
fire (Math.min(3
- Math.abs(bearingFromGun?),getEnergy()
- .1));
}
// otherwise just set the gun to turn.
// Note: This will have no effect until we call scan()
else {
turnGunRight?(bearingFromGun?);
}
// Generates another scan event if we see a robot.
// We only need to call this if the gun (and therefore radar)
// are not turning. Otherwise, scan is called automatically.
if (bearingFromGun? == 0)
scan();
}
}
public void onWin(WinEvent? e)
{
//My? favorite little victory dance.
setAdjustRadarForRobotTurn?(true);
setAdjustRadarForGunTurn(true);
setAdjustGunForRobotTurn(true);
for(;;){
setTurnRadarRight(360);
setTurnGunLeft?(180);
setTurnLeft?(90);
if(getEnergy() > 0.1)
fire(0.1);
}
}
// Helper function
public double normalRelativeAngle(double angle) {
if (angle > -180 && angle <= 180)
return angle;
double fixedAngle = angle;
while (fixedAngle <= -180)
fixedAngle += 360;
while (fixedAngle > 180)
fixedAngle -= 360;
return fixedAngle;
}
/**
* onHitByBullet?: Randomize my movement
*/
public void onBulletMissed?(BulletMissedEvent? e) {
misscount++;
if(misscount > 5){
if(targetStrategy==1)
targetStrategy=2;
if(targetStrategy==2)
targetStrategy=1;
}
}

Changed: 177,185c95,96
//make sure my allies aren't firing on me, and if
//they are, I will cut short our alliance
if(e.getName().length() >= 5 && getOthers() > 1){
if((getName().subSequence(0,5))
.equals(e.getName().subSequence(0,5))){
if(ally==true){ally = false;}}}

}}
</pre>
}
}</pre>

Robo Home | Changes | Preferences | AllPages
Search: