Skip to content

Commit f96c536

Browse files
author
Ian Gonzalez Hermosillo
committed
fix sensing and cooldown multipliers
1 parent 3e96b6d commit f96c536

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ public class GameConstants {
119119
/** Maximum amount of turns a robot can go at 0 paint without dying */
120120
public static final int MAX_TURNS_WITHOUT_PAINT = 10;
121121

122-
/** Maximum percent amount of paint to start cooldown */
123-
public static final int DECREASED_MOVEMENT_THRESHOLD = 50;
122+
/** Percent of paint capacity at which a robot begins to face increased cooldowns */
123+
public static final int INCREASED_COOLDOWN_THRESHOLD = 50;
124124

125-
/** Intercept in the formula for the movement cooldown */
126-
public static final int MOVEMENT_COOLDOWN_INTERCEPT = 100;
125+
/** Intercept in the formula for the increased cooldown */
126+
public static final int INCREASED_COOLDOWN_INTERCEPT = 100;
127127

128-
/** Slope of paint in the formula for the movement cooldown */
129-
public static final int MOVEMENT_COOLDOWN_SLOPE = -2;
128+
/** Slope of paint in the formula for the increased cooldown */
129+
public static final int INCREASED_COOLDOWN_SLOPE = -2;
130130

131131
/** Multiplier for paint penalties moppers face for ending on non-ally territory. */
132132
public static final int MOPPER_PAINT_PENALTY_MULTIPLIER = 2;

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ public void upgradeTower(UnitType newType) {
264264
* Resets the action cooldown.
265265
*/
266266
public void addActionCooldownTurns(int numActionCooldownToAdd) {
267+
int paintPercentage = (int) Math.round(this.paintAmount * 100.0/ this.type.paintCapacity);
268+
if (paintPercentage < GameConstants.INCREASED_COOLDOWN_THRESHOLD && type.isRobotType()) {
269+
numActionCooldownToAdd = (int) Math.round(numActionCooldownToAdd
270+
* (GameConstants.INCREASED_COOLDOWN_INTERCEPT + GameConstants.INCREASED_COOLDOWN_SLOPE * paintPercentage)
271+
/ 100.0);
272+
}
267273
setActionCooldownTurns(this.actionCooldownTurns + numActionCooldownToAdd);
268274
}
269275

@@ -272,9 +278,10 @@ public void addActionCooldownTurns(int numActionCooldownToAdd) {
272278
*/
273279
public void addMovementCooldownTurns() {
274280
int movementCooldown = GameConstants.MOVEMENT_COOLDOWN;
275-
if (paintAmount < GameConstants.MOVEMENT_COOLDOWN) {
276-
movementCooldown = (int) Math.round(GameConstants.MOVEMENT_COOLDOWN
277-
* (GameConstants.MOVEMENT_COOLDOWN_INTERCEPT + GameConstants.MOVEMENT_COOLDOWN_SLOPE * paintAmount)
281+
int paintPercentage = (int) Math.round(this.paintAmount * 100.0/ this.type.paintCapacity);
282+
if (paintPercentage < GameConstants.INCREASED_COOLDOWN_THRESHOLD && type.isRobotType()) {
283+
movementCooldown = (int) Math.round(movementCooldown
284+
* (GameConstants.INCREASED_COOLDOWN_INTERCEPT + GameConstants.INCREASED_COOLDOWN_SLOPE * paintPercentage)
278285
/ 100.0);
279286
}
280287
this.setMovementCooldownTurns(this.movementCooldownTurns + movementCooldown);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public RobotInfo senseRobotAtLocation(MapLocation loc) throws GameActionExceptio
222222
@Override
223223
public boolean canSenseRobot(int id) {
224224
InternalRobot sensedRobot = getRobotByID(id);
225-
return sensedRobot == null || canSenseLocation(sensedRobot.getLocation());
225+
return sensedRobot != null && canSenseLocation(sensedRobot.getLocation());
226226
}
227227

228228
@Override

0 commit comments

Comments
 (0)