Skip to content

Commit

Permalink
Merge branch 'main' into javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mao authored Jan 2, 2022
2 parents 3c8b672 + 990687c commit 8328d1d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 20 deletions.
4 changes: 1 addition & 3 deletions engine/src/main/battlecode/common/AnomalyType.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public enum AnomalyType {
* The values of {@link #globalPercentage} and {@link #sagePercentage} are
* unused.
*/
VORTEX (true, false, 0, 0),

SINGULARITY (true, false, 0, 0);
VORTEX (true, false, 0, 0);

/**
* Whether this type of Anomaly could appear in the global schedule.
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/battlecode/common/GameConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class GameConstants {
// *********************************

/** A blueprint building's health, as a multiplier of max health. */
public static final float PROTOTYPE_HP_PERCENTAGE = 0.9f;
public static final float PROTOTYPE_HP_PERCENTAGE = 0.6f;

/** The multiplier for reclaiming a building's cost. */
public static final float RECLAIM_COST_MULTIPLIER = 0.2f;
Expand Down
21 changes: 16 additions & 5 deletions engine/src/main/battlecode/common/RobotController.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,25 @@ public strictfp interface RobotController {
boolean canSenseRadiusSquared(int radiusSquared);

/**
* Checks whether a robot is at a given location. Assumes the location is valid.
* Checks whether a robot is at a given location. Assumes the location is valid.
*
* @param loc the location to check
* @return true if a robot is at the location
* @throws GameActionException if the location is not within vision range or on the map
*
* @battlecode.doc.costlymethod
*/
boolean canSenseRobotAtLocation(MapLocation loc) throws GameActionException;
boolean isLocationOccupied(MapLocation loc) throws GameActionException;

/**
* Checks whether a robot is at a given location. Assume the location is valid.
*
* @param loc the location to check
* @return true if a robot is at the location, false if there is no robot or the location can not be sensed.
*
* @battlecode.doc.costlymethod
*/
boolean canSenseRobotAtLocation(MapLocation loc);

/**
* Senses the robot at the given location, or null if there is no robot
Expand Down Expand Up @@ -379,7 +389,7 @@ public strictfp interface RobotController {
*
* @battlecode.doc.costlymethod
*/
double getActionCooldownTurns();
int getActionCooldownTurns();

/**
* Tests whether the robot can move.
Expand All @@ -400,7 +410,7 @@ public strictfp interface RobotController {
*
* @battlecode.doc.costlymethod
*/
double getMovementCooldownTurns();
int getMovementCooldownTurns();

/**
* Tests whether the robot can transform.
Expand All @@ -421,10 +431,11 @@ public strictfp interface RobotController {
* {@link GameConstants#COOLDOWNS_PER_TURN} every turn.
*
* @return the number of cooldown turns remaining before this unit can transform again
* @throws GameActionException if the robot's mode is not TURRET or PORTABLE
*
* @battlecode.doc.costlymethod
*/
double getTransformCooldownTurns();
int getTransformCooldownTurns() throws GameActionException;

// ***********************************
// ****** MOVEMENT METHODS ***********
Expand Down
3 changes: 2 additions & 1 deletion engine/src/main/battlecode/common/RobotType.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public boolean canBuild(RobotType builtType) {
*/
public boolean canAttack() {
return (this == WATCHTOWER
|| this == SOLDIER);
|| this == SOLDIER
|| this == SAGE);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions engine/src/main/battlecode/world/LiveMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ public LiveMap(int width,
Arrays.fill(this.rubbleArray, 1); // default cooldown factor is 1
this.leadArray = new int[width * height]; // TODO: we guarantee there to be lead within vision range of archons

this.anomalySchedule = new AnomalyScheduleEntry[1];
this.anomalySchedule[0] = new AnomalyScheduleEntry(GameConstants.GAME_MAX_NUMBER_OF_ROUNDS, AnomalyType.SINGULARITY);
this.anomalySchedule = new AnomalyScheduleEntry[0];
this.nextAnomalyIndex = 0;

// invariant: bodies is sorted by id
Expand Down
22 changes: 14 additions & 8 deletions engine/src/main/battlecode/world/RobotControllerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,18 @@ public boolean canSenseRadiusSquared(int radiusSquared) {
}

@Override
public boolean canSenseRobotAtLocation(MapLocation loc) throws GameActionException {
public boolean isLocationOccupied(MapLocation loc) throws GameActionException {
assertCanSenseLocation(loc);
return this.gameWorld.getRobot(loc) != null;
}

@Override
public boolean canSenseRobotAtLocation(MapLocation loc) {
try {
return isLocationOccupied(loc);
} catch (GameActionException e) { return false; }
}

@Override
public RobotInfo senseRobotAtLocation(MapLocation loc) throws GameActionException {
assertCanSenseLocation(loc);
Expand Down Expand Up @@ -301,10 +308,6 @@ public MapLocation[] getAllLocationsWithinRadiusSquared(MapLocation center, int
// ****** READINESS METHODS **********
// ***********************************

private boolean isLocationOccupied(MapLocation loc) throws GameActionException {
return this.gameWorld.getRobot(loc) != null;
}

private void assertIsActionReady() throws GameActionException {
if (!this.robot.getMode().canAct)
throw new GameActionException(CANT_DO_THAT,
Expand All @@ -323,7 +326,7 @@ public boolean isActionReady() {
}

@Override
public double getActionCooldownTurns() {
public int getActionCooldownTurns() {
return this.robot.getActionCooldownTurns();
}

Expand All @@ -345,7 +348,7 @@ public boolean isMovementReady() {
}

@Override
public double getMovementCooldownTurns() {
public int getMovementCooldownTurns() {
return this.robot.getMovementCooldownTurns();
}

Expand All @@ -368,7 +371,10 @@ public boolean isTransformReady() {
}

@Override
public double getTransformCooldownTurns() {
public int getTransformCooldownTurns() throws GameActionException {
if (!this.robot.getMode().canTransform)
throw new GameActionException(CANT_DO_THAT,
"This robot is not in a mode that can transform.");
return this.robot.getTransformCooldownTurns();
}

Expand Down

0 comments on commit 8328d1d

Please sign in to comment.