Skip to content

Commit d4a09d2

Browse files
committed
rename rat to baby rat
1 parent e262883 commit d4a09d2

8 files changed

Lines changed: 51 additions & 51 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public enum UnitType {
44
// health, size, speed, visionRadius, actionCooldown
5-
RAT(100, 1, 5, 20, 90, 10, 10, 10000),
5+
BABY_RAT(100, 1, 5, 20, 90, 10, 10, 10000),
66
RAT_KING(500, 3, 1, 29, 360, 10, 40, 20000),
77
CAT(2000, 2, 10, 37, 180, 15, 10, 10);
88

@@ -35,19 +35,19 @@ public boolean usesBottomLeftLocationForDistance() {
3535
}
3636

3737
public boolean isRobotType() {
38-
return this == RAT || this == CAT || this == RAT_KING;
38+
return this == BABY_RAT || this == CAT || this == RAT_KING;
3939
}
4040

4141
public boolean isThrowableType() {
42-
return this == RAT;
42+
return this == BABY_RAT;
4343
}
4444

4545
public boolean isThrowingType() {
46-
return this == RAT;
46+
return this == BABY_RAT;
4747
}
4848

49-
public boolean isRatType() {
50-
return this == RAT;
49+
public boolean isBabyRatType() {
50+
return this == BABY_RAT;
5151
}
5252

5353
public boolean isRatKingType() {

engine/src/main/battlecode/util/FlatHelpers.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static TrapType getTrapTypeFromSchemaTrapType(byte b) {
5252
public static UnitType getUnitTypeFromRobotType(byte b) {
5353
switch (b) {
5454
case 1:
55-
return UnitType.RAT;
55+
return UnitType.BABY_RAT;
5656
case 2:
5757
return UnitType.RAT_KING;
5858
case 3:
@@ -64,7 +64,7 @@ public static UnitType getUnitTypeFromRobotType(byte b) {
6464

6565
public static byte getRobotTypeFromUnitType(UnitType type) {
6666
switch (type) {
67-
case RAT:
67+
case BABY_RAT:
6868
return 1;
6969
case RAT_KING:
7070
return 2;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ public boolean setWinnerIfMoreRatsAlive() {
829829
int[] totalRobotsAlive = new int[2];
830830

831831
for (UnitType type : UnitType.values()) {
832-
if (type.isRatType()) {
832+
if (type.isBabyRatType() || type.isRatKingType()) {
833833
totalRobotsAlive[Team.A.ordinal()] += this.getObjectInfo().getRobotTypeCount(Team.A, type);
834834
totalRobotsAlive[Team.B.ordinal()] += this.getObjectInfo().getRobotTypeCount(Team.B, type);
835835
}
@@ -939,7 +939,7 @@ public void processEndOfRound() {
939939

940940
Team[] teams = {Team.A, Team.B};
941941
for (Team t : teams){
942-
this.matchMaker.addTeamInfo(t, this.teamInfo.getCheese(t), this.teamInfo.getCheeseCollected(t), this.teamInfo.getDamageToCats(t), this.teamInfo.getNumRatKings(t), this.teamInfo.getNumRats(t), this.teamInfo.getDirt(t), this.getTrapCount(TrapType.RAT_TRAP, t), this.getTrapCount(TrapType.CAT_TRAP, t));
942+
this.matchMaker.addTeamInfo(t, this.teamInfo.getCheese(t), this.teamInfo.getCheeseCollected(t), this.teamInfo.getDamageToCats(t), this.teamInfo.getNumRatKings(t), this.teamInfo.getNumBabyRats(t), this.teamInfo.getDirt(t), this.getTrapCount(TrapType.RAT_TRAP, t), this.getTrapCount(TrapType.CAT_TRAP, t));
943943
}
944944
this.teamInfo.processEndOfRound();
945945

@@ -977,8 +977,8 @@ public int spawnRobot(int ID, UnitType type, MapLocation location, Direction dir
977977
objectInfo.createRobot(robot);
978978
controlProvider.robotSpawned(robot);
979979

980-
if (type.isRatType()) {
981-
this.teamInfo.addRats(1, team);
980+
if (type.isBabyRatType()) {
981+
this.teamInfo.addBabyRats(1, team);
982982
} else if (type.isRatKingType()) {
983983
this.teamInfo.addRatKings(1, team);
984984
} else if (type.isCatType()) {
@@ -1057,8 +1057,8 @@ public void destroyRobot(int id, boolean fromException, boolean fromDamage) {
10571057
MapLocation loc = robot.getLocation();
10581058

10591059
if (loc != null) {
1060-
if (robot.getType().isRatType()) {
1061-
this.teamInfo.addRats(-1, robotTeam);
1060+
if (robot.getType().isBabyRatType()) {
1061+
this.teamInfo.addBabyRats(-1, robotTeam);
10621062
} else if (robot.getType().isRatKingType()) {
10631063
this.teamInfo.addRatKings(-1, robotTeam);
10641064
} else if (robot.getType().isCatType()) {

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ public void addActionCooldownTurns(int numActionCooldownToAdd) {
440440
int cooldownUp = numActionCooldownToAdd
441441
* (int) (this.carryingRobot != null ? GameConstants.CARRY_COOLDOWN_MULTIPLIER : 1); // TODO add support
442442
// for rat towers???
443-
if (getType() == UnitType.RAT) {
443+
if (getType() == UnitType.BABY_RAT) {
444444
cooldownUp = (int) (((double)cooldownUp)*(1.0 + this.cheeseAmount*GameConstants.CHEESE_COOLDOWN_PENALTY));
445445
}
446446
setActionCooldownTurns(this.actionCooldownTurns + cooldownUp);
@@ -451,15 +451,15 @@ public void addActionCooldownTurns(int numActionCooldownToAdd) {
451451
*/
452452
public void addMovementCooldownTurns(Direction d) {
453453
int movementCooldown = this.getType().movementCooldown;
454-
if (getType() == UnitType.RAT && this.dir != d) {
454+
if (getType() == UnitType.BABY_RAT && this.dir != d) {
455455
movementCooldown = GameConstants.MOVE_STRAFE_COOLDOWN;
456456
}
457457
movementCooldown *= (int) (this.carryingRobot != null ? GameConstants.CARRY_COOLDOWN_MULTIPLIER : 1); // TODO
458458
// add
459459
// support
460460
// for rat
461461
// towers???
462-
if (getType() == UnitType.RAT) {
462+
if (getType() == UnitType.BABY_RAT) {
463463
movementCooldown = (int) (((double)movementCooldown)*(1.0 + this.cheeseAmount*GameConstants.CHEESE_COOLDOWN_PENALTY));
464464
}
465465
this.setMovementCooldownTurns(this.movementCooldownTurns + movementCooldown);
@@ -829,7 +829,7 @@ public void travelFlying(boolean isSecondMove) {
829829
*/
830830
public void attack(MapLocation loc) {
831831
switch (this.getType()) {
832-
case RAT, RAT_KING:
832+
case BABY_RAT, RAT_KING:
833833
bite(loc, -1);
834834
break;
835835
case CAT:
@@ -849,7 +849,7 @@ public void attack(MapLocation loc) {
849849
*/
850850
public void attack(MapLocation loc, int cheese) {
851851
switch (this.getType()) {
852-
case RAT, RAT_KING:
852+
case BABY_RAT, RAT_KING:
853853
bite(loc, cheese);
854854
break;
855855
case CAT:
@@ -1072,7 +1072,7 @@ public void processBeginningOfTurn() {
10721072
this.sentMessagesCount = 0;
10731073

10741074
// if rat is being carried
1075-
if (this.getType() == UnitType.RAT && this.isGrabbedByRobot()
1075+
if (this.getType() == UnitType.BABY_RAT && this.isGrabbedByRobot()
10761076
&& this.getGrabbedByRobot().getTeam() != this.getTeam()) {
10771077

10781078
// check if grabber has died
@@ -1101,7 +1101,7 @@ public void processBeginningOfTurn() {
11011101
}
11021102

11031103
// if baby rat is being thrown
1104-
if (this.getType() == UnitType.RAT && this.isBeingThrown()) {
1104+
if (this.getType() == UnitType.BABY_RAT && this.isBeingThrown()) {
11051105
// decrement first since we already moved once on the round where throwing was
11061106
// initiated?
11071107
this.remainingThrowDuration -= 1;
@@ -1163,7 +1163,7 @@ public void processEndOfTurn() {
11631163
RobotInfo rat = null;
11641164

11651165
for (RobotInfo r : nearbyRobots) {
1166-
if (r.getType().isRatType() || r.getType().isRatKingType()) {
1166+
if (r.getType().isBabyRatType() || r.getType().isRatKingType()) {
11671167
ratVisible = true;
11681168
rat = r;
11691169
}
@@ -1282,7 +1282,7 @@ public void processEndOfTurn() {
12821282
rat = null;
12831283

12841284
for (RobotInfo r : nearbyRobots) {
1285-
if (r.getType().isRatType() || r.getType().isRatKingType()) {
1285+
if (r.getType().isBabyRatType() || r.getType().isRatKingType()) {
12861286
ratVisible = true;
12871287
rat = r;
12881288
}

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private void assertCanRemoveDirt(MapLocation loc) throws GameActionException {
261261
assertIsRobotType(this.robot.getType());
262262
assertCanActLocation(loc, GameConstants.BUILD_DISTANCE_SQUARED);
263263

264-
if ((this.robot.getType().isRatType()
264+
if ((this.robot.getType().isBabyRatType()
265265
|| this.robot.getType().isRatKingType()) && (this.getAllCheese() < GameConstants.DIG_DIRT_CHEESE_COST))
266266
throw new GameActionException(CANT_DO_THAT, "Insufficient cheese to remove dirt!");
267267

@@ -413,7 +413,7 @@ public void removeDirt(MapLocation loc) throws GameActionException {
413413
assertCanRemoveDirt(loc);
414414
this.gameWorld.setDirt(loc, false);
415415
this.gameWorld.getTeamInfo().updateDirt(this.robot.getTeam(), false);
416-
if (this.robot.getType().isRatType() || this.robot.getType().isRatKingType())
416+
if (this.robot.getType().isBabyRatType() || this.robot.getType().isRatKingType())
417417
this.robot.addCheese(-1 * GameConstants.DIG_DIRT_CHEESE_COST);
418418

419419
this.robot.addActionCooldownTurns(GameConstants.DIG_COOLDOWN);
@@ -427,7 +427,7 @@ private void assertCanPickUpCheese(MapLocation loc) throws GameActionException {
427427

428428
if (this.gameWorld.getCheeseAmount(loc) <= 0)
429429
throw new GameActionException(CANT_DO_THAT, "No cheese at this location!");
430-
if (this.robot.getType() != UnitType.RAT && this.robot.getType() != UnitType.RAT_KING)
430+
if (this.robot.getType() != UnitType.BABY_RAT && this.robot.getType() != UnitType.RAT_KING)
431431
throw new GameActionException(CANT_DO_THAT, "Only rats can pick up cheese");
432432
}
433433

@@ -750,7 +750,7 @@ private void assertCanMove(Direction d) throws GameActionException {
750750
InternalRobot occupyingRobot = this.gameWorld.getRobot(loc);
751751
if ((occupyingRobot != null) && (occupyingRobot.getID() != this.robot.getID())) {
752752

753-
if (occupyingRobot.getType().isRatType() && this.getType().isCatType()) {
753+
if (occupyingRobot.getType().isBabyRatType() && this.getType().isCatType()) {
754754
System.out.println("Cat killed a rat by stepping on it");
755755
} else {
756756
System.out.println("DEBUGGING: " + this.robot.getID() + " collision with robot of type "
@@ -807,7 +807,7 @@ public void processTrapsAtLocation(MapLocation loc) {
807807
for (int j = this.gameWorld.getTrapTriggers(loc).size() - 1; j >= 0; j--) {
808808
Trap trap = this.gameWorld.getTrapTriggers(loc).get(j);
809809
TrapType type = trap.getType();
810-
boolean wrongTrapType = ((this.getType().isRatType() || this.getType().isRatKingType())
810+
boolean wrongTrapType = ((this.getType().isBabyRatType() || this.getType().isRatKingType())
811811
&& type == TrapType.CAT_TRAP)
812812
|| (this.getType().isCatType() && type == TrapType.RAT_TRAP);
813813

@@ -830,7 +830,7 @@ public void move(Direction d) throws GameActionException {
830830
MapLocation newLoc = curLocs[i].add(d);
831831
InternalRobot crushedRobot = this.gameWorld.getRobot(newLoc);
832832
if (crushedRobot != null && this.getID() != crushedRobot.getID() && this.getType().isCatType()
833-
&& crushedRobot.getType().isRatType()) {
833+
&& crushedRobot.getType().isBabyRatType()) {
834834
// kill this rat
835835
crushedRobot.addHealth(-crushedRobot.getHealth());
836836
}
@@ -873,7 +873,7 @@ public void turn(Direction d) throws GameActionException {
873873
@Override
874874
public int getCurrentRatCost() {
875875
return GameConstants.BUILD_ROBOT_BASE_COST +
876-
GameConstants.BUILD_ROBOT_COST_INCREASE * (this.gameWorld.getTeamInfo().getNumRats(getTeam())
876+
GameConstants.BUILD_ROBOT_COST_INCREASE * (this.gameWorld.getTeamInfo().getNumBabyRats(getTeam())
877877
/ GameConstants.NUM_ROBOTS_FOR_COST_INCREASE);
878878
}
879879

@@ -919,13 +919,13 @@ public boolean canBuildRobot(MapLocation loc) {
919919
public void buildRobot(MapLocation loc) throws GameActionException {
920920
assertCanBuildRobot(loc);
921921
this.robot.addActionCooldownTurns(GameConstants.BUILD_ROBOT_COOLDOWN);
922-
this.gameWorld.spawnRobot(UnitType.RAT, loc, this.getDirection(), this.robot.getChirality(),
922+
this.gameWorld.spawnRobot(UnitType.BABY_RAT, loc, this.getDirection(), this.robot.getChirality(),
923923
this.robot.getTeam());
924924
int cost = getCurrentRatCost();
925925
this.robot.addCheese(-cost);
926926
InternalRobot robotSpawned = this.gameWorld.getRobot(loc);
927927
this.gameWorld.getMatchMaker().addSpawnAction(robotSpawned.getID(), loc, this.robot.getDirection(),
928-
this.robot.getChirality(), getTeam(), UnitType.RAT);
928+
this.robot.getChirality(), getTeam(), UnitType.BABY_RAT);
929929
}
930930

931931
public void buildTrap(TrapType type, MapLocation loc) throws GameActionException {
@@ -964,7 +964,7 @@ private void assertCanAttack(MapLocation loc) throws GameActionException {
964964
}
965965

966966
switch (this.robot.getType()) {
967-
case RAT, RAT_KING:
967+
case BABY_RAT, RAT_KING:
968968
assertCanAttackRat(loc);
969969
break;
970970
case CAT:
@@ -1014,10 +1014,10 @@ public void assertCanBecomeRatKing() throws GameActionException {
10141014
for (Direction d : Direction.allDirections()) {
10151015
MapLocation curLoc = this.adjacentLocation(d);
10161016
InternalRobot curRobot = this.gameWorld.getRobot(curLoc);
1017-
if (curRobot != null && curRobot.getTeam() == this.robot.getTeam() && curRobot.getType() == UnitType.RAT) {
1017+
if (curRobot != null && curRobot.getTeam() == this.robot.getTeam() && curRobot.getType() == UnitType.BABY_RAT) {
10181018
numAllyRats += 1;
10191019
}
1020-
if (curRobot != null && !curRobot.getType().isRatType()) {
1020+
if (curRobot != null && !curRobot.getType().isBabyRatType()) {
10211021
throw new GameActionException(CANT_DO_THAT,
10221022
"Can't become a rat king when there are nearby cats or rat kings!");
10231023
}
@@ -1159,7 +1159,7 @@ private void assertCanTransferCheese(MapLocation loc, int amount) throws GameAct
11591159
if (robot.getTeam() != this.robot.getTeam()) {
11601160
throw new GameActionException(CANT_DO_THAT, "Cannot transfer resources to the enemy team!");
11611161
}
1162-
if (!this.robot.getType().isRatType()) {
1162+
if (!this.robot.getType().isBabyRatType()) {
11631163
throw new GameActionException(CANT_DO_THAT, "Only rats can transfer cheese!");
11641164
}
11651165
if (!robot.getType().isRatKingType()) {
@@ -1195,7 +1195,7 @@ public void transferCheese(MapLocation loc, int amount) throws GameActionExcepti
11951195
public void assertCanThrowRat(Direction dir) throws GameActionException {
11961196
assertIsActionReady();
11971197
MapLocation nextLoc = this.getLocation().add(dir);
1198-
if (!this.robot.getType().isRatType()) {
1198+
if (!this.robot.getType().isBabyRatType()) {
11991199
throw new GameActionException(CANT_DO_THAT, "Only rats can throw other rats!");
12001200
}
12011201
if (!this.robot.isCarryingRobot())
@@ -1211,7 +1211,7 @@ public void assertCanThrowRat(Direction dir) throws GameActionException {
12111211
public void assertCanDropRat(Direction dir) throws GameActionException {
12121212
assertIsActionReady();
12131213
MapLocation nextLoc = this.getLocation().add(dir);
1214-
if (!this.robot.getType().isRatType()) {
1214+
if (!this.robot.getType().isBabyRatType()) {
12151215
throw new GameActionException(CANT_DO_THAT, "Only rats can drop other rats!");
12161216
}
12171217
if (!this.robot.isCarryingRobot())
@@ -1261,7 +1261,7 @@ public void assertCanCarryRat(MapLocation loc) throws GameActionException {
12611261
assertIsActionReady();
12621262

12631263
// Must be a rat-type
1264-
if (!this.robot.getType().isRatType()) {
1264+
if (!this.robot.getType().isBabyRatType()) {
12651265
throw new GameActionException(CANT_DO_THAT, "Only rats can grab other rats!");
12661266
}
12671267

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class TeamInfo {
1717
private int[] dirtCounts;
1818
private int[] oldCheeseCounts;
1919
private int[] cheeseCollected;
20-
private int[] totalNumRats;
20+
private int[] numBabyRats;
2121
private int[] numRatKings;
2222
private int[] damageToCats;
2323
private int[] points;
@@ -33,7 +33,7 @@ public TeamInfo(GameWorld gameWorld) {
3333
this.dirtCounts = new int[2];
3434
this.oldCheeseCounts = new int[2];
3535
this.cheeseCollected = new int[2];
36-
this.totalNumRats = new int[2];
36+
this.numBabyRats = new int[2];
3737
this.damageToCats = new int[2];
3838
this.numRatKings = new int[2];
3939
this.points = new int[2];
@@ -81,8 +81,8 @@ public int getDirt(Team team) {
8181
* @param team the team to query
8282
* @return the number of rats the team has
8383
*/
84-
public int getNumRats(Team team) {
85-
return this.totalNumRats[team.ordinal()];
84+
public int getNumBabyRats(Team team) {
85+
return this.numBabyRats[team.ordinal()];
8686
}
8787

8888
/**
@@ -121,12 +121,12 @@ public int getPoints(Team team) {
121121

122122

123123
/**
124-
* Change the total number of rats belonging to a team
124+
* Change the total number of baby rats belonging to a team
125125
*
126126
* @param team the team to change
127127
*/
128-
public void addRats(int num, Team team) {
129-
this.totalNumRats[team.ordinal()] += num;
128+
public void addBabyRats(int num, Team team) {
129+
this.numBabyRats[team.ordinal()] += num;
130130
}
131131

132132
/**

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static void run(RobotController rc) throws GameActionException {
101101

102102
if (turnCount == 0) {
103103
// This is our first turn; we can perform any initial setup here.
104-
if (rc.getType() == battlecode.common.UnitType.RAT) {
104+
if (rc.getType() == battlecode.common.UnitType.BABY_RAT) {
105105
initBaby(rc);
106106
}
107107
}
@@ -112,7 +112,7 @@ public static void run(RobotController rc) throws GameActionException {
112112
try {
113113
if (rc.getType() == battlecode.common.UnitType.RAT_KING) {
114114
runKing(rc);
115-
} else if (rc.getType() == battlecode.common.UnitType.RAT) {
115+
} else if (rc.getType() == battlecode.common.UnitType.BABY_RAT) {
116116
runBaby(rc);
117117
}
118118
} catch (GameActionException e) {
@@ -278,7 +278,7 @@ public static void runBaby(RobotController rc) throws GameActionException {
278278
cheeseMineCount += 1;
279279
}
280280
for (RobotInfo bot : nearbyBots) {
281-
if (bot.getType() == UnitType.RAT && bot.getTeam() == rc.getTeam() && bot.getLocation().distanceSquaredTo(loc.getMapLocation()) <= 8) { // An ally has been spotted next to this cheese mine; we assume that he's got it covered
281+
if (bot.getType() == UnitType.BABY_RAT && bot.getTeam() == rc.getTeam() && bot.getLocation().distanceSquaredTo(loc.getMapLocation()) <= 8) { // An ally has been spotted next to this cheese mine; we assume that he's got it covered
282282
// TODO replace sensing with something done via soft squeaking
283283
if (Arrays.stream(occupiedCheeseMines).noneMatch(x -> x != null && x.equals(loc.getMapLocation()))) {
284284
occupiedCheeseMines[occupiedCheeseMineCount] = loc.getMapLocation();
@@ -334,7 +334,7 @@ public static boolean safe(RobotController rc, Direction d) throws GameActionExc
334334
return false;
335335
}
336336
MapLocation adjacentLocation = rc.getLocation().add(d);
337-
if (rc.getType() == UnitType.RAT) {
337+
if (rc.getType() == UnitType.BABY_RAT) {
338338
RobotInfo[] enemies = rc.senseNearbyRobots();
339339
for (RobotInfo enemy : enemies) {
340340
if (enemy.team != rc.getTeam()) {

0 commit comments

Comments
 (0)