Advertisement
kernel_memory_dump

Untitled

Apr 16th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. package roboti.sebastian;
  2. import java.awt.Color;
  3.  
  4. import robocode.AdvancedRobot;
  5. import robocode.HitByBulletEvent;
  6. import robocode.HitRobotEvent;
  7. import robocode.HitWallEvent;
  8. import robocode.ScannedRobotEvent;
  9.  
  10. // API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html
  11.  
  12. /**
  13. * AB123 - a robot by (your name here)
  14. */
  15. public class Masakrator extends AdvancedRobot {
  16.  
  17. private byte scanDirection = 1;
  18. /**
  19. * run: AB123's default behavior
  20. */
  21. public void run() {
  22.  
  23. // Colors
  24. setBodyColor(Color.red);
  25. setGunColor(Color.black);
  26. setRadarColor(Color.black);
  27. setBulletColor(Color.red);
  28. setScanColor(Color.red);
  29.  
  30. // Initialization of the robot should be put here
  31.  
  32. // After trying out your robot, try uncommenting the import at the top,
  33. // and the next line:
  34.  
  35. // setColors(Color.red,Color.blue,Color.green); // body,gun,radar
  36. while(true) {
  37. setAdjustRadarForRobotTurn(true);
  38. setTurnRadarRight(36000);
  39. execute ();
  40. // Robot main loop
  41.  
  42. }
  43. }
  44.  
  45. /**
  46. * onScannedRobot: What to do when you see another robot
  47. */
  48. public void onScannedRobot(ScannedRobotEvent e) {
  49. // Lock on to our target (this time for sure)
  50. setTurnRight(e.getBearing());
  51. // move a little closer
  52. if (e.getDistance() > 200)
  53. setAhead(e.getDistance() / 2);
  54. // but not too close
  55. if (e.getDistance() < 100)
  56. setBack(e.getDistance());
  57.  
  58. // shoot at him
  59. setFire(3);
  60.  
  61. // wobble the radar to generate another scan event
  62. scanDirection *= -1;
  63. setTurnRadarRight(36000 * scanDirection);
  64.  
  65. }
  66.  
  67. /**
  68. * onHitByBullet: What to do when you're hit by a bullet
  69. */
  70. public void onHitByBullet(HitByBulletEvent e) {
  71. // Replace the next line with any behavior you would like
  72. back(20);
  73. }
  74.  
  75. /**
  76. * onHitWall: What to do when you hit a wall
  77. */
  78. public void onHitWall(HitWallEvent e) {
  79. // Replace the next line with any behavior you would like
  80. back(20);
  81. }
  82. public void onHitRobot (HitRobotEvent e) {
  83. // Replace the next line with any behavior you would like
  84. back (20);
  85. ahead (100);
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement