Advertisement
kernel_memory_dump

Untitled

Apr 16th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1.  
  2.  
  3. package roboti.sebastian;
  4.  
  5. import robocode.AdvancedRobot;
  6. import robocode.HitRobotEvent;
  7. import robocode.Robot;
  8. import robocode.ScannedRobotEvent;
  9.  
  10. public class SebastianBot2 extends AdvancedRobot {
  11.  
  12.     private byte scanDirection = 1;
  13.     public void run() {
  14.  
  15.         while(true){
  16.             if (getOthers() > 3){
  17.                 coshakMod();
  18.             }
  19.            
  20.            
  21.        
  22. //
  23.     setAdjustRadarForRobotTurn(true);
  24.             setTurnRadarRight(36000);  // okrecemo
  25.     // radar 10 puta u krug
  26.         }
  27.  
  28.    }
  29.    
  30.     public void coshakMod(){
  31.         final double M = 50;
  32.         double maxX = getBattleFieldWidth();
  33.         double maxY = getBattleFieldHeight();
  34.         double x;
  35.         double y;
  36.         ahead(M);
  37.         x = getX();
  38.         y = getY();
  39.         if (   (maxX - x)  <= M + getHeight() ){
  40.             turnRight(90);
  41.         } else if ( (maxY - y) <= M + getHeight()){
  42.             turnRight(90);
  43.         } else if ( x <= M + getHeight()) {
  44.             turnLeft(90);
  45.         } else if ( y <= M + getHeight() ){
  46.             turnRight (90);
  47.         }
  48.     }
  49.    
  50.    public void onHitRobot(HitRobotEvent event) {
  51.        turnRight(180);
  52.        ahead(100);
  53.    }
  54.    
  55.  
  56.     public void onScannedRobot(ScannedRobotEvent e) {
  57.         // okrenimo se ka skeniranom protivniku
  58.         if(getOthers() > 3){
  59.             setTurnRight(e.getBearing());
  60.             setFire(3);
  61.         }
  62.         else {
  63.             // Lock on to our target (this time for sure)
  64.                         setTurnRight(e.getBearing());
  65.                         // move a little closer
  66.                         if (e.getDistance() > 200)
  67.                             setAhead(e.getDistance() / 2);
  68.                         // but not too close
  69.                         if (e.getDistance() < 100)
  70.                             setBack(e.getDistance());
  71.  
  72.                         // shoot at him
  73.                         setFire(3);
  74.  
  75.                         // wobble the radar to generate another scan event
  76.                         scanDirection *= -1;
  77.                         setTurnRadarRight(36000 * scanDirection);
  78.         }
  79.  
  80. }
  81.    
  82.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement