Difference between revisions of "SuperSittingDuck"
Jump to navigation
Jump to search
RednaxelaBot (talk | contribs) m (Using <syntaxhighlight>.) |
(Add infobox) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | == | + | {{Infobox Robot |
− | + | | author = [[CrazyBassoonist]] | |
− | + | | extends = [[AdvancedRobot]] | |
− | + | | targeting = None | |
− | + | | movement = [[Pattern Movement]] | |
− | + | | current_version = 1.0 | |
− | + | | license = Public domain | |
+ | | download_link = http://robocode-archive.strangeautomata.com/robots/wiki.SuperSampleBot.SuperSittingDuck_1.0.jar | ||
+ | | isOpenSource = yes | ||
+ | | isMelee = no | ||
+ | | isOneOnOne = yes | ||
+ | }} | ||
+ | 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 Bots|sample robots]]. This robot was intended as an April Fools joke. | ||
== 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 == | ||
Line 27: | Line 31: | ||
int enemyHits; | int enemyHits; | ||
boolean goCryInCorner; | boolean goCryInCorner; | ||
+ | |||
/** | /** | ||
* run: SuperSittingDuck's default behavior | * run: SuperSittingDuck's default behavior | ||
Line 40: | Line 45: | ||
}while(true); | }while(true); | ||
} | } | ||
+ | |||
public void onScannedRobot(ScannedRobotEvent e){ | public void onScannedRobot(ScannedRobotEvent e){ | ||
double absBearing=e.getBearingRadians()+getHeadingRadians(); | double absBearing=e.getBearingRadians()+getHeadingRadians(); | ||
Line 61: | Line 67: | ||
setTurnRadarRightRadians(robocode.util.Utils.normalRelativeAngle(absBearing-getRadarHeadingRadians())); | setTurnRadarRightRadians(robocode.util.Utils.normalRelativeAngle(absBearing-getRadarHeadingRadians())); | ||
} | } | ||
+ | |||
public void onHitByBullet(HitByBulletEvent e){ | public void onHitByBullet(HitByBulletEvent e){ | ||
/* | /* | ||
Line 71: | Line 78: | ||
} | } | ||
} | } | ||
− | |||
}</syntaxhighlight> | }</syntaxhighlight> | ||
+ | [[Category:Bots]] | ||
+ | [[Category:Super Sample Bots]] |
Latest revision as of 12:28, 4 September 2017
SuperSittingDuck | |
Author(s) | CrazyBassoonist |
Extends | AdvancedRobot |
Targeting | None |
Movement | Pattern Movement |
Current Version | 1.0 |
Code License | Public domain |
Download |
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;
}
}
}