kernel_memory_dump

Untitled

Apr 16th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 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.         final double M = 50;
  15.         double maxX = getBattleFieldWidth();
  16.         double maxY = getBattleFieldHeight();
  17.         double x;
  18.         double y;
  19.  
  20.         while(true){
  21.            
  22.             ahead(M);
  23.             scan();
  24.             x = getX();
  25.             y = getY();
  26.             if (   (maxX - x)  <= M + getHeight() ){
  27.                 turnRight(90);
  28.             } else if ( (maxY - y) <= M + getHeight()){
  29.                 turnRight(90);
  30.             } else if ( x <= M + getHeight()) {
  31.                 turnLeft(90);
  32.             } else if ( y <= M + getHeight() ){
  33.                 turnRight (90);
  34.             }
  35.         }
  36.    
  37.            
  38.        
  39.  
  40.    }
  41.    
  42.     public void coshakMod(){
  43.         final double M = 50;
  44.         double maxX = getBattleFieldWidth();
  45.         double maxY = getBattleFieldHeight();
  46.         double x;
  47.         double y;
  48.         ahead(M);
  49.         x = getX();
  50.         y = getY();
  51.         if (   (maxX - x)  <= M + getHeight() ){
  52.             turnRight(90);
  53.         } else if ( (maxY - y) <= M + getHeight()){
  54.             turnRight(90);
  55.         } else if ( x <= M + getHeight()) {
  56.             turnLeft(90);
  57.         } else if ( y <= M + getHeight() ){
  58.             turnRight (90);
  59.         }
  60.     }
  61.    
  62.    public void onHitRobot(HitRobotEvent event) {
  63.        setTurnRight(event.getBearing());
  64.        setFire(3);
  65.        turnRight(180);
  66.        
  67.        ahead(100);
  68.    }
  69.    
  70.  
  71.     public void onScannedRobot(ScannedRobotEvent e) {
  72.         // okrenimo se ka skeniranom protivniku
  73.         if(getOthers() > 3){
  74.             setTurnRight(e.getBearing());
  75.             setFire(3);
  76.         }
  77.         else {
  78.             // Lock on to our target (this time for sure)
  79.                         setTurnRight(e.getBearing());
  80.                         // move a little closer
  81.                         if (e.getDistance() > 200)
  82.                             setAhead(e.getDistance() / 2);
  83.                         // but not too close
  84.                         if (e.getDistance() < 100)
  85.                             setBack(e.getDistance());
  86.  
  87.                         // shoot at him
  88.                         setFire(3);
  89.  
  90.                         // wobble the radar to generate another scan event
  91.                         scanDirection *= -1;
  92.                         setTurnRadarRight(36000 * scanDirection);
  93.         }
  94.  
  95. }
  96.    
  97.     }
Advertisement
Add Comment
Please, Sign In to add comment