Skip to content

Commit 3a75cb9

Browse files
author
Ian Gonzalez Hermosillo
committed
last minute balance changes
1 parent 0aba78d commit 3a75cb9

8 files changed

Lines changed: 67 additions & 34 deletions

File tree

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ public class GameConstants {
5555
/** The maximum number of rounds in a game. **/
5656
public static final int GAME_MAX_NUMBER_OF_ROUNDS = 2000;
5757

58-
/** The maximum number of bytecodes a bot is allow to use in one turn */
59-
public static final int BYTECODE_LIMIT = 25000;
58+
/** The maximum number of bytecodes a robot is allowed to use in one turn */
59+
public static final int ROBOT_BYTECODE_LIMIT = 15000;
60+
61+
/** The maximum number of bytecodes a tower is allowed to use in one turn */
62+
public static final int TOWER_BYTECODE_LIMIT = 20000;
6063

6164
/**
6265
* The maximum length of indicator strings that a player can associate with a
@@ -76,15 +79,6 @@ public class GameConstants {
7679
/** Paint penalty for ending a turn on neutral territory */
7780
public static final int PENALTY_NEUTRAL_TERRITORY = 1;
7881

79-
/** Paint capacity for soldier robots */
80-
public static final int PAINT_CAPACITY_SOLDIER = 200;
81-
82-
/** Paint capacity for splasher robots */
83-
public static final int PAINT_CAPACITY_SPLASHER = 300;
84-
85-
/** Paint capacity for mopper robots */
86-
public static final int PAINT_CAPACITY_MOPPER = 100;
87-
8882
/** The amount of money each team starts with. */
8983
public static final int INITIAL_TEAM_MONEY = 1000;
9084

@@ -125,6 +119,12 @@ public class GameConstants {
125119
/** The extra resources per turn that resource patterns give */
126120
public static final int EXTRA_RESOURCES_FROM_PATTERN = 3;
127121

122+
/** The extra damage all ally towers get for each level 1 defense tower */
123+
public static final int EXTRA_DAMAGE_FROM_DEFENSE_TOWER = 10;
124+
125+
/** The increase in extra damage for ally towers for upgrading a defense tower */
126+
public static final int EXTRA_TOWER_DAMAGE_LEVEL_INCREASE = 5;
127+
128128
/** Maximum amount of turns a robot can go at 0 paint without dying */
129129
public static final int MAX_TURNS_WITHOUT_PAINT = 10;
130130

@@ -168,6 +168,21 @@ public class GameConstants {
168168
/** The amount of paint depleted from enemies in a swing mopper attack */
169169
public static final int MOPPER_SWING_PAINT_DEPLETION = 5;
170170

171+
/** The maximum amount of bytes that can be encoded in a message */
172+
public static final int MAX_MESSAGE_BYTES = 4;
173+
174+
/** The maximum squared radius a robot can send a message to */
175+
public static final int MESSAGE_RADIUS_SQUARED = 20;
176+
177+
/** The maximum number of rounds a message will exist for */
178+
public static final int MESSAGE_ROUND_DURATION = 5;
179+
180+
/** The maximum number of messages a robot can send per turn */
181+
public static final int MAX_MESSAGES_SENT_ROBOT = 1;
182+
183+
/** The maximum number of messages a tower can send per turn */
184+
public static final int MAX_MESSAGES_SENT_TOWER = 20;
185+
171186
// *********************************
172187
// ****** COOLDOWNS ****************
173188
// *********************************
@@ -194,19 +209,4 @@ public class GameConstants {
194209
/** THe amount added to the action cooldown counter after transferring paint */
195210
public static final int PAINT_TRANSFER_COOLDOWN = 10;
196211

197-
/** The maximum amount of bytes that can be encoded in a message */
198-
public static final int MAX_MESSAGE_BYTES = 4;
199-
200-
/** The maximum squared radius a robot can send a message to */
201-
public static final int MESSAGE_RADIUS_SQUARED = 20;
202-
203-
/** The maximum number of rounds a message will exist for */
204-
public static final int MESSAGE_ROUND_DURATION = 5;
205-
206-
/** The maximum number of messages a robot can send per turn */
207-
public static final int MAX_MESSAGES_SENT_ROBOT = 1;
208-
209-
/** The maximum number of messages a tower can send per turn */
210-
public static final int MAX_MESSAGES_SENT_TOWER = 20;
211-
212212
}

engine/src/main/battlecode/server/GameMaker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public int makeRobotTypeMetadata(FlatBufferBuilder builder){
310310
RobotTypeMetadata.addActionCooldown(builder, type.actionCooldown);
311311
RobotTypeMetadata.addActionRadiusSquared(builder, type.actionRadiusSquared);
312312
RobotTypeMetadata.addBaseHealth(builder,type.health);
313-
RobotTypeMetadata.addBytecodeLimit(builder, 25000);
313+
RobotTypeMetadata.addBytecodeLimit(builder, type.isRobotType() ? GameConstants.ROBOT_BYTECODE_LIMIT : GameConstants.TOWER_BYTECODE_LIMIT);
314314
RobotTypeMetadata.addMovementCooldown(builder, GameConstants.MOVEMENT_COOLDOWN);
315315
RobotTypeMetadata.addVisionRadiusSquared(builder, GameConstants.VISION_RADIUS_SQUARED);
316316
RobotTypeMetadata.addMessageRadiusSquared(builder, GameConstants.MESSAGE_RADIUS_SQUARED);

engine/src/main/battlecode/server/Server.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ public String getWinnerString(GameInfo game, Team winner, int roundNumber) {
408408
case PAINT_ENOUGH_AREA:
409409
sb.append("The winning team painted enough of the map.");
410410
break;
411+
case DESTROY_ALL_UNITS:
412+
sb.append("The winning team destroyed all of the enemy team's units.");
413+
break;
411414
case MORE_SQUARES_PAINTED:
412415
sb.append("The winning team won on tiebreakers (painted more of the map).");
413416
break;

engine/src/main/battlecode/world/DominationFactor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ public enum DominationFactor {
88
* Win by painting more than {@value battlecode.common.GameConstants#PAINT_PERCENT_TO_WIN}% of the map.
99
*/
1010
PAINT_ENOUGH_AREA,
11+
/**
12+
* Win by destroying all of the enemy team's robots and towers.
13+
*/
14+
DESTROY_ALL_UNITS,
1115
/**
1216
* Win by having more squares painted than the other team at the end of the game (tiebreak 1).
1317
*/

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class GameWorld {
4747
private Team[] resourcePatternCentersByLoc;
4848
private ArrayList<MapLocation> towerLocations;
4949
private Team[] towersByLoc; // indexed by location
50+
private int[] currentDamageIncreases = {0,0};
51+
private int[] currentNumberUnits = {0,0};
5052

5153
// List of all ruins, not indexed by location
5254
private ArrayList<MapLocation> allRuins;
@@ -129,6 +131,8 @@ public GameWorld(LiveMap gm, RobotControlProvider cp, GameMaker.MatchMaker match
129131
RobotInfo robot = initialBodies[i];
130132
MapLocation newLocation = robot.location.translate(gm.getOrigin().x, gm.getOrigin().y);
131133
spawnRobot(robot.ID, robot.type, newLocation, robot.team);
134+
InternalRobot tower = getRobot(newLocation);
135+
tower.upgradeTower(tower.getType().getNextLevel());
132136
this.towerLocations.add(newLocation);
133137
towersByLoc[locationToIndex(newLocation)] = robot.team;
134138
}
@@ -539,6 +543,15 @@ public int extraResourcesFromPatterns(Team team){
539543
return getNumResourcePatterns(team) * GameConstants.EXTRA_RESOURCES_FROM_PATTERN;
540544
}
541545

546+
public int getDefenseTowerDamageIncrease(Team team){
547+
return this.currentDamageIncreases[team.ordinal()];
548+
}
549+
550+
public void upgradeTower(UnitType newType, Team team){
551+
if (newType == UnitType.LEVEL_TWO_DEFENSE_TOWER || newType == UnitType.LEVEL_THREE_DEFENSE_TOWER)
552+
this.currentDamageIncreases[team.ordinal()] += GameConstants.EXTRA_TOWER_DAMAGE_LEVEL_INCREASE;
553+
}
554+
542555
/**
543556
* Returns the resource pattern corresponding to the map,
544557
* stored as the bits of an int between 0 and 2^({@value GameConstants#PATTERN_SIZE}^2) - 1.
@@ -966,9 +979,11 @@ public int spawnRobot(int ID, UnitType type, MapLocation location, Team team){
966979
this.teamInfo.addTowers(1, team);
967980
robot.addPaint(GameConstants.INITIAL_TOWER_PAINT_AMOUNT);
968981
}
969-
else{
982+
else
970983
robot.addPaint((int) Math.round(type.paintCapacity * GameConstants.INITIAL_ROBOT_PAINT_PERCENTAGE / 100.0));
971-
}
984+
if (type == UnitType.LEVEL_ONE_DEFENSE_TOWER)
985+
this.currentDamageIncreases[team.ordinal()] += GameConstants.EXTRA_DAMAGE_FROM_DEFENSE_TOWER;
986+
this.currentNumberUnits[team.ordinal()] += 1;
972987
return ID;
973988
}
974989

@@ -999,6 +1014,12 @@ public void destroyRobot(int id, boolean fromException, boolean fromDamage){
9991014
this.towerLocations.remove(loc);
10001015
this.teamInfo.addTowers(-1, robot.getTeam());
10011016
}
1017+
switch (robot.getType()){
1018+
case LEVEL_ONE_DEFENSE_TOWER: this.currentDamageIncreases[robot.getTeam().ordinal()] -= GameConstants.EXTRA_DAMAGE_FROM_DEFENSE_TOWER; break;
1019+
case LEVEL_TWO_DEFENSE_TOWER: this.currentDamageIncreases[robot.getTeam().ordinal()] -= GameConstants.EXTRA_DAMAGE_FROM_DEFENSE_TOWER + GameConstants.EXTRA_TOWER_DAMAGE_LEVEL_INCREASE; break;
1020+
case LEVEL_THREE_DEFENSE_TOWER: this.currentDamageIncreases[robot.getTeam().ordinal()] -= GameConstants.EXTRA_DAMAGE_FROM_DEFENSE_TOWER + 2 * GameConstants.EXTRA_TOWER_DAMAGE_LEVEL_INCREASE; break;
1021+
default: break;
1022+
}
10021023

10031024
removeRobot(loc);
10041025
}
@@ -1009,6 +1030,10 @@ public void destroyRobot(int id, boolean fromException, boolean fromDamage){
10091030
matchMaker.addDieAction(id, fromException);
10101031
else
10111032
matchMaker.addDied(id);
1033+
this.currentNumberUnits[robot.getTeam().ordinal()] -= 1;
1034+
if (this.currentNumberUnits[robot.getTeam().ordinal()] == 0){
1035+
setWinner(robot.getTeam().opponent(), DominationFactor.DESTROY_ALL_UNITS);
1036+
}
10121037
}
10131038

10141039
// *********************************

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public InternalRobot(GameWorld gw, int id, Team team, UnitType type, MapLocation
7676
this.paintAmount = 0;
7777

7878
this.controlBits = 0;
79-
this.currentBytecodeLimit = GameConstants.BYTECODE_LIMIT;
79+
this.currentBytecodeLimit = type.isRobotType() ? GameConstants.ROBOT_BYTECODE_LIMIT : GameConstants.TOWER_BYTECODE_LIMIT;
8080
this.bytecodesUsed = 0;
8181

8282
this.roundsAlive = 0;
@@ -448,9 +448,10 @@ public void towerAttack(MapLocation loc) {
448448
if(this.gameWorld.getRobot(loc) != null) {
449449
InternalRobot unit = this.gameWorld.getRobot(loc);
450450
if(this.team != unit.getTeam()){
451-
unit.addHealth(-this.type.attackStrength);
451+
int damage = this.type.attackStrength + this.gameWorld.getDefenseTowerDamageIncrease(team);
452+
unit.addHealth(-damage);
452453
this.gameWorld.getMatchMaker().addAttackAction(unit.getID());
453-
this.gameWorld.getMatchMaker().addDamageAction(unit.getID(), this.type.attackStrength);
454+
this.gameWorld.getMatchMaker().addDamageAction(unit.getID(), damage);
454455
}
455456
}
456457
}
@@ -581,7 +582,7 @@ public void processBeginningOfTurn() {
581582
this.towerHasSingleAttacked = this.towerHasAreaAttacked = false;
582583
this.actionCooldownTurns = Math.max(0, this.actionCooldownTurns - GameConstants.COOLDOWNS_PER_TURN);
583584
this.movementCooldownTurns = Math.max(0, this.movementCooldownTurns - GameConstants.COOLDOWNS_PER_TURN);
584-
this.currentBytecodeLimit = GameConstants.BYTECODE_LIMIT;
585+
this.currentBytecodeLimit = this.type.isRobotType() ? GameConstants.ROBOT_BYTECODE_LIMIT : GameConstants.TOWER_BYTECODE_LIMIT;
585586
this.gameWorld.getMatchMaker().startTurn(this.ID);
586587
}
587588

engine/src/main/battlecode/world/RobotControllerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ public void upgradeTower(MapLocation loc) throws GameActionException{
658658
moneyRequired += newType.moneyCost;
659659
this.gameWorld.getTeamInfo().addMoney(robot.getTeam(), -moneyRequired);
660660
robot.upgradeTower(newType);
661+
this.gameWorld.upgradeTower(newType, getTeam());
661662
this.gameWorld.getMatchMaker().addUpgradeAction(robot.getID(), robot.getHealth(),
662663
robot.getType().health, robot.getPaint(), robot.getType().paintCapacity);
663664
}

engine/src/main/battlecode/world/TeamInfo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class TeamInfo {
1616
private int[] moneyCounts;
1717
private int[] totalPaintedSquares;
1818
private int[] totalNumberOfTowers;
19-
2019
private int[] oldMoneyCounts;
2120

2221
/**

0 commit comments

Comments
 (0)