Skip to content

Commit 4252858

Browse files
Merge remote-tracking branch 'origin/engine-testing-3' into crossplay
2 parents a3b851c + e43ee33 commit 4252858

16 files changed

Lines changed: 458 additions & 543 deletions

File tree

client/src/playback/RoundStat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class RoundStat {
7676
let totalCatDamage = 0
7777
let totalRatKings = 0
7878
for (let i = 0; i < delta.teamIdsLength(); i++) {
79-
totalCheese += delta.teamCheeseAmounts(i)!
79+
totalCheese += delta.teamCheeseTransferred(i)!
8080
totalCatDamage += delta.teamCatDamage(i)!
8181
totalRatKings += delta.teamAliveRatKings(i)!
8282
}
@@ -86,7 +86,7 @@ export default class RoundStat {
8686
assert(team != undefined, `team ${i} not found in game.teams in round`)
8787
const teamStat = this.teams.get(team) ?? assert.fail(`team ${i} not found in team stats in round`)
8888

89-
teamStat.cheeseAmount = delta.teamEnemyDamage(i) ?? assert.fail('missing cheese amount')
89+
teamStat.cheeseAmount = delta.teamCheeseTransferred(i) ?? assert.fail('missing cheese amount')
9090
teamStat.cheesePercent = teamStat.cheeseAmount / totalCheese
9191
teamStat.catDamageAmount = delta.teamCatDamage(i) ?? assert.fail('missing cat damage amount')
9292
teamStat.catDamagePercent = teamStat.catDamageAmount / totalCatDamage

crossplay_temp/started_java.txt

Whitespace-only changes.

engine/src/main/battlecode/schema/Round.java

Lines changed: 62 additions & 76 deletions
Large diffs are not rendered by default.

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

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,8 @@ public class MatchMaker {
357357

358358
// Round statistics
359359
private TIntArrayList teamIDs;
360-
private TIntArrayList teamEnemyDamage;
361360
private TIntArrayList teamCatDamage;
362-
private TIntArrayList teamCheeseAmounts;
361+
private TIntArrayList teamCheeseTransferred;
363362
private TIntArrayList teamAliveRatKings;
364363
private TIntArrayList teamAliveBabyRats;
365364
private TIntArrayList teamRatTrapCount;
@@ -389,9 +388,8 @@ public class MatchMaker {
389388

390389
public MatchMaker() {
391390
this.teamIDs = new TIntArrayList();
392-
this.teamEnemyDamage = new TIntArrayList();
393391
this.teamCatDamage = new TIntArrayList();
394-
this.teamCheeseAmounts = new TIntArrayList();
392+
this.teamCheeseTransferred = new TIntArrayList();
395393
this.teamAliveRatKings = new TIntArrayList();
396394
this.teamAliveBabyRats = new TIntArrayList();
397395
this.teamDirtCount = new TIntArrayList();
@@ -508,9 +506,8 @@ public void endRound() {
508506
createEvent((builder) -> {
509507
// Round statistics
510508
int teamIDsP = Round.createTeamIdsVector(builder, teamIDs.toNativeArray());
511-
int teamCheeseAmountsP = Round.createTeamCheeseAmountsVector(builder,
512-
teamCheeseAmounts.toNativeArray());
513-
int teamEnemyDamageP = Round.createTeamEnemyDamageVector(builder, teamEnemyDamage.toNativeArray());
509+
int teamCheeseTransferredP = Round.createTeamCheeseTransferredVector(builder,
510+
teamCheeseTransferred.toNativeArray());
514511
int teamCatDamageP = Round.createTeamCatDamageVector(builder, teamCatDamage.toNativeArray());
515512
int teamAliveRatKingsP = Round.createTeamAliveRatKingsVector(builder, teamAliveRatKings.toNativeArray());
516513
int teamAliveBabyRatsP = Round.createTeamAliveBabyRatsVector(builder, teamAliveBabyRats.toNativeArray());
@@ -524,8 +521,7 @@ public void endRound() {
524521

525522
Round.addTeamIds(builder, teamIDsP);
526523
Round.addRoundId(builder, this.currentRound);
527-
Round.addTeamCheeseAmounts(builder, teamCheeseAmountsP);
528-
Round.addTeamEnemyDamage(builder, teamEnemyDamageP);
524+
Round.addTeamCheeseTransferred(builder, teamCheeseTransferredP);
529525
Round.addTeamCatDamage(builder, teamCatDamageP);
530526
Round.addTeamAliveBabyRats(builder, teamAliveBabyRatsP);
531527
Round.addTeamAliveRatKings(builder, teamAliveRatKingsP);
@@ -581,9 +577,9 @@ public void addDamageAction(int damagedRobotID, int damage) {
581577
});
582578
}
583579

584-
public void addRatNapAction(int grabbedRobotID) {
580+
public void addRatNapAction(int grabberRobotID) {
585581
applyToBuilders((builder) -> {
586-
int action = RatNap.createRatNap(builder, grabbedRobotID);
582+
int action = RatNap.createRatNap(builder, grabberRobotID);
587583
builder.addAction(action, Action.RatNap);
588584
});
589585
}
@@ -604,9 +600,9 @@ public void addThrowAction(int thrownRobotID, MapLocation throwDirLocation) {
604600
}
605601

606602
/// Visually indicate an rat bite
607-
public void addBiteAction(int otherID) {
603+
public void addBiteAction(int biterID) {
608604
applyToBuilders((builder) -> {
609-
int action = RatAttack.createRatAttack(builder, otherID);
605+
int action = RatAttack.createRatAttack(builder, biterID);
610606
builder.addAction(action, Action.RatAttack);
611607
});
612608
}
@@ -722,10 +718,9 @@ public void addDieAction(int id, boolean fromException) {
722718
});
723719
}
724720

725-
public void addTeamInfo(Team team, int totalCheeseAmount, int enemyDamage, int catDamage, int aliveRatKings, int aliveBabyRats, int amountDirtCollected, int ratTrapCount, int catTrapCount) {
721+
public void addTeamInfo(Team team, int cheeseTransferred, int catDamage, int aliveRatKings, int aliveBabyRats, int amountDirtCollected, int ratTrapCount, int catTrapCount) {
726722
teamIDs.add(TeamMapping.id(team));
727-
teamCheeseAmounts.add(totalCheeseAmount);
728-
teamEnemyDamage.add(enemyDamage);
723+
teamCheeseTransferred.add(cheeseTransferred);
729724
teamCatDamage.add(catDamage);
730725
teamAliveRatKings.add(aliveRatKings);
731726
teamAliveBabyRats.add(aliveBabyRats);
@@ -803,9 +798,8 @@ private int locationToInt(MapLocation loc) {
803798

804799
private void clearRoundData() {
805800
this.teamIDs.clear();
806-
this.teamEnemyDamage.clear();
807801
this.teamCatDamage.clear();
808-
this.teamCheeseAmounts.clear();
802+
this.teamCheeseTransferred.clear();
809803
this.teamAliveRatKings.clear();
810804
this.teamAliveBabyRats.clear();
811805
this.teamDirtCount.clear();

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

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,16 @@ public void bfsFromTarget(MapLocation target, int chirality){
230230
for (Direction d : Direction.allDirections()){
231231
if (d == Direction.CENTER)
232232
continue;
233-
if (chirality == 1)
234-
d = flipDirBySymmetry(d);
233+
234+
Direction useDir;
235+
if (chirality == 1){
236+
useDir = flipDirBySymmetry(d);
237+
}
238+
else{
239+
useDir = d;
240+
}
235241

236-
MapLocation neighbor = nextLoc.add(d);
242+
MapLocation neighbor = nextLoc.add(useDir);
237243

238244
if (this.gameMap.onTheMap(neighbor) && bfs_map[locationToIndex(neighbor)][locationToIndex(target)] != null){
239245
// visited already
@@ -259,7 +265,7 @@ public void bfsFromTarget(MapLocation target, int chirality){
259265
}
260266
}
261267
if (validPath){
262-
Direction reverseDirection = d.opposite();
268+
Direction reverseDirection = useDir.opposite();
263269
bfs_map[locationToIndex(neighbor)][locationToIndex(target)] = reverseDirection;
264270
queue.add(neighbor);
265271
}
@@ -851,32 +857,32 @@ public boolean setWinnerIfMoreRatsAlive() {
851857
public boolean setWinnerIfMorePoints() {
852858
double cat_weight; // cat damage
853859
double king_weight; // number of kings
854-
double rat_damage_weight; // amount damage lost by other team throughout the game
860+
double cheese_transfer_weight; // amount cheese transferred
855861

856862
if (isCooperation()) {
857863
cat_weight = 0.5;
858864
king_weight = 0.3;
859-
rat_damage_weight = 0.2;
865+
cheese_transfer_weight = 0.2;
860866
} else {
861867
cat_weight = 0.3;
862868
king_weight = 0.5;
863-
rat_damage_weight = 0.2;
869+
cheese_transfer_weight = 0.2;
864870
}
865871

866872
ArrayList<Integer> teamPoints = new ArrayList<>();
867873

868874
int total_num_rat_kings = teamInfo.getNumRatKings(Team.A) + teamInfo.getNumRatKings(Team.B);
869-
int total_amount_rat_damage = teamInfo.getDamageSuffered(Team.A) + teamInfo.getDamageSuffered(Team.B);
875+
int total_amount_cheese_transferred = teamInfo.getCheeseTransferred(Team.A) + teamInfo.getCheeseTransferred(Team.B);
870876
int total_amount_cat_damage = teamInfo.getDamageToCats(Team.A) + teamInfo.getDamageToCats(Team.B);
871877

872878
for (Team team : List.of(Team.A, Team.B)) {
873879

874880
float proportion_rat_kings = teamInfo.getNumRatKings(team) / total_num_rat_kings;
875-
float proportion_damage_to_other_rats = teamInfo.getDamageSuffered(team.opponent()) / total_amount_rat_damage;
881+
float proportion_cheese_transferred = teamInfo.getCheeseTransferred(team) / total_amount_cheese_transferred;
876882
float proportion_cat_damage = teamInfo.getDamageToCats(team) / total_amount_cat_damage;
877883

878884
int points = (int) (cat_weight * 100 * (proportion_cat_damage) + king_weight * 100 * proportion_rat_kings
879-
+ rat_damage_weight * 100 * proportion_damage_to_other_rats);
885+
+ cheese_transfer_weight * 100 * proportion_cheese_transferred);
880886
this.teamInfo.addPoints(team, points);
881887
teamPoints.add(points);
882888
}
@@ -939,7 +945,7 @@ public void processEndOfRound() {
939945

940946
Team[] teams = {Team.A, Team.B};
941947
for (Team t : teams){
942-
this.matchMaker.addTeamInfo(t, this.teamInfo.getCheese(t), this.teamInfo.getDamageSuffered(t.opponent()), this.teamInfo.getDamageToCats(t), this.teamInfo.getNumRatKings(t), this.teamInfo.getNumBabyRats(t), this.teamInfo.getDirt(t), this.getTrapCount(TrapType.RAT_TRAP, t), this.getTrapCount(TrapType.CAT_TRAP, t));
948+
this.matchMaker.addTeamInfo(t, this.teamInfo.getCheeseTransferred(t), this.teamInfo.getDamageToCats(t), this.teamInfo.getNumRatKings(t), this.teamInfo.getNumBabyRats(t), this.teamInfo.getDirt(t), this.getTrapCount(TrapType.RAT_TRAP, t), this.getTrapCount(TrapType.CAT_TRAP, t));
943949
}
944950
this.teamInfo.processEndOfRound();
945951

@@ -970,7 +976,7 @@ public int spawnRobot(int ID, UnitType type, MapLocation location, Direction dir
970976

971977
InternalRobot robot = new InternalRobot(this, ID, team, type, location, dir, chirality);
972978

973-
for (MapLocation loc : type.getAllTypeLocations(location)) {
979+
for (MapLocation loc : robot.getAllPartLocations()) {
974980
addRobot(loc, robot);
975981
}
976982

@@ -1071,6 +1077,13 @@ public void destroyRobot(int id, boolean fromException, boolean fromDamage) {
10711077
InternalRobot carryingRobot = robot.getCarryingRobot();
10721078
carryingRobot.getDropped(loc);
10731079
}
1080+
if (robot.isGrabbedByRobot()) {
1081+
InternalRobot carrier = robot.getGrabbedByRobot();
1082+
robot.clearGrabbedByRobot();
1083+
if (carrier != null && carrier.getCarryingRobot() == robot) {
1084+
carrier.clearCarryingRobot();
1085+
}
1086+
}
10741087
if (robot.getCheese() > 0) {
10751088
addCheese(loc, robot.getCheese());
10761089
matchMaker.addCheeseSpawnAction(loc, robot.getCheese());

0 commit comments

Comments
 (0)