Skip to content

Commit

Permalink
fix sensing and cooldown multipliers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Gonzalez Hermosillo committed Jan 1, 2025
1 parent 3e96b6d commit f96c536
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
12 changes: 6 additions & 6 deletions engine/src/main/battlecode/common/GameConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ public class GameConstants {
/** Maximum amount of turns a robot can go at 0 paint without dying */
public static final int MAX_TURNS_WITHOUT_PAINT = 10;

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

/** Intercept in the formula for the movement cooldown */
public static final int MOVEMENT_COOLDOWN_INTERCEPT = 100;
/** Intercept in the formula for the increased cooldown */
public static final int INCREASED_COOLDOWN_INTERCEPT = 100;

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

/** Multiplier for paint penalties moppers face for ending on non-ally territory. */
public static final int MOPPER_PAINT_PENALTY_MULTIPLIER = 2;
Expand Down
13 changes: 10 additions & 3 deletions engine/src/main/battlecode/world/InternalRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ public void upgradeTower(UnitType newType) {
* Resets the action cooldown.
*/
public void addActionCooldownTurns(int numActionCooldownToAdd) {
int paintPercentage = (int) Math.round(this.paintAmount * 100.0/ this.type.paintCapacity);
if (paintPercentage < GameConstants.INCREASED_COOLDOWN_THRESHOLD && type.isRobotType()) {
numActionCooldownToAdd = (int) Math.round(numActionCooldownToAdd
* (GameConstants.INCREASED_COOLDOWN_INTERCEPT + GameConstants.INCREASED_COOLDOWN_SLOPE * paintPercentage)
/ 100.0);
}
setActionCooldownTurns(this.actionCooldownTurns + numActionCooldownToAdd);
}

Expand All @@ -272,9 +278,10 @@ public void addActionCooldownTurns(int numActionCooldownToAdd) {
*/
public void addMovementCooldownTurns() {
int movementCooldown = GameConstants.MOVEMENT_COOLDOWN;
if (paintAmount < GameConstants.MOVEMENT_COOLDOWN) {
movementCooldown = (int) Math.round(GameConstants.MOVEMENT_COOLDOWN
* (GameConstants.MOVEMENT_COOLDOWN_INTERCEPT + GameConstants.MOVEMENT_COOLDOWN_SLOPE * paintAmount)
int paintPercentage = (int) Math.round(this.paintAmount * 100.0/ this.type.paintCapacity);
if (paintPercentage < GameConstants.INCREASED_COOLDOWN_THRESHOLD && type.isRobotType()) {
movementCooldown = (int) Math.round(movementCooldown
* (GameConstants.INCREASED_COOLDOWN_INTERCEPT + GameConstants.INCREASED_COOLDOWN_SLOPE * paintPercentage)
/ 100.0);
}
this.setMovementCooldownTurns(this.movementCooldownTurns + movementCooldown);
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/battlecode/world/RobotControllerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public RobotInfo senseRobotAtLocation(MapLocation loc) throws GameActionExceptio
@Override
public boolean canSenseRobot(int id) {
InternalRobot sensedRobot = getRobotByID(id);
return sensedRobot == null || canSenseLocation(sensedRobot.getLocation());
return sensedRobot != null && canSenseLocation(sensedRobot.getLocation());
}

@Override
Expand Down

0 comments on commit f96c536

Please sign in to comment.