diff --git a/engine/src/main/battlecode/common/GameConstants.java b/engine/src/main/battlecode/common/GameConstants.java index 5045b608..a8466f6d 100644 --- a/engine/src/main/battlecode/common/GameConstants.java +++ b/engine/src/main/battlecode/common/GameConstants.java @@ -155,6 +155,9 @@ public class GameConstants { /** The maximum distance from a robot for building traps or dirt */ public static final int BUILD_DISTANCE_SQUARED = 2; + /** The maximum distance from a cat for building traps or dirt, measured from cat center*/ + public static final float CAT_BUILD_DISTANCE_SQUARED = 4.5f; + /** * The maximum distance squared a rat king can build traps or dirt, * measured from the king's center. All rats (including rat kings) diff --git a/engine/src/main/battlecode/world/InternalRobot.java b/engine/src/main/battlecode/world/InternalRobot.java index 116b96f3..8885fce8 100644 --- a/engine/src/main/battlecode/world/InternalRobot.java +++ b/engine/src/main/battlecode/world/InternalRobot.java @@ -931,7 +931,12 @@ public void pounce(int[] delta) { if (crushedRobot != null && (crushedRobot.getID() != this.ID)) { // destroy robot + if (crushedRobot.isCarryingRobot()){ + InternalRobot carriedRobot = crushedRobot.getRobotBeingCarried(); + carriedRobot.addHealth(-carriedRobot.getHealth()); + } crushedRobot.addHealth(-crushedRobot.getHealth()); + } } @@ -1264,6 +1269,12 @@ else if (this.type == UnitType.CAT) { case CHASE: + if (this.catTurns >= 10) { + this.catTurns = 0; + this.catState = CatStateType.EXPLORE; + break; + } + dir = this.gameWorld.getBfsDir(getCatCornerByChirality(), this.catTargetLoc, this.chirality); if (dir == null) { @@ -1279,6 +1290,7 @@ else if (this.type == UnitType.CAT) { for (MapLocation partLoc : partLocs) { if (partLoc.distanceSquaredTo(this.catTargetLoc) <= 2) { this.catState = CatStateType.SEARCH; + this.catTurns = 0; } } @@ -1337,6 +1349,7 @@ else if (this.controller.canAttack(nextLoc)) { this.catTurnsStuck = 0; } } + this.catTurns += 1; break; case SEARCH: @@ -1369,12 +1382,29 @@ else if (this.controller.canAttack(nextLoc)) { this.catTargetLoc = rat.getLocation(); this.catTarget = rat; this.catState = CatStateType.ATTACK; + this.catTurns = 0; } this.catTurns += 1; break; case ATTACK: + + if (this.catTurns == 10) { + if (this.chirality == 0) this.dir = this.dir.rotateRight().rotateRight(); + else this.dir = this.dir.rotateLeft().rotateLeft(); + + this.catTurns += 1; + break; + } + else if (this.catTurns == 11){ + if (this.chirality == 0) this.dir = this.dir.rotateRight().rotateRight(); + else this.dir = this.dir.rotateLeft().rotateLeft(); + + this.catTurns = 0; + this.catState = CatStateType.EXPLORE; + break; + } // step 1: try to find the rat it was attacking, if cannot find it go back to // explore @@ -1391,6 +1421,7 @@ else if (this.controller.canAttack(nextLoc)) { if (!ratVisible) { this.catState = CatStateType.EXPLORE; + this.catTurns = 0; break; } @@ -1463,6 +1494,7 @@ else if (this.controller.canAttack(nextLoc)) { this.catTurnsStuck = 0; } } + this.catTurns += 1; break; } } diff --git a/engine/src/main/battlecode/world/RobotControllerImpl.java b/engine/src/main/battlecode/world/RobotControllerImpl.java index 2f4a25f7..b1ba5ed3 100644 --- a/engine/src/main/battlecode/world/RobotControllerImpl.java +++ b/engine/src/main/battlecode/world/RobotControllerImpl.java @@ -205,7 +205,7 @@ private void assertCanSenseLocation(MapLocation loc) throws GameActionException "Target location not within vision range"); } - private void assertCanActLocation(MapLocation loc, int maxRadiusSquared) throws GameActionException { + private void assertCanActLocation(MapLocation loc, float maxRadiusSquared) throws GameActionException { // assumes maxRadiusSquared <= visionRadiusSquared. // This handles the angle checking, so we only check distance. assertCanSenseLocation(loc); @@ -239,9 +239,8 @@ private void assertCanPlaceDirt(MapLocation loc) throws GameActionException { assertIsActionReady(); assertIsRobotType(myType); - assertCanActLocation(loc, myType == UnitType.RAT_KING - ? GameConstants.RAT_KING_BUILD_DISTANCE_SQUARED - : GameConstants.BUILD_DISTANCE_SQUARED); + float myBuildRadiusSquared = myType == UnitType.RAT_KING ? GameConstants.RAT_KING_BUILD_DISTANCE_SQUARED : (myType == UnitType.CAT ? GameConstants.CAT_BUILD_DISTANCE_SQUARED : GameConstants.BUILD_DISTANCE_SQUARED); + assertCanActLocation(loc, myBuildRadiusSquared); // state checks : if (this.gameWorld.getTeamInfo().getDirt(this.robot.getTeam()) <= 0) @@ -263,9 +262,9 @@ private void assertCanRemoveDirt(MapLocation loc) throws GameActionException { assertIsActionReady(); assertIsRobotType(myType); - assertCanActLocation(loc, myType == UnitType.RAT_KING - ? GameConstants.RAT_KING_BUILD_DISTANCE_SQUARED - : GameConstants.BUILD_DISTANCE_SQUARED); + + float myBuildRadiusSquared = myType == UnitType.RAT_KING ? GameConstants.RAT_KING_BUILD_DISTANCE_SQUARED : (myType == UnitType.CAT ? GameConstants.CAT_BUILD_DISTANCE_SQUARED : GameConstants.BUILD_DISTANCE_SQUARED); + assertCanActLocation(loc, myBuildRadiusSquared); if ((this.robot.getType().isBabyRatType() || this.robot.getType().isRatKingType()) && (this.getAllCheese() < GameConstants.DIG_DIRT_CHEESE_COST)) @@ -847,6 +846,10 @@ public void move(Direction d) throws GameActionException { if (crushedRobot != null && this.getID() != crushedRobot.getID() && this.getType().isCatType() && crushedRobot.getType().isBabyRatType()) { // kill this rat + if (crushedRobot.isCarryingRobot()){ + InternalRobot carriedRobot = crushedRobot.getRobotBeingCarried(); + carriedRobot.addHealth(-carriedRobot.getHealth()); + } crushedRobot.addHealth(-crushedRobot.getHealth()); } // processTrapsAtLocation(newLoc); diff --git a/specs/specs.pdf b/specs/specs.pdf index 788cb4e7..d3a61864 100644 Binary files a/specs/specs.pdf and b/specs/specs.pdf differ