Skip to content

Commit 0d84876

Browse files
committedJan 22, 2025··
Merge branch 'master' into public-release
2 parents 8b2a6a1 + 7dec04c commit 0d84876

23 files changed

+74
-15
lines changed
 

‎client/src/constants.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const CLIENT_VERSION = '2.0.3'
1+
export const CLIENT_VERSION = '3.0.0'
22
export const SPEC_VERSION = '1'
33
export const BATTLECODE_YEAR: number = 2025
44
export const MAP_SIZE_RANGE = {
@@ -45,7 +45,25 @@ export const ENGINE_BUILTIN_MAP_NAMES: string[] = [
4545
'SMILE',
4646
'TargetPractice',
4747
'UglySweater',
48-
'UnderTheSea'
48+
'UnderTheSea',
49+
50+
// Sprint 2
51+
'giver',
52+
'galaxy',
53+
'leavemealone',
54+
'sayhi',
55+
'sierpinski',
56+
'windmill',
57+
'quack',
58+
'gridworld',
59+
'fix',
60+
'Filter',
61+
'BunnyGame',
62+
'Bread',
63+
'Snowglobe',
64+
'Barcode',
65+
'Flower',
66+
'Piglets2'
4967
]
5068

5169
export const TEAM_COLOR_NAMES = ['Silver', 'Gold']

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public class GameConstants {
134134
/** The percent of the defense tower damage buff that is applied to AoE attacks */
135135
public static final int DEFENSE_ATTACK_BUFF_AOE_EFFECTIVENESS = 0;
136136

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

140140
/** Percent of paint capacity at which a robot begins to face increased cooldowns */

‎engine/src/main/battlecode/server/NetServer.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,21 @@ public void onOpen(WebSocket client, ClientHandshake handshake) {
151151

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

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

163162
@Override
164163
public void onError(WebSocket conn, Exception ex) {
165164
if (!(ex instanceof ClosedByInterruptException)) {
166-
System.err.println("Error from: "+conn.getRemoteSocketAddress()+": "+ex);
165+
if (conn != null)
166+
System.err.println("Error from " + conn.getRemoteSocketAddress() + ": " + ex);
167+
else
168+
System.err.println("Error from [unopened WebSocket]: " + ex);
167169
}
168170
}
169171
}

‎engine/src/main/battlecode/world/GameWorld.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,20 @@ public GameWorld(LiveMap gm, RobotControlProvider cp, GameMaker.MatchMaker match
130130
towersByLoc[i] = Team.NEUTRAL;
131131
}
132132
for (int i = 0; i < initialBodies.length; i++) {
133-
RobotInfo robot = initialBodies[i];
134-
MapLocation newLocation = robot.location.translate(gm.getOrigin().x, gm.getOrigin().y);
135-
spawnRobot(robot.ID, robot.type, newLocation, robot.team);
133+
RobotInfo robotInfo = initialBodies[i];
134+
MapLocation newLocation = robotInfo.location.translate(gm.getOrigin().x, gm.getOrigin().y);
135+
spawnRobot(robotInfo.ID, robotInfo.type, newLocation, robotInfo.team);
136136
this.towerLocations.add(newLocation);
137-
towersByLoc[locationToIndex(newLocation)] = robot.team;
137+
towersByLoc[locationToIndex(newLocation)] = robotInfo.team;
138138
this.allRuinsByLoc[locationToIndex(newLocation)] = true;
139139
this.allRuins.add(newLocation);
140+
141+
// Start initial towers at level 2. Defer upgrade action until the tower's first
142+
// turn since client only supports actions this way
143+
InternalRobot robot = getRobot(newLocation);
144+
UnitType newType = robot.getType().getNextLevel();
145+
robot.upgradeTower(newType);
146+
upgradeTower(newType, robot.getTeam());
140147
}
141148
}
142149

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

+20-3
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,19 @@ public void towerAttack(MapLocation loc) {
463463
}
464464
}
465465

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

482-
for(int i = 0; i < 6; i ++) { // check all three spots
493+
for(int i = 0; i < 6; i ++) { // check all six affected MapLocations
483494
int x = this.getLocation().x + dx[dirIdx][i], y = this.getLocation().y + dy[dirIdx][i];
484495
MapLocation newLoc = new MapLocation(x, y);
485496
if(!this.gameWorld.getGameMap().onTheMap(newLoc)) continue;
@@ -585,6 +596,12 @@ public void processBeginningOfRound() {
585596
addPaint(this.type.paintPerTurn + this.gameWorld.extraResourcesFromPatterns(this.team));
586597
if (this.type.moneyPerTurn != 0)
587598
this.gameWorld.getTeamInfo().addMoney(this.team, this.type.moneyPerTurn+this.gameWorld.extraResourcesFromPatterns(this.team));
599+
600+
// Add upgrade action for initially upgraded starting towers
601+
if (this.type.isTowerType() && this.gameWorld.getCurrentRound() == 1 && this.type.level == 2) {
602+
this.getGameWorld().getMatchMaker().addUpgradeAction(getID(), getHealth(),
603+
getType().health, getPaint(), getType().paintCapacity);
604+
}
588605
}
589606

590607
public void processBeginningOfTurn() {

‎engine/src/main/battlecode/world/LiveMap.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,26 @@ public void assertIsValid() throws Exception{
372372
}
373373
int[] towerCountA = new int[3];
374374
int[] towerCountB = new int[3];
375+
int initialBodyCountTeamA = 0;
376+
int initialBodyCountTeamB = 0;
375377
for (RobotInfo initialBody : initialBodies){
376378
if (initialBody.team == Team.A){
377379
towerCountA[FlatHelpers.getRobotTypeFromUnitType(initialBody.type)-1] += 1;
380+
initialBodyCountTeamA++;
378381
}
379-
else towerCountB[FlatHelpers.getRobotTypeFromUnitType(initialBody.type)-1] += 1;
382+
else if (initialBody.team == Team.B){
383+
towerCountB[FlatHelpers.getRobotTypeFromUnitType(initialBody.type)-1] += 1;
384+
initialBodyCountTeamB++;
385+
}
386+
else {
387+
throw new RuntimeException("Expected initial body team " + initialBody.team + " to be team A or team B!");
388+
}
389+
}
390+
if (initialBodyCountTeamA != GameConstants.NUMBER_INITIAL_TOWERS) {
391+
throw new RuntimeException("Expected to have " + GameConstants.NUMBER_INITIAL_TOWERS + " team A towers!");
392+
}
393+
if (initialBodyCountTeamB != GameConstants.NUMBER_INITIAL_TOWERS) {
394+
throw new RuntimeException("Expected to have " + GameConstants.NUMBER_INITIAL_TOWERS + " team B towers!");
380395
}
381396
if (towerCountA[FlatHelpers.getRobotTypeFromUnitType(UnitType.LEVEL_ONE_PAINT_TOWER) - 1] != GameConstants.NUMBER_INITIAL_PAINT_TOWERS){
382397
throw new RuntimeException("Expected to have " + GameConstants.NUMBER_INITIAL_PAINT_TOWERS + " paint towers!");
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.

‎specs/specs.pdf

483 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.