SHARE
TWEET

Untitled

a guest Oct 17th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public int getDirectionOfNearestFriend() {
  2.         int nearestFriendX = 0;
  3.         int nearestFriendY = 0;
  4.         int nearestFriendDistance;
  5.         for(int i = 0; i < gridRows; i++) {
  6.             for(int j = 0; j < gridColumns; j++) {
  7.                 if(i == row && j == col) {
  8.  
  9.                 } else {
  10.                     if(grid.get(i, j) == team) {
  11.                         int d = getDistance(i, j);
  12.             if(nearestFriendDistance == null) {
  13.                 nearestFriendDistance = d;
  14.             } else if(d < nearestFriendDistance) {
  15.                             nearestFriendX = i;
  16.                             nearestFriendY = j;
  17.                             nearestFriendDistance = d;
  18.                         }
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.        
  24.     if (nearestFriendDistance != null) {
  25.         return getDirection(nearestFriendX, nearestFriendY);
  26.     }
  27.         return NEUTRAL;
  28.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top