Skip to content

Commit 6181e48

Browse files
committed
set max number of squeaks
1 parent 4dc7a66 commit 6181e48

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class GameConstants {
3434
public static final int MAX_DIRT_PERCENTAGE = 50;
3535

3636
/** The maximum percentage of the map that can be walls */
37-
public static final int MAX_WALL_PERCENTAGE = 20; // TODO remove if not using walls
37+
public static final int MAX_WALL_PERCENTAGE = 20;
3838

3939
// *********************************
4040
// ****** GAME PARAMETERS **********
@@ -62,7 +62,7 @@ public class GameConstants {
6262
public static final int INITIAL_TEAM_CHEESE = 2500;
6363

6464
/** The maximum number of rat kings that a team can have. */
65-
public static final int MAX_NUMBER_OF_RAT_KINGS = 5; // TODO need to specify!
65+
public static final int MAX_NUMBER_OF_RAT_KINGS = 5;
6666

6767
/**
6868
* The maximum execution time that can be spent on a team in one match. If the
@@ -133,9 +133,6 @@ public class GameConstants {
133133
/** The maximum distance from a robot for building traps or dirt */
134134
public static final int BUILD_DISTANCE_SQUARED = 2;
135135

136-
/** The maximum amount of bytes that can be encoded in a message */
137-
public static final int MAX_MESSAGE_BYTES = 4; // TODO need to spec messages as a whole!
138-
139136
/** The maximum squared radius a robot can send a message to */
140137
public static final int MESSAGE_RADIUS_SQUARED = 20; // TODO need to spec messages as a whole!
141138

@@ -146,7 +143,7 @@ public class GameConstants {
146143
public static final int MESSAGE_ROUND_DURATION = 5; // TODO need to spec messages as a whole!
147144

148145
/** The maximum number of messages a robot can send per turn */
149-
public static final int MAX_MESSAGES_SENT_ROBOT = 1; // TODO need to spec messages as a whole!
146+
public static final int MAX_MESSAGES_SENT_ROBOT = 1;
150147

151148
/** The maximum squared radius a robot can squeak to */
152149
public static final int SQUEAK_RADIUS_SQUARED = 16;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,10 +839,10 @@ public interface RobotController {
839839
*
840840
* @param messageContent an int representing the content of the
841841
* message (up to 4 bytes)
842-
*
842+
* @return true if squeak was sent, false if not (i.e. if reached max. number of messages fo this turn)
843843
* @battlecode.doc.costlymethod
844844
*/
845-
void squeak(int messageContent);
845+
boolean squeak(int messageContent);
846846

847847
/**
848848
* Reads all squeaks sent to this unit within the past 5 rounds if roundNum =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public int makeRobotTypeMetadata(FlatBufferBuilder builder) {
316316
RobotTypeMetadata.addMovementCooldown(builder, type.movementCooldown);
317317
RobotTypeMetadata.addVisionConeRadiusSquared(builder, type.visionConeRadiusSquared);
318318
RobotTypeMetadata.addVisionConeAngle(builder, type.visionConeAngle);
319-
RobotTypeMetadata.addMessageRadiusSquared(builder, GameConstants.MESSAGE_RADIUS_SQUARED);
319+
RobotTypeMetadata.addMessageRadiusSquared(builder, GameConstants.SQUEAK_RADIUS_SQUARED);
320320
robotTypeMetadataOffsets.add(RobotTypeMetadata.endRobotTypeMetadata(builder));
321321
}
322322
return GameHeader.createRobotTypeMetadataVector(builder, robotTypeMetadataOffsets.toNativeArray());

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,11 +1099,14 @@ public void becomeRatKing() throws GameActionException {
10991099
// ***********************************
11001100

11011101
@Override
1102-
public void squeak(int messageContent) {
1102+
public boolean squeak(int messageContent) {
1103+
if(this.robot.getSentMessagesCount() >= GameConstants.MAX_MESSAGES_SENT_ROBOT)
1104+
return false;
11031105
Message message = new Message(messageContent, this.robot.getID(), this.gameWorld.getCurrentRound(),
11041106
this.getLocation());
11051107
this.gameWorld.squeak(this.robot, message);
11061108
this.robot.incrementMessageCount();
1109+
return true;
11071110
}
11081111

11091112
@Override

0 commit comments

Comments
 (0)