From a11a087058d420112c22249cafbdfc3f84c6c62e Mon Sep 17 00:00:00 2001 From: vilasopher Date: Wed, 6 Jan 2016 22:14:45 -0500 Subject: [PATCH] Update RobotPlayer.java --- RobotPlayer.java | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/RobotPlayer.java b/RobotPlayer.java index bdfddb7..66af561 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -3,6 +3,7 @@ import battlecode.common.*; //imports Battlecode UI import java.util.Random; //Use this instead of Math.random(); seeded by the robot's id so more likely to be random than Math.random import java.util.Arrays; +import java.util.Collection; public class RobotPlayer{ /** @@ -13,12 +14,16 @@ public class RobotPlayer{ * $ourTeam: our Team, to save bytecodes * $opponentTeam: Opponent's (NOT ZOMBIES) team * + * $zombieDenLocations: locations of the zombie dens + * $enemyArchonIDs: the IDs of enemy archons */ static RobotController rc; static Random randall; static Team ourTeam; static Team opponentTeam; static int[] zombieRounds; + static MapLocation[] zombieDenLocations; + static Collection enemyArchonIDs; /** * run @@ -437,7 +442,7 @@ public static RobotType chooseRobotType() { if(Math.random()*3>1) { return RobotType.SCOUT; } - if(numberOfRobotsInRadius(RobotType.GUARD,3,ourTeam) == 7){ + if(numberOfRobotsInRadiusAndThoseRobots(RobotType.GUARD,3,ourTeam).first == 7){ return RobotType.SCOUT; } return RobotType.GUARD; @@ -448,20 +453,35 @@ public static RobotType chooseRobotType() { * @param type the type of robot to look for * @param radiusSqr the squared radius * @param team the team the robot should be on - * @return the number of robots nearby + * @return a tuple containing the number of robots nearby and the array of all robots nearby */ - public static int numberOfRobotsInRadius(RobotType type,int radiusSqr,Team team){ + public static Tuple numberOfRobotsInRadiusAndThoseRobots(RobotType type,int radiusSqr,Team team){ int count = 0; RobotInfo[] robats = rc.senseNearbyRobots(radiusSqr,team); if(type == null){ - return robats.length; + Tuple thingToReturn = new Tuple(robats.length, robats); + return thingToReturn; } for(int i = 0; i < robats.length; i++){ if(robats[i].type.equals(type)){ count++; } } - return count; + Tuple returnThing = new Tuple(count, robats); + return returnThing; + } + + /** + * Collects the ID of enemy archons within sight range + * adds the IDs to the static collection enemyArchonIDs + */ + public static void collectEnemyArchonID() { + Tuple robs = numberOfRobotsInRadiusAndThoseRobots(RobotType.ARCHON, rc.getType().sensorRadiusSquared, opponentTeam); + if (robs.first > 0) { + for (RobotInfo rob : robs.second) { + enemyArchonIDs.add(rob.ID); + } + } } }