Difference between revisions of "Thread:User talk:Gertjan96/Simple robot - looking for improvements"
Jump to navigation
Jump to search
(New thread: Simple robot - looking for improvements) |
(No difference)
|
Latest revision as of 20:30, 17 June 2014
Hello,
I made a simple but (I hope) effective robot. I don't have much experience, so I would love to get any tips on how to further improve this code. It has to be ready in 3,5 hours. Lots of thanks.
package MyRobots;
import robocode.*;
import java.awt.Color;
public class Fireintheass extends AdvancedRobot
{
double distance = 10;
public void run() {
setColors(Color.pink, Color.pink, Color.pink, Color.white, Color.pink);
setAdjustRadarForGunTurn(true);
setTurnRadarRight(360);
while(true) {
ahead(distance + 100);
back(distance);
}
}
public void onScannedRobot(ScannedRobotEvent e) {
turnRight(e.getBearing());
distance = e.getDistance();
if (e.getVelocity() == 0)
{
fire(3);
}
setTurnRadarRight(360);
}
}