Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions engine/src/main/battlecode/common/GameConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 32 additions & 0 deletions engine/src/main/battlecode/world/InternalRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

}
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -1337,6 +1349,7 @@ else if (this.controller.canAttack(nextLoc)) {
this.catTurnsStuck = 0;
}
}
this.catTurns += 1;
break;

case SEARCH:
Expand Down Expand Up @@ -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
Expand All @@ -1391,6 +1421,7 @@ else if (this.controller.canAttack(nextLoc)) {

if (!ratVisible) {
this.catState = CatStateType.EXPLORE;
this.catTurns = 0;
break;
}

Expand Down Expand Up @@ -1463,6 +1494,7 @@ else if (this.controller.canAttack(nextLoc)) {
this.catTurnsStuck = 0;
}
}
this.catTurns += 1;
break;
}
}
Expand Down
17 changes: 10 additions & 7 deletions engine/src/main/battlecode/world/RobotControllerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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);
Expand Down
Binary file modified specs/specs.pdf
Binary file not shown.