Skip to content

Commit fa4c3c5

Browse files
committed
updates by spec
1 parent 4d2cff4 commit fa4c3c5

File tree

6 files changed

+15
-34
lines changed

6 files changed

+15
-34
lines changed

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public class GameConstants {
134134
public static final int BUILD_DISTANCE_SQUARED = 2;
135135

136136
/** The maximum number of rounds a message will exist for */
137-
public static final int MESSAGE_ROUND_DURATION = 5; // TODO need to spec messages as a whole!
137+
public static final int MESSAGE_ROUND_DURATION = 5;
138138

139139
/** The maximum number of messages a robot can send per turn */
140140
public static final int MAX_MESSAGES_SENT_ROBOT = 1;
@@ -174,9 +174,6 @@ public class GameConstants {
174174
*/
175175
public static final int HEALTH_GRAB_THRESHOLD = 0;
176176

177-
/** The area effected by the cat's attack. */
178-
public static final int CAT_ATTACK_AOE_RADIUS_SQUARED = 4; // TODO need to specify!
179-
180177
/** The cheese cost for upgrading a rat into a rat king */
181178
public static final int RAT_KING_UPGRADE_CHEESE_COST = 50;
182179

@@ -186,8 +183,6 @@ public class GameConstants {
186183
/** The cheese cost to place a tile of dirt */
187184
public static final int PLACE_DIRT_CHEESE_COST = 10;
188185

189-
/** After this many turns, cats will begin moving if they haven't already. */
190-
public static final int CAT_GRACE_PERIOD = 100;
191186

192187
// *********************************
193188
// ****** COMMUNICATION ************
@@ -199,8 +194,6 @@ public class GameConstants {
199194
/** The maximum value of an integer in the shared array and persistent array. */
200195
public static final int COMM_ARRAY_MAX_VALUE = 1023;
201196

202-
/** The size of the persistent array. */
203-
public static final int PERSISTENT_ARRAY_SIZE = 5;
204197

205198
// *********************************
206199
// ****** COOLDOWNS ****************
@@ -215,12 +208,7 @@ public class GameConstants {
215208
/**
216209
* The amount added to the turning cooldown counter when turning
217210
*/
218-
public static final int TURNING_COOLDOWN = 5; // TODO not sure
219-
220-
/**
221-
* The amount added to the movement cooldown counter when a king moves
222-
*/
223-
public static final int DRAGGING_MOVEMENT_COOLDOWN = 15; // TODO need to specify!
211+
public static final int TURNING_COOLDOWN = 10;
224212

225213
/**
226214
* The amount added to the action cooldown counter after a king builds a robot
@@ -240,8 +228,7 @@ public class GameConstants {
240228
public static final int DIG_COOLDOWN = 25;
241229

242230
/**
243-
* The multiplier to the cooldowns when carrying another robot; TODO increases
244-
* exponentially when >1 robot is carried?
231+
* The multiplier to the cooldowns when carrying another robot
245232
*/
246233
public static final double CARRY_COOLDOWN_MULTIPLIER = 1.5;
247234

@@ -252,9 +239,7 @@ public class GameConstants {
252239
public static final int MAX_CARRY_DURATION = 10;
253240

254241
/**
255-
* The total number turns a rat can travel for while thrown (rats are stunned
256-
* while
257-
* thrown)
242+
* The total number turns a rat can travel for while thrown (rats are stunned while thrown)
258243
*/
259244
public static final int THROW_DURATION = 4;
260245

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ public interface RobotController {
345345
RobotInfo[] senseNearbyRobots(MapLocation center, int radiusSquared, Team team) throws GameActionException;
346346

347347
/**
348-
* Given a senseable location, returns whether that location is passable (a
349-
* wall).
348+
* Given a senseable location, returns whether that location is passable (i.e. no wall or dirt)
350349
*
351350
* @param loc the given location
352351
* @return whether that location is passable
@@ -511,7 +510,7 @@ public interface RobotController {
511510

512511
/**
513512
* Returns the number of turning cooldown turns remaining before this unit can
514-
* move again.
513+
* turn again.
515514
* When this number is strictly less than {@link GameConstants#COOLDOWN_LIMIT},
516515
* isTurningReady()
517516
* is true and the robot can turn again. This number decreases by
@@ -534,7 +533,7 @@ public interface RobotController {
534533
* location is not on the map, if the target location is occupied, if the target
535534
* location is impassible, or if there are cooldown turns remaining.
536535
*
537-
* @return true if it is possible to call <code>move</code> without an exception
536+
* @return true if it is possible to call <code>moveForward</code> without an exception
538537
*
539538
* @battlecode.doc.costlymethod
540539
*/

engine/src/main/battlecode/server/GameMaker.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
import static battlecode.util.FlatHelpers.*;
3232

33-
// TODO: new actions for this year's game and update all call sites
34-
3533
/**
3634
* Writes a game to a flatbuffer, hooray.
3735
*/

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ public GameWorld(LiveMap gm, RobotControlProvider cp, GameMaker.MatchMaker match
193193
}
194194

195195
this.sharedArray = new int[2][GameConstants.SHARED_ARRAY_SIZE];
196-
this.persistentArray = new int[2][GameConstants.PERSISTENT_ARRAY_SIZE];
197196
// TODO make persistent array last between matches
198197

199198
RobotInfo[] initialBodies = gm.getInitialBodies();

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ public void hitGround() {
785785
setActionCooldownTurns(this.actionCooldownTurns + GameConstants.HIT_GROUND_COOLDOWN);
786786
setTurningCooldownTurns(this.turningCooldownTurns + GameConstants.HIT_GROUND_COOLDOWN);
787787

788-
this.gameWorld.getMatchMaker().addStunAction(this.ID, GameConstants.HIT_TARGET_COOLDOWN);
788+
this.gameWorld.getMatchMaker().addStunAction(this.ID, GameConstants.HIT_GROUND_COOLDOWN);
789789
}
790790

791791
public void hitTarget(boolean isSecondMove) {
@@ -803,12 +803,12 @@ public void hitTarget(boolean isSecondMove) {
803803
if (this.health > 0){
804804
this.gameWorld.addRobot(this.location, this);
805805
}
806-
setMovementCooldownTurns(this.movementCooldownTurns + GameConstants.HIT_GROUND_COOLDOWN);
807-
setActionCooldownTurns(this.actionCooldownTurns + GameConstants.HIT_GROUND_COOLDOWN);
808-
setTurningCooldownTurns(this.turningCooldownTurns + GameConstants.HIT_GROUND_COOLDOWN);
806+
setMovementCooldownTurns(this.movementCooldownTurns + GameConstants.HIT_TARGET_COOLDOWN);
807+
setActionCooldownTurns(this.actionCooldownTurns + GameConstants.HIT_TARGET_COOLDOWN);
808+
setTurningCooldownTurns(this.turningCooldownTurns + GameConstants.HIT_TARGET_COOLDOWN);
809809
this.gameWorld.getMatchMaker().addDamageAction(this.ID, damage);
810810

811-
this.gameWorld.getMatchMaker().addStunAction(this.ID, GameConstants.HIT_GROUND_COOLDOWN);
811+
this.gameWorld.getMatchMaker().addStunAction(this.ID, GameConstants.HIT_TARGET_COOLDOWN);
812812
}
813813

814814
public void travelFlying(boolean isSecondMove) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,9 @@ public void assertCanBecomeRatKing() throws GameActionException {
10251025
if (this.gameWorld.getTeamInfo().getCheese(this.robot.getTeam()) < GameConstants.RAT_KING_UPGRADE_CHEESE_COST) {
10261026
throw new GameActionException(CANT_DO_THAT, "Not enough cheese to upgrade to a rat king");
10271027
}
1028+
if (this.gameWorld.getTeamInfo().getNumRatKings(this.robot.getTeam()) >= GameConstants.MAX_NUMBER_OF_RAT_KINGS){
1029+
throw new GameActionException(CANT_DO_THAT, "Cannot have more than " +GameConstants.MAX_NUMBER_OF_RAT_KINGS + "rat kings per team!" );
1030+
}
10281031
int numAllyRats = 0;
10291032
for (Direction d : Direction.allDirections()) {
10301033
MapLocation curLoc = this.adjacentLocation(d);
@@ -1140,9 +1143,6 @@ public int readSharedArray(int index) throws GameActionException {
11401143
public void writePersistentArray(int index, int value) throws GameActionException {
11411144
if (!this.getType().isRatKingType()) {
11421145
throw new GameActionException(CANT_DO_THAT, "Only rat kings can write to the persistent array!");
1143-
} else if (index < 0 || index >= GameConstants.PERSISTENT_ARRAY_SIZE) {
1144-
throw new GameActionException(CANT_DO_THAT,
1145-
"Index " + index + " is out of bounds for the persistent array!");
11461146
} else if (value < 0 || value > GameConstants.COMM_ARRAY_MAX_VALUE) {
11471147
throw new GameActionException(CANT_DO_THAT,
11481148
"Value " + value + " is out of bounds for the persistent array!");

0 commit comments

Comments
 (0)