Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ISpaceShip attackShip() {
- ISpaceShip[] ships = World.getOtherShips();
- int nShips = ships.length;
- ISpaceShip[] aliveShips = new ISpaceShip[nShips];
- int nAliveShips = aliveShips.length;
- int alive = 0;
- for (int a=0;a<nShips;a++){
- if (alive(ships[a])){
- aliveShips[alive] = ships[a];
- alive++;
- }
- }
- ISpaceShip ship = aliveShips[0];
- for (int a=0;a<nAliveShips;a++){
- if (getDistanceTo(ship)>=getDistanceTo(aliveShips[a])){
- ship = ships[a];
- }
- }
- return ship;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement