Files
SirRoboGarage/tools/raw_recorder/RawRecord.java
T
SirStone fcaa7ba183 tools/raw_recorder + tr_bots/_salvage: recorder source and the legacy port
tools/raw_recorder/RawRecord.java + shadow/GameRecorder.java  the observer
    that writes the .battle.gz corpora in data/ (gitignored, regenerable)
  tools/raw_recorder/query.py, sample_outline.md               query helpers
    and the shape of a capture
  tr_bots/_salvage/                                           the port audit:
    portaudit/{methods,static}.py, shim/, and the tr_wrappers/*.json + *.sh
    for 29 rescued legacy bots, with legacy_bots/MANIFEST.sha256
2026-10-05 22:43:41 +02:00

53 lines
2.2 KiB
Java

import dev.robocode.tankroyale.runner.BattleHandle;
import dev.robocode.tankroyale.runner.BattleRunner;
import dev.robocode.tankroyale.runner.BattleSetup;
import dev.robocode.tankroyale.runner.BotEntry;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
/**
* Runs a battle with the runner's built-in recording enabled
* (BattleRunner.Builder.enableRecording -> GameRecorder) and nothing else.
* The raw observer stream lands in DIR as game-<timestamp>.battle.gz
* (gzipped ND-JSON, one observer message per line):
*
* gunzip -c DIR/game-*.battle.gz > /tmp/raw.jsonl
*/
public final class RawRecord {
public static void main(String[] args) throws Exception {
String dirArg = "/tmp/rawrec";
int roundsArg = 2;
List<Path> bots = new ArrayList<>();
for (int i = 0; i < args.length; i++) {
switch (args[i]) {
case "--dir" -> dirArg = args[++i];
case "--rounds" -> roundsArg = Integer.parseInt(args[++i]);
case "--bot" -> bots.add(Path.of(args[++i]));
default -> { System.err.println("Unknown arg: " + args[i]); System.exit(2); }
}
}
final String dir = dirArg;
final int rounds = roundsArg;
if (bots.isEmpty()) { System.err.println("--bot <dir> required (repeatable)"); System.exit(2); }
List<BotEntry> entries = new ArrayList<>();
for (Path b : bots) entries.add(BotEntry.of(b));
try (BattleRunner runner = BattleRunner.create(
b -> b.embeddedServer().suppressServerOutput().enableRecording(Path.of(dir)))) {
BattleSetup setup = BattleSetup.classic(s -> {
s.setNumberOfRounds(rounds);
s.setDefaultTurnsPerSecond(-1);
});
try (BattleHandle h = runner.startBattleAsync(setup, entries)) {
Object owner = new Object();
h.getOnRoundEnded().on(owner, e -> System.out.println("[raw] round " + e.getRoundNumber() + " done"));
var res = h.awaitResults();
System.out.println("[raw] results: " + res.getResults());
}
}
System.out.println("[raw] recording in " + dir);
}
}