fix(PPO_Bot): SIGSEGV crash fixes + static buffers for thread safety
- bullets: seq[InFlightBullet] → array[4, InFlightBullet] + bulletCount (eliminates cross-thread heap realloc under ORC) - hasFired: edge-triggered (cleared after state build, not level-triggered) - round_counter parseInt: wrapped for empty/torn file → 0 - Static SVG + intent buffers to kill cross-thread heap realloc - Tick-local alive/bulletData also fixed arrays Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -70,22 +70,25 @@ public class RunTraining {
|
||||
);
|
||||
|
||||
var owner = new Object();
|
||||
int[] prevTotal = { 0 };
|
||||
|
||||
try (var handle = runner.startBattleAsync(setup, bots)) {
|
||||
|
||||
handle.getOnRoundEnded().on(owner, event -> {
|
||||
int round = event.getRoundNumber();
|
||||
int ticks = event.getTurnNumber();
|
||||
int score = 0;
|
||||
int totalScore = 0;
|
||||
boolean win = false;
|
||||
boolean found = false;
|
||||
for (var r : event.getResults()) {
|
||||
if (r.getName().equals("PPO_Bot")) {
|
||||
found = true;
|
||||
score = r.getTotalScore();
|
||||
totalScore = r.getTotalScore();
|
||||
win = r.getRank() == 1;
|
||||
}
|
||||
}
|
||||
int score = totalScore - prevTotal[0];
|
||||
prevTotal[0] = totalScore;
|
||||
// PPO_Bot's process died mid-battle: abort so run.sh's crash-restart
|
||||
// loop resumes from round_counter instead of grinding dummy rounds.
|
||||
// Frozen for a few harness rounds can be a healthy-but-lagging counter
|
||||
@@ -113,8 +116,8 @@ public class RunTraining {
|
||||
}
|
||||
// Append game-outcome JSON line
|
||||
String line = String.format(
|
||||
"{\"type\":\"game\",\"round\":%d,\"ticks\":%d,\"score\":%d,\"win\":%b,\"opponent\":\"%s\"}",
|
||||
round, ticks, score, win, opponent
|
||||
"{\"type\":\"game\",\"round\":%d,\"ticks\":%d,\"score\":%d,\"total_score\":%d,\"win\":%b,\"opponent\":\"%s\"}",
|
||||
round, ticks, score, totalScore, win, opponent
|
||||
);
|
||||
try {
|
||||
appendLine(logFile, line);
|
||||
|
||||
Reference in New Issue
Block a user