Difference between revisions of "SuperSittingDuck"
Jump to navigation
Jump to search
(Oops, there is already a SuperSittingDuck article (added it to the super sample bots category)) |
(Improve formatting) |
||
Line 1: | Line 1: | ||
− | + | SuperSittingDuck is part of the [[Super Sample Bots]] set by [[CrazyBassoonist]]. These robots are intended to provide new robocoders with a new challenge after beating all of the sample robots. This robot was intended as an April Fools joke. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | SuperSittingDuck is part of the Super Sample Bots set by CrazyBassoonist. These robots are intended to provide new robocoders with a new challenge after beating all of the sample robots. | ||
− | |||
== Movement == | == Movement == | ||
SuperSittingDuck moves to the enemy and stays at a close distance, then goes and cries in a corner of the field if it gets hit too much. | SuperSittingDuck moves to the enemy and stays at a close distance, then goes and cries in a corner of the field if it gets hit too much. | ||
− | |||
== Targeting == | == Targeting == | ||
None. | None. | ||
− | |||
== Code == | == Code == |
Revision as of 19:29, 9 August 2017
SuperSittingDuck is part of the Super Sample Bots set by CrazyBassoonist. These robots are intended to provide new robocoders with a new challenge after beating all of the sample robots. This robot was intended as an April Fools joke.
Movement
SuperSittingDuck moves to the enemy and stays at a close distance, then goes and cries in a corner of the field if it gets hit too much.
Targeting
None.
Code
package wiki.SuperSampleBot;
import robocode.*;
import java.awt.Color;
/**
* SuperSittingDuck - a SuperSampleBot by CrazyBassoonist
*/
public class SuperSittingDuck extends AdvancedRobot{
int enemyHits;
boolean goCryInCorner;
/**
* run: SuperSittingDuck's default behavior
*/
public void run() {
/**
*set the colors
*/
setBodyColor(Color.yellow);
setGunColor(Color.yellow);
do{
turnRadarRightRadians(Double.POSITIVE_INFINITY);
}while(true);
}
public void onScannedRobot(ScannedRobotEvent e){
double absBearing=e.getBearingRadians()+getHeadingRadians();
double robotForce=5*(e.getDistance()-100);
/*
*If we get hit too much, go cry in the corner.
*/
if(goCryInCorner){
turnRight(90-getHeading());
ahead((getBattleFieldWidth()-getX())-20);
turnRight(0-getHeading());
ahead((getBattleFieldHeight()-getY())-20);
}
/*
*Otherwise go towards the other robot and don't fire at him
*/
else{
setAhead(robotForce);
setTurnRightRadians(robocode.util.Utils.normalRelativeAngle(absBearing-getHeadingRadians()));
}
setTurnRadarRightRadians(robocode.util.Utils.normalRelativeAngle(absBearing-getRadarHeadingRadians()));
}
public void onHitByBullet(HitByBulletEvent e){
/*
*Find out how much the enemy has hit us...
*/
enemyHits++;
if(enemyHits==4){
System.out.println("Oh, the shame of losing!");
goCryInCorner=true;
}
}
}