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; }
public void earlyNearbyCows() throws GameActionException { target = null; double numCows = -1.0; for (int x = -8; x <= 8; x++) { for (int y = -8; y <= 8; y++) { MapLocation lookat = currentLocation.add(x, y); if (lookat.distanceSquaredTo(ALLY_PASTR_COUNT > 0 ? ALLY_PASTR_LOCS[0] : currentLocation) <= 5 || !RC.canSenseSquare(lookat)) continue; double t = RC.senseCowsAtLocation(lookat); if (t > numCows) { numCows = t; target = lookat; } } } System.out.println("target" + target + " numcows " + numCows); }