Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ShielsJack;
- import robocode.*;
- import robocode.util.*;
- //import java.awt.Color;
- // API help : https://robocode.sourceforge.io/docs/robocode/robocode/Robot.html
- /**
- * ShielsJack - a robot by (your name here)
- */
- public class ShielsJack extends AdvancedRobot
- {
- /**
- * run: ShielsJack's default behavior
- */
- public void run() {
- // Initialization of the robot should be put here
- // After trying out your robot, try uncommenting the import at the top,
- // and the next line:
- setAdjustGunForRobotTurn(true);
- setAdjustRadarForGunTurn(true);
- // setColors(Color.red,Color.blue,Color.green); // body,gun,radar
- // Robot main loop
- while(true) {
- // Replace the next 4 lines with any behavior you would like
- setTurnRadarRight(360);
- ahead(200);
- turnLeft(45);
- }
- }
- /**
- * onScannedRobot: What to do when you see another robot
- */
- public void onScannedRobot(ScannedRobotEvent e) {
- // Replace the next line with any behavior you would like
- // taken from wiki
- // taken from mark.random-article.com
- setTurnGunRight(getHeading() - getGunHeading() + e.getBearing());
- fire(5);
- if (e.getDistance() < 200){
- ahead(100);
- back(100);
- setTurnRadarRight(360);
- }
- }
- /**
- * onHitByBullet: What to do when you're hit by a bullet
- */
- public void onHitByBullet(HitByBulletEvent e) {
- // Replace the next line with any behavior you would like
- ahead(200);
- }
- /**
- * onHitWall: What to do when you hit a wall
- */
- public void onHitWall(HitWallEvent e) {
- // Replace the next line with any behavior you would like
- back(20);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement