private MapLocation findRichSquare() { double maxCows = currentCowsHere + 50 * COW_GROWTH[curX][curY] + 300; // favor staying here double curCows; MapLocation best = currentLocation; for (MapLocation current : MapLocation.getAllMapLocationsWithinRadiusSq( currentLocation, RobotType.SOLDIER.sensorRadiusSquared)) { try { if (RC.senseTerrainTile(current) == TerrainTile.OFF_MAP) continue; curCows = RC.senseCowsAtLocation(current) + 50 * COW_GROWTH[current.x][current.y]; if (curCows > maxCows && RC.senseObjectAtLocation(current) == null) { best = current; maxCows = curCows; } } catch (GameActionException e) { e.printStackTrace(); } } RC.setIndicatorString(1, "max nearby cows: " + maxCows + " at " + best); if (maxCows > 1000) { return best; } return null; }