From 5c3b5dd66e1a20edd7b234205530401c6caa8836 Mon Sep 17 00:00:00 2001 From: Elizabeth Zou Date: Wed, 12 Jan 2022 13:47:00 -0500 Subject: [PATCH] fix sense lead/gold --- .../main/battlecode/world/RobotControllerImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/src/main/battlecode/world/RobotControllerImpl.java b/engine/src/main/battlecode/world/RobotControllerImpl.java index 5ab103fd..da8d9e1c 100644 --- a/engine/src/main/battlecode/world/RobotControllerImpl.java +++ b/engine/src/main/battlecode/world/RobotControllerImpl.java @@ -321,9 +321,9 @@ public MapLocation[] senseNearbyLocationsWithLead(MapLocation center, int radius throw new GameActionException(CANT_DO_THAT, "Radius squared must be non-negative."); ArrayList locations = new ArrayList<>(); - for (MapLocation m : this.gameWorld.getAllLocationsWithinRadiusSquared(center, radiusSquared)) { - if (this.gameWorld.getLead(m) >= minLead) { - locations.add(m); + for (MapLocation loc : this.gameWorld.getAllLocationsWithinRadiusSquared(center, radiusSquared)) { + if (this.gameWorld.getLead(loc) >= minLead && canSenseLocation(loc)) { + locations.add(loc); } } MapLocation[] result = new MapLocation[locations.size()]; @@ -361,9 +361,9 @@ public MapLocation[] senseNearbyLocationsWithGold(MapLocation center, int radius throw new GameActionException(CANT_DO_THAT, "Radius squared must be non-negative."); ArrayList locations = new ArrayList<>(); - for (MapLocation m : this.gameWorld.getAllLocationsWithinRadiusSquared(center, radiusSquared)) { - if (this.gameWorld.getGold(m) >= minGold) { - locations.add(m); + for (MapLocation loc : this.gameWorld.getAllLocationsWithinRadiusSquared(center, radiusSquared)) { + if (this.gameWorld.getGold(loc) >= minGold && canSenseLocation(loc)) { + locations.add(loc); } } MapLocation[] result = new MapLocation[locations.size()];