Skip to content

Commit 4afdf39

Browse files
committed
remove duplicate robot sensing of multitile robots
1 parent 8b818e0 commit 4afdf39

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

engine/src/main/battlecode/world/RobotControllerImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,10 @@ public RobotInfo[] senseNearbyRobots(MapLocation center, int radiusSquared, Team
546546
// corner
547547
InternalRobot[] allSensedRobots = gameWorld.getAllRobotsWithinRadiusSquared(center, actualRadiusSquared, team, this.robot.getChirality());
548548
List<RobotInfo> validSensedRobots = new ArrayList<>();
549+
HashSet<Integer> uniqueRobotIds = new HashSet<>();
549550
for (InternalRobot sensedRobot : allSensedRobots) {
551+
if (uniqueRobotIds.contains(sensedRobot.getID()))
552+
continue;
550553
// check if this robot
551554
if (sensedRobot.equals(this.robot))
552555
continue;
@@ -557,6 +560,7 @@ public RobotInfo[] senseNearbyRobots(MapLocation center, int radiusSquared, Team
557560
if (team != null && sensedRobot.getTeam() != team)
558561
continue;
559562
validSensedRobots.add(sensedRobot.getRobotInfo());
563+
uniqueRobotIds.add(sensedRobot.getID());
560564
}
561565
return validSensedRobots.toArray(new RobotInfo[validSensedRobots.size()]);
562566
}

0 commit comments

Comments
 (0)