Skip to content

Commit 63f8e4c

Browse files
committed
Merge branch 'trap_changes' of https://github.com/battlecode/battlecode26 into trap_changes
2 parents b2f35a3 + 4afdf39 commit 63f8e4c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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)