protected MapLocation[] findEnemy() throws GameActionException { ArrayList<MapLocation> enemyLocations = new ArrayList<MapLocation>(); ArrayList<Robot> allRobots = new ArrayList<Robot>(); Robot[] airRobots = myRC.senseNearbyAirRobots(); Robot[] groundRobots = myRC.senseNearbyGroundRobots(); allRobots.addAll(Arrays.asList(airRobots)); allRobots.addAll(Arrays.asList(groundRobots)); for (Robot robot : allRobots) { try { RobotInfo info = myRC.senseRobotInfo(robot); if (!myRC.getTeam().equals(info.team)) { int distance = myRC.getLocation().distanceSquaredTo(info.location); if (distance < enemyDistance) { enemyDistance = distance; } enemyLocations.add(info.location); } } catch (GameActionException e) { } } MapLocation[] retLocations = new MapLocation[enemyLocations.size()]; retLocations = enemyLocations.toArray(retLocations); return retLocations; }
protected void transferEnergon() throws GameActionException { for (Robot robot : myRC.senseNearbyGroundRobots()) { try { RobotInfo robotInfo = myRC.senseRobotInfo(robot); if (robotInfo.team == myRC.getTeam()) { MapLocation robotLocation = robotInfo.location; if (myRC.getLocation().isAdjacentTo(robotLocation)) myRC.transferEnergon( Math.max( 0, Math.min( robotInfo.maxEnergon - robotInfo.eventualEnergon, myRC.getEnergonLevel() / 2)), robotLocation, RobotLevel.ON_GROUND); } } catch (GameActionException e) { } } }