Skip to content

Commit ed7669d

Browse files
author
Ian Gonzalez Hermosillo
committed
isSecondary consistency, better canMarkTowerPattern check
1 parent 4891e0a commit ed7669d

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

engine/src/main/battlecode/common/PaintType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public boolean isAlly() {
1111
return this == ALLY_PRIMARY || this == ALLY_SECONDARY;
1212
}
1313

14-
public boolean isPrimary() {
15-
return this == ALLY_PRIMARY || this == ENEMY_PRIMARY;
14+
public boolean isSecondary() {
15+
return this == ALLY_SECONDARY || this == ENEMY_SECONDARY;
1616
}
1717
}

engine/src/main/battlecode/common/RobotController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,13 @@ public interface RobotController {
559559
* the given location.
560560
* This requires there to be a ruin at the location.
561561
*
562+
* @param type which tower pattern type should be used
562563
* @param loc the center of the 5x5 pattern
563564
* @return true if a tower pattern can be marked at loc
564565
*
565566
* @battlecode.doc.costlymethod
566567
*/
567-
boolean canMarkTowerPattern(MapLocation loc);
568+
boolean canMarkTowerPattern(UnitType type, MapLocation loc);
568569

569570
/**
570571
* Builds a tower by marking a 5x5 pattern centered at the given location.

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,9 @@ public void removeMark(MapLocation loc) throws GameActionException {
561561
this.gameWorld.setMarker(getTeam(), loc, 0);
562562
}
563563

564-
private void assertCanMarkTowerPattern(MapLocation loc) throws GameActionException {
564+
private void assertCanMarkTowerPattern(UnitType type, MapLocation loc) throws GameActionException {
565565
assertIsRobotType(this.robot.getType());
566+
assertIsTowerType(type);
566567
assertCanActLocation(loc, GameConstants.BUILD_TOWER_RADIUS_SQUARED);
567568

568569
if (!this.gameWorld.hasRuin(loc)) {
@@ -583,9 +584,9 @@ private void assertCanMarkTowerPattern(MapLocation loc) throws GameActionExcepti
583584
}
584585

585586
@Override
586-
public boolean canMarkTowerPattern(MapLocation loc) {
587+
public boolean canMarkTowerPattern(UnitType type, MapLocation loc) {
587588
try {
588-
assertCanMarkTowerPattern(loc);
589+
assertCanMarkTowerPattern(type, loc);
589590
return true;
590591
} catch (GameActionException e) {
591592
return false;
@@ -599,7 +600,7 @@ public void markTowerPattern(UnitType type, MapLocation loc) throws GameActionEx
599600

600601
@Override
601602
public void markTowerPattern(UnitType type, MapLocation loc, int rotationAngle, boolean reflect) throws GameActionException {
602-
assertCanMarkTowerPattern(loc);
603+
assertCanMarkTowerPattern(type, loc);
603604

604605
this.robot.addPaint(-GameConstants.MARK_PATTERN_PAINT_COST);
605606
this.gameWorld.markTowerPattern(type, getTeam(), loc, rotationAngle, reflect);

example-bots/src/main/examplefuncsplayer/RobotPlayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public static void runSoldier(RobotController rc) throws GameActionException{
155155
rc.move(dir);
156156
// Mark the pattern we need to draw to build a tower here if we haven't already.
157157
MapLocation shouldBeMarked = curRuin.getMapLocation().subtract(dir);
158-
if (rc.senseMapInfo(shouldBeMarked).getMark() == PaintType.EMPTY && rc.canMarkTowerPattern(targetLoc)){
158+
if (rc.senseMapInfo(shouldBeMarked).getMark() == PaintType.EMPTY && rc.canMarkTowerPattern(UnitType.LEVEL_ONE_PAINT_TOWER, targetLoc)){
159159
rc.markTowerPattern(UnitType.LEVEL_ONE_PAINT_TOWER, targetLoc);
160160
System.out.println("Trying to build a tower at " + targetLoc);
161161
}

0 commit comments

Comments
 (0)