Skip to content

Commit

Permalink
Merge branch 'master' into public-release
Browse files Browse the repository at this point in the history
  • Loading branch information
TheApplePieGod committed Jan 22, 2025
2 parents 8b2a6a1 + 7dec04c commit 0d84876
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 15 deletions.
22 changes: 20 additions & 2 deletions client/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const CLIENT_VERSION = '2.0.3'
export const CLIENT_VERSION = '3.0.0'
export const SPEC_VERSION = '1'
export const BATTLECODE_YEAR: number = 2025
export const MAP_SIZE_RANGE = {
Expand Down Expand Up @@ -45,7 +45,25 @@ export const ENGINE_BUILTIN_MAP_NAMES: string[] = [
'SMILE',
'TargetPractice',
'UglySweater',
'UnderTheSea'
'UnderTheSea',

// Sprint 2
'giver',
'galaxy',
'leavemealone',
'sayhi',
'sierpinski',
'windmill',
'quack',
'gridworld',
'fix',
'Filter',
'BunnyGame',
'Bread',
'Snowglobe',
'Barcode',
'Flower',
'Piglets2'
]

export const TEAM_COLOR_NAMES = ['Silver', 'Gold']
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 @@ -134,7 +134,7 @@ public class GameConstants {
/** The percent of the defense tower damage buff that is applied to AoE attacks */
public static final int DEFENSE_ATTACK_BUFF_AOE_EFFECTIVENESS = 0;

/** Maximum amount of turns a robot can go at 0 paint without dying */
/** DEPRECATED: See NO_PAINT_DAMAGE */
public static final int MAX_TURNS_WITHOUT_PAINT = 10;

/** Percent of paint capacity at which a robot begins to face increased cooldowns */
Expand Down
10 changes: 6 additions & 4 deletions engine/src/main/battlecode/server/NetServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,21 @@ public void onOpen(WebSocket client, ClientHandshake handshake) {

@Override
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
System.out.println("Closed: "+conn.getRemoteSocketAddress() + " for "+reason);
System.out.println("Closed: " + conn.getRemoteSocketAddress() + " for " + reason);
}

@Override
public void onMessage(WebSocket ws, String s) {
System.err.println("Spurious message from "+
ws.getRemoteSocketAddress()+": `"+s+"`");
System.err.println("Spurious message from " + ws.getRemoteSocketAddress() + ": \"" + s + "\"");
}

@Override
public void onError(WebSocket conn, Exception ex) {
if (!(ex instanceof ClosedByInterruptException)) {
System.err.println("Error from: "+conn.getRemoteSocketAddress()+": "+ex);
if (conn != null)
System.err.println("Error from " + conn.getRemoteSocketAddress() + ": " + ex);
else
System.err.println("Error from [unopened WebSocket]: " + ex);
}
}
}
15 changes: 11 additions & 4 deletions engine/src/main/battlecode/world/GameWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,20 @@ public GameWorld(LiveMap gm, RobotControlProvider cp, GameMaker.MatchMaker match
towersByLoc[i] = Team.NEUTRAL;
}
for (int i = 0; i < initialBodies.length; i++) {
RobotInfo robot = initialBodies[i];
MapLocation newLocation = robot.location.translate(gm.getOrigin().x, gm.getOrigin().y);
spawnRobot(robot.ID, robot.type, newLocation, robot.team);
RobotInfo robotInfo = initialBodies[i];
MapLocation newLocation = robotInfo.location.translate(gm.getOrigin().x, gm.getOrigin().y);
spawnRobot(robotInfo.ID, robotInfo.type, newLocation, robotInfo.team);
this.towerLocations.add(newLocation);
towersByLoc[locationToIndex(newLocation)] = robot.team;
towersByLoc[locationToIndex(newLocation)] = robotInfo.team;
this.allRuinsByLoc[locationToIndex(newLocation)] = true;
this.allRuins.add(newLocation);

// Start initial towers at level 2. Defer upgrade action until the tower's first
// turn since client only supports actions this way
InternalRobot robot = getRobot(newLocation);
UnitType newType = robot.getType().getNextLevel();
robot.upgradeTower(newType);
upgradeTower(newType, robot.getTeam());
}
}

