Skip to content

Commit

Permalink
Merge branch 'main' of github.com:battlecode/battlecode22 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav-arya committed Jan 10, 2022
2 parents c673e6c + ecf7476 commit 0130a2f
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 18 deletions.
2 changes: 1 addition & 1 deletion client/visualizer/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export enum Mode {
*/
export function defaults(supplied?: any): Config {
let conf: Config = {
gameVersion: "2022.0.2.0", //TODO: Change this on each release!
gameVersion: "2022.0.3.0", //TODO: Change this on each release!
fullscreen: false,
width: 600,
height: 600,
Expand Down
12 changes: 12 additions & 0 deletions deploy/deploy-javadoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ BUCKET_NAME="bc-game-storage"
# cd deploy

# TODO put this into a bucket, and configure properly, etc

read -p "IMPORTANT: Ensure that the docs are in the `javadoc` folder. Press enter to proceed..."

gsutil -m rm gs://$BUCKET_NAME/javadocs/2022/**
# Upload
cd ../javadoc
gsutil -m cp -r ** gs://$BUCKET_NAME/javadocs/2022/
cd ../deploy
# Enforce cache policy
gsutil -m setmeta -h "Cache-Control:no-cache" -r gs://$BUCKET_NAME/javadocs/2022/**
# TODO public check
gsutil -m acl ch -u AllUsers:R -r gs://$BUCKET_NAME/javadocs/2022/**
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 @@ -9,7 +9,7 @@ public class GameConstants {
/**
* The current spec version the server compiles with.
*/
public static final String SPEC_VERSION = "2022.0.2.0";
public static final String SPEC_VERSION = "2022.0.3.0";

// *********************************
// ****** MAP CONSTANTS ************
Expand Down
126 changes: 120 additions & 6 deletions engine/src/main/battlecode/common/RobotController.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,21 @@ public strictfp interface RobotController {
*/
int senseGold(MapLocation loc) throws GameActionException;

/**
* Return all locations that contain a nonzero amount of lead.
*
* @return all locations within vision radius that contain a nonzero amount of lead
*
* @battlecode.doc.costlymethod
*/
MapLocation[] senseNearbyLocationsWithLead();

/**
* Return all locations that contain a nonzero amount of lead, within a
* specified radius of your robot location.
* If radiusSquared is larger than the robot's vision radius, uses the robot's
* vision radius instead.
*
* Checks that radiusSquared is non-negative.
* vision radius instead. If -1 is passed, all locations with vision radius
* are returned.
*
* @param radiusSquared the squared radius of all locations to be returned
* @return all locations that contain a nonzero amount of lead within the radius
Expand All @@ -357,12 +365,69 @@ public strictfp interface RobotController {
MapLocation[] senseNearbyLocationsWithLead(int radiusSquared) throws GameActionException;

/**
* Return all locations that contain a nonzero amount of gold, within a
* Return all locations that contain a nonzero amount of lead, within a
* specified radius of a center location.
* If radiusSquared is larger than the robot's vision radius, uses the robot's
* vision radius instead. If -1 is passed, all locations with vision radius
* are returned.
*
* @param center the center of the search area
* @param radiusSquared the squared radius of all locations to be returned
* @return all locations that contain a nonzero amount of lead within the radius
* @throws GameActionException if the radius is negative
*
* @battlecode.doc.costlymethod
*/
MapLocation[] senseNearbyLocationsWithLead(MapLocation center, int radiusSquared) throws GameActionException;

/**
* Return all locations that contain at least a certain amount of lead, within a
* specified radius of your robot location.
* If radiusSquared is larger than the robot's vision radius, uses the robot's
* vision radius instead.
* vision radius instead. If -1 is passed, all locations with vision radius
* are returned.
*
* Checks that radiusSquared is non-negative.
* @param radiusSquared the squared radius of all locations to be returned
* @param minLead the minimum amount of lead
* @return all locations that contain at least minLead lead within the radius
* @throws GameActionException if the radius is negative
*
* @battlecode.doc.costlymethod
*/
MapLocation[] senseNearbyLocationsWithLead(int radiusSquared, int minLead) throws GameActionException;

/**
* Return all locations that contain at least a certain amount of lead, within a
* specified radius of a center location.
* If radiusSquared is larger than the robot's vision radius, uses the robot's
* vision radius instead. If -1 is passed, all locations with vision radius
* are returned.
*
* @param center the center of the search area
* @param radiusSquared the squared radius of all locations to be returned
* @param minLead the minimum amount of lead
* @return all locations that contain at least minLead lead within the radius
* @throws GameActionException if the radius is negative
*
* @battlecode.doc.costlymethod
*/
MapLocation[] senseNearbyLocationsWithLead(MapLocation center, int radiusSquared, int minLead) throws GameActionException;

/**
* Return all locations that contain a nonzero amount of gold.
*
* @return all locations within vision radius that contain a nonzero amount of gold
*
* @battlecode.doc.costlymethod
*/
MapLocation[] senseNearbyLocationsWithGold();

/**
* Return all locations that contain a nonzero amount of gold, within a
* specified radius of your robot location.
* If radiusSquared is larger than the robot's vision radius, uses the robot's
* vision radius instead. If -1 is passed, all locations with vision radius
* are returned.
*
* @param radiusSquared the squared radius of all locations to be returned
* @return all locations that contain a nonzero amount of gold within the radius
Expand All @@ -372,6 +437,55 @@ public strictfp interface RobotController {
*/
MapLocation[] senseNearbyLocationsWithGold(int radiusSquared) throws GameActionException;

/**
* Return all locations that contain a nonzero amount of gold, within a
* specified radius of a center location.
* If radiusSquared is larger than the robot's vision radius, uses the robot's
* vision radius instead. If -1 is passed, all locations with vision radius
* are returned.
*
* @param center the center of the search area
* @param radiusSquared the squared radius of all locations to be returned
* @return all locations that contain a nonzero amount of gold within the radius
* @throws GameActionException if the radius is negative
*
* @battlecode.doc.costlymethod
*/
MapLocation[] senseNearbyLocationsWithGold(MapLocation center, int radiusSquared) throws GameActionException;

/**
* Return all locations that contain at least a certain amount of gold, within a
* specified radius of your robot location.
* If radiusSquared is larger than the robot's vision radius, uses the robot's
* vision radius instead. If -1 is passed, all locations with vision radius
* are returned.
*
* @param radiusSquared the squared radius of all locations to be returned
* @param minGold the minimum amount of gold
* @return all locations that contain at least minGold gold within the radius
* @throws GameActionException if the radius is negative
*
* @battlecode.doc.costlymethod
*/
MapLocation[] senseNearbyLocationsWithGold(int radiusSquared, int minGold) throws GameActionException;

/**
* Return all locations that contain at least a certain amount of gold, within a
* specified radius of a center location.
* If radiusSquared is larger than the robot's vision radius, uses the robot's
* vision radius instead. If -1 is passed, all locations with vision radius
* are returned.
*
* @param center the center of the search area
* @param radiusSquared the squared radius of all locations to be returned
* @param minGold the minimum amount of gold
* @return all locations that contain at least minGold gold within the radius
* @throws GameActionException if the radius is negative
*
* @battlecode.doc.costlymethod
*/
MapLocation[] senseNearbyLocationsWithGold(MapLocation center, int radiusSquared, int minGold) throws GameActionException;

/**
* Returns the location adjacent to current location in the given direction.
*
Expand Down
1 change: 0 additions & 1 deletion engine/src/main/battlecode/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ private Team runMatch(GameInfo currentGame,

try {
loadedMap = GameMapIO.loadMap(mapName, new File(options.get("bc.game.map-path")));
debug("running map " + loadedMap);
} catch (IOException e) {
warn("Couldn't load map " + mapName + ", skipping");
throw e;
Expand Down
4 changes: 3 additions & 1 deletion engine/src/main/battlecode/world/InternalRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ public void transform() {
public void mutate() {
if (!canMutate()) return;
this.level++;
this.health += this.type.getMaxHealth(this.level) - this.type.getMaxHealth(this.level - 1);
int healthIncrease = this.type.getMaxHealth(this.level) - this.type.getMaxHealth(this.level - 1);
this.gameWorld.getMatchMaker().addAction(getID(), Action.CHANGE_HEALTH, healthIncrease);
this.health += healthIncrease;
}

/**
Expand Down
60 changes: 54 additions & 6 deletions engine/src/main/battlecode/world/RobotControllerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,31 +290,79 @@ public int senseGold(MapLocation loc) throws GameActionException {
return this.gameWorld.getGold(loc);
}

@Override
public MapLocation[] senseNearbyLocationsWithLead() {
try {
return senseNearbyLocationsWithLead(getLocation(), -1, 1);
} catch (GameActionException willNeverHappen) {
throw new RuntimeException("impossible", willNeverHappen);
}
}

@Override
public MapLocation[] senseNearbyLocationsWithLead(int radiusSquared) throws GameActionException {
return senseNearbyLocationsWithLead(getLocation(), radiusSquared, 1);
}

@Override
public MapLocation[] senseNearbyLocationsWithLead(MapLocation center, int radiusSquared) throws GameActionException {
return senseNearbyLocationsWithLead(center, radiusSquared, 1);
}

@Override
public MapLocation[] senseNearbyLocationsWithLead(int radiusSquared, int minLead) throws GameActionException {
return senseNearbyLocationsWithLead(getLocation(), radiusSquared, minLead);
}

@Override
public MapLocation[] senseNearbyLocationsWithLead(MapLocation center, int radiusSquared, int minLead) throws GameActionException {
radiusSquared = (radiusSquared == -1) ? getType().visionRadiusSquared : Math.min(radiusSquared, getType().visionRadiusSquared);
if (radiusSquared < 0)
throw new GameActionException(CANT_DO_THAT,
"Radius squared must be non-negative.");
radiusSquared = Math.min(radiusSquared, getType().visionRadiusSquared);
ArrayList<MapLocation> locations = new ArrayList<>();
for (MapLocation m : this.gameWorld.getAllLocationsWithinRadiusSquared(getLocation(), radiusSquared)) {
if (this.gameWorld.getLead(m) > 0) {
for (MapLocation m : this.gameWorld.getAllLocationsWithinRadiusSquared(center, radiusSquared)) {
if (this.gameWorld.getLead(m) >= minLead) {
locations.add(m);
}
}
MapLocation[] result = new MapLocation[locations.size()];
return locations.toArray(result);
}

@Override
public MapLocation[] senseNearbyLocationsWithGold() {
try {
return senseNearbyLocationsWithGold(getLocation(), -1, 1);
} catch (GameActionException willNeverHappen) {
throw new RuntimeException("impossible", willNeverHappen);
}
}

@Override
public MapLocation[] senseNearbyLocationsWithGold(int radiusSquared) throws GameActionException {
return senseNearbyLocationsWithGold(getLocation(), radiusSquared, 1);
}

@Override
public MapLocation[] senseNearbyLocationsWithGold(MapLocation center, int radiusSquared) throws GameActionException {
return senseNearbyLocationsWithGold(center, radiusSquared, 1);
}

@Override
public MapLocation[] senseNearbyLocationsWithGold(int radiusSquared, int minGold) throws GameActionException {
return senseNearbyLocationsWithGold(getLocation(), radiusSquared, minGold);
}

@Override
public MapLocation[] senseNearbyLocationsWithGold(MapLocation center, int radiusSquared, int minGold) throws GameActionException {
radiusSquared = (radiusSquared == -1) ? getType().visionRadiusSquared : Math.min(radiusSquared, getType().visionRadiusSquared);
if (radiusSquared < 0)
throw new GameActionException(CANT_DO_THAT,
"Radius squared must be non-negative.");
radiusSquared = Math.min(radiusSquared, getType().visionRadiusSquared);
ArrayList<MapLocation> locations = new ArrayList<>();
for (MapLocation m : this.gameWorld.getAllLocationsWithinRadiusSquared(getLocation(), radiusSquared)) {
if (this.gameWorld.getGold(m) > 0) {
for (MapLocation m : this.gameWorld.getAllLocationsWithinRadiusSquared(center, radiusSquared)) {
if (this.gameWorld.getGold(m) >= minGold) {
locations.add(m);
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ maps=maptestsmall
profilerEnabled=false
source=src
mapLocation=maps
release_version=2022.0.2.0
release_version=2022.0.3.0
3 changes: 3 additions & 0 deletions javadoc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
An otherwise-empty folder, to designate where javadocs should appear as they are deployed.

(This file allows GitHub to track the folder, so that its location can be properly known to users.)
13 changes: 12 additions & 1 deletion specs/specs.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# Formal specification

*This is the formal specification of the Battlecode 2022 game.* Current version: *2022.0.2.0*
*This is the formal specification of the Battlecode 2022 game.* Current version: *2022.0.3.0*

**Welcome to Battlecode 2022: Mutation.**

Expand Down Expand Up @@ -323,6 +323,16 @@

# Appendix: Changelog

- Version 2022.0.3.0 (January 9, 2022)
- Engine
- (New feature) Add overloads for sensing nearby locations with metals
- Do not dump debug map information at start of match
- Client
- Track HP change on mutations and fix DP display
- Running averages for lead and gold income
- Other
- Javadocs are 2022, not 2017

- Version 2022.0.2.0 (January 5, 2022)
- Engine
- (New feature) Add `rc.senseNearbyLocationsWithLead` and `rc.senseNearbyLocationsWithGold`
Expand All @@ -334,6 +344,7 @@
- Fix Vortex anomaly rendering
- Other
- Improvements to release scripts

- Version 2022.0.1.1 (January 4, 2022)
- Specs
- Clarify that Archons are not guaranteed to have ID at least 10,000
Expand Down

0 comments on commit 0130a2f

Please sign in to comment.