Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 10th, 2012  |  syntax: Java  |  size: 0.52 KB  |  views: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.         }