Expand Down
23 changes: 20 additions & 3 deletions engine/src/main/battlecode/world/InternalRobot.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,19 @@ public void towerAttack(MapLocation loc) {
}
}

public void mopSwing(Direction dir) { // NOTE: only works for moppers!
// swing even if there's not 3 robots there, just remove from existing
/**
* Special action exclusive to moppers.
* Given a cardinal direction, apply swing to adjacent square in that direction and that direction's diagonal directions.
* Also apply to squares directly behind those three.
* Example EAST SWING: mopper m, unaffected o, affected x.
* oooo
* oxxo
* mxxo
* oxxo
* oooo
*/
public void mopSwing(Direction dir) {
// swing even if robots in the swing map locations are missing, remove hp from the present enemy robots
if(this.type != UnitType.MOPPER)
throw new RuntimeException("Unit must be a mopper");
if(!(dir == Direction.SOUTH || dir == Direction.NORTH || dir == Direction.WEST || dir == Direction.EAST))
Expand All @@ -479,7 +490,7 @@ public void mopSwing(Direction dir) { // NOTE: only works for moppers!
else if(dir == Direction.WEST) dirIdx = 3;
ArrayList<Integer> affectedIDs = new ArrayList<>();

for(int i = 0; i < 6; i ++) { // check all three spots
for(int i = 0; i < 6; i ++) { // check all six affected MapLocations
int x = this.getLocation().x + dx[dirIdx][i], y = this.getLocation().y + dy[dirIdx][i];
MapLocation newLoc = new MapLocation(x, y);
if(!this.gameWorld.getGameMap().onTheMap(newLoc)) continue;
Expand Down Expand Up @@ -585,6 +596,12 @@ public void processBeginningOfRound() {
addPaint(this.type.paintPerTurn + this.gameWorld.extraResourcesFromPatterns(this.team));
if (this.type.moneyPerTurn != 0)
this.gameWorld.getTeamInfo().addMoney(this.team, this.type.moneyPerTurn+this.gameWorld.extraResourcesFromPatterns(this.team));

// Add upgrade action for initially upgraded starting towers
if (this.type.isTowerType() && this.gameWorld.getCurrentRound() == 1 && this.type.level == 2) {
this.getGameWorld().getMatchMaker().addUpgradeAction(getID(), getHealth(),
getType().health, getPaint(), getType().paintCapacity);
}
}

public void processBeginningOfTurn() {
Expand Down
17 changes: 16 additions & 1 deletion engine/src/main/battlecode/world/LiveMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,26 @@ public void assertIsValid() throws Exception{
}
int[] towerCountA = new int[3];
int[] towerCountB = new int[3];
int initialBodyCountTeamA = 0;
int initialBodyCountTeamB = 0;
for (RobotInfo initialBody : initialBodies){
if (initialBody.team == Team.A){
towerCountA[FlatHelpers.getRobotTypeFromUnitType(initialBody.type)-1] += 1;
initialBodyCountTeamA++;
}
else towerCountB[FlatHelpers.getRobotTypeFromUnitType(initialBody.type)-1] += 1;
else if (initialBody.team == Team.B){
towerCountB[FlatHelpers.getRobotTypeFromUnitType(initialBody.type)-1] += 1;
initialBodyCountTeamB++;
}
else {
throw new RuntimeException("Expected initial body team " + initialBody.team + " to be team A or team B!");
}
}
if (initialBodyCountTeamA != GameConstants.NUMBER_INITIAL_TOWERS) {
throw new RuntimeException("Expected to have " + GameConstants.NUMBER_INITIAL_TOWERS + " team A towers!");
}
if (initialBodyCountTeamB != GameConstants.NUMBER_INITIAL_TOWERS) {
throw new RuntimeException("Expected to have " + GameConstants.NUMBER_INITIAL_TOWERS + " team B towers!");
}
if (towerCountA[FlatHelpers.getRobotTypeFromUnitType(UnitType.LEVEL_ONE_PAINT_TOWER) - 1] != GameConstants.NUMBER_INITIAL_PAINT_TOWERS){
throw new RuntimeException("Expected to have " + GameConstants.NUMBER_INITIAL_PAINT_TOWERS + " paint towers!");
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified specs/specs.pdf
Binary file not shown.

0 comments on commit 0d84876

Please sign in to comment.