Advertisement
Guest User

Untitled

a guest
Mar 10th, 2012
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1.     public ISpaceShip attackShip() {
  2.         ISpaceShip[] ships = World.getOtherShips();
  3.         int nShips      = ships.length;
  4.         ISpaceShip[] aliveShips = new ISpaceShip[nShips];
  5.         int nAliveShips = aliveShips.length;
  6.         int alive       = 0;
  7.         for (int a=0;a<nShips;a++){
  8.             if (alive(ships[a])){
  9.                 aliveShips[alive] = ships[a];
  10.                 alive++;
  11.             }
  12.         }
  13.         ISpaceShip ship = aliveShips[0];
  14.         for (int a=0;a<nAliveShips;a++){
  15.             if (getDistanceTo(ship)>=getDistanceTo(aliveShips[a])){
  16.                 ship = ships[a];
  17.             }                  
  18.         }
  19.         return ship;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement