Skip to content

Commit 36f4c3d

Browse files
Better tesselation of SRP #6
1 parent 44a61b0 commit 36f4c3d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

java/src/s2/Soldier.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,24 @@ private boolean shouldBuildSRP() throws GameActionException{
139139
for (MapInfo mapInfo : info) {
140140
MapLocation tileLocation = mapInfo.getMapLocation();
141141
if (mapInfo.isResourcePatternCenter()) { // will overlap already built SRP
142-
return false;
142+
// Resource centers at the very edge of the vision radius
143+
// that are on the same x or y axis as the current are overlappable without issue
144+
// relative locations (0,4) (-4,0) (0,-4) (4,0)
145+
MapLocation relativeLocation = tileLocation.translate(-currentLocation.x, -currentLocation.y);
146+
int x = relativeLocation.x;
147+
int y = relativeLocation.y;
148+
boolean case1 = x == 0 && (y == 4 || y == -4);
149+
boolean case2 = y == 0 && (x == 4 || x == -4);
150+
if (!(case1 || case2)) {
151+
return false;
152+
}
143153
}
144154

145155
// Has wall or tower blocking
146156
// Locations within SRP range
147-
// boolean in_range = mapInfo.getMapLocation().isWithinDistanceSquared(currentLocation, 1);
148-
// boolean isTower = mapInfo.hasRuin() && !noRobot;
149-
// if (in_range) {
150-
// // boolean isPaintedbyAlly =mapInfo.getPaint().isAlly();
151-
// if (mapInfo.isWall() || isTower) {
152-
// return false;
153-
// }
154-
// }
155-
157+
boolean noRobot = rc.senseRobotAtLocation(tileLocation) == null;
156158
// cant build if there is uncompleted ruin
157159
// this makes sure SRPs wont overlap onto TowerPatterns
158-
boolean noRobot = rc.senseRobotAtLocation(tileLocation) == null;
159160
boolean noTower = mapInfo.hasRuin() && noRobot;
160161
if (noTower) {
161162
return false;

0 commit comments

Comments
 (0)