feat(tools): capture real DrussGT movement from classic Robocode as fixtures

There are no genuinely competitive adversaries for Tank Royale, and the
in-repo ones were broken until recently. Classic Robocode 1.9.5.5 is
obtainable (SourceForge, 20.4 MB) and its programmatic control API
(robocode.control.RobocodeEngine + BattleAdaptor.onTurnEnded) can run real
battles headless and expose per-turn robot state. So a legacy leader bot's
MOVEMENT can be captured and used as a gun-testing fixture with no port.

Captured unmodified DrussGT 3.1.4159 vs spinbot/ramfire/crazy/corners and a
mirror match: 28,797 ticks, plus two trivial-bot contrasts. Conversion to
the Tank Royale convention is validated to 0.000-0.001 deg by recomputing
the direction implied by (heading, speed) and comparing it against the
recorded per-tick displacement -- i.e. the data is proven to be genuine
recorded motion rather than a mangled export. (A first attempt treated the
snapshot API's headings as degrees; they are radians, ~95 deg off.)

The statistics confirm it is really a wave surfer: perpendicular to the
opponent 65-96% of ticks, radial ~0.001, 41-72% of ticks at full speed,
reversing on 42-46% of ticks, holding range at a 283-526 px median. The
straight-line contrast is radial-dominant (0.75) with ZERO reversals.

Discovery: DrussGT detects predictable guns and switches to a bullet-shield
stand-still mode, so captures against sample.Walls/TrackFire had to be
rejected as non-movement.

CAVEATS, recorded in DRUSSGT_FIXTURES.md: these are open-loop (replayed
DrussGT never dodges OUR bullets) and perfect-information (the observer
gives true positions every tick, unlike our stale live WorldState). Both
make our guns look better than in live play, so use them for RELATIVE gun
ranking, not absolute hit rates.

Jars stay out of git; capture tooling is reproducible via capture.sh.
This commit is contained in:
2026-09-20 23:44:42 +02:00
parent 974528d5cf
commit 4f18c8ce07
21 changed files with 32456 additions and 0 deletions
+226
View File
@@ -0,0 +1,226 @@
import robocode.control.*;
import robocode.control.events.*;
import robocode.control.snapshot.*;
import java.io.*;
import java.util.*;
/**
* Headless classic-Robocode battle runner that dumps per-turn robot state to JSONL.
*
* Usage: Capture <enemyNamePattern> <shooterNamePattern> <rounds> <outFile> <adversaryLabel> <note>
*
* The robot whose name matches enemyNamePattern is written as e* (the movement we want),
* the other as s* (the shooter / bearing reference).
*
* Heading conversion (classic Robocode -> Tank Royale):
* classic heading: 0 = North (+y), positive = clockwise
* tank royale heading: 0 = East (+x), positive = counter-clockwise
* => headingTank = (90 - headingClassic) mod 360
* Positions are identical (both origin bottom-left, x right, y up).
*/
public class Capture {
public static class Row {
int tick; // global, continuous across rounds
double ex, ey, eh, es, ee;
double sx, sy, sh, ss, se;
}
static List<Row> rows = new ArrayList<>();
static Map<Integer, String> idxToName = new HashMap<>();
static int enemyIdx = -1, shooterIdx = -1;
static int globalTick = 0;
static Map<Integer, Integer> roundTicks = new LinkedHashMap<>();
static List<String> errors = new ArrayList<>();
static double tankHeading(double classicRad) {
// IRobotSnapshot.getBodyHeading() returns RADIANS in the classic Robocode
// convention (0 = north, positive = clockwise).
double classicDeg = Math.toDegrees(classicRad);
double t = (90.0 - classicDeg) % 360.0;
if (t < 0) t += 360.0;
return t;
}
static String f(double v) {
return String.format(Locale.ROOT, "%.4f", v);
}
static boolean printedIndexMap = false;
public static void main(String[] args) throws Exception {
System.setProperty("java.awt.headless", "true");
if (args.length < 6) {
System.err.println("usage: Capture <enemyPattern> <shooterPattern> <rounds> <out> <label> <note>");
System.exit(2);
}
final String enemyPattern = args[0];
final String shooterPattern = args[1];
final int rounds = Integer.parseInt(args[2]);
final String outFile = args[3];
final String label = args[4];
final String note = args[5];
File home = new File(System.getProperty("robocode.home", "/tmp/robocode/install"));
System.out.println("[capture] home=" + home + " enemy=" + enemyPattern + " shooter=" + shooterPattern
+ " rounds=" + rounds);
RobocodeEngine engine = new RobocodeEngine(home);
engine.setVisible(false);
engine.addBattleListener(new BattleAdaptor() {
@Override
public void onTurnEnded(TurnEndedEvent event) {
try {
ITurnSnapshot snap = event.getTurnSnapshot();
IRobotSnapshot[] bots = snap.getRobots();
if (!printedIndexMap) {
printedIndexMap = true;
for (IRobotSnapshot b : bots) {
System.out.println("[capture] index=" + b.getRobotIndex() + " name=" + b.getName());
}
}
IRobotSnapshot en = null, sh = null;
for (IRobotSnapshot b : bots) {
String n = b.getName();
if (enemyIdx >= 0 && b.getRobotIndex() == enemyIdx) en = b;
if (shooterIdx >= 0 && b.getRobotIndex() == shooterIdx) sh = b;
}
if (en == null || sh == null) return;
if (en.getState() == null || !en.getState().isAlive()) return;
if (sh.getState() == null || !sh.getState().isAlive()) return;
Row r = new Row();
r.tick = globalTick++;
r.ex = en.getX(); r.ey = en.getY();
r.eh = tankHeading(en.getBodyHeading());
r.es = en.getVelocity(); r.ee = en.getEnergy();
r.sx = sh.getX(); r.sy = sh.getY();
r.sh = tankHeading(sh.getBodyHeading());
r.ss = sh.getVelocity(); r.se = sh.getEnergy();
rows.add(r);
roundTicks.merge(snap.getRound(), 1, Integer::sum);
} catch (Throwable t) {
errors.add("onTurnEnded: " + t);
}
}
@Override
public void onRoundStarted(RoundStartedEvent e) {
// nothing
}
@Override
public void onBattleError(BattleErrorEvent e) {
errors.add("battleError: " + e.getError());
}
@Override
public void onRoundEnded(RoundEndedEvent e) {
System.out.println("[capture] round " + e.getRound() + " ended, turns=" + e.getTurns());
}
});
List<RobotSpecification> picked = new ArrayList<>();
RobotSpecification enSpec = null, shSpec = null;
String query = enemyPattern.equals(shooterPattern) ? enemyPattern : enemyPattern + "," + shooterPattern;
RobotSpecification[] repo = engine.getLocalRepository(query);
if (repo == null || repo.length < 1) {
System.err.println("[capture] FAILED to resolve robots; got " + (repo == null ? 0 : repo.length));
System.exit(3);
}
for (RobotSpecification rs : repo) {
System.out.println("[capture] repo entry name=" + rs.getName() + " class=" + rs.getClassName());
if (enSpec == null && rs.getClassName().equals(enemyPattern)) enSpec = rs;
if (shSpec == null && rs.getClassName().equals(shooterPattern)) shSpec = rs;
}
if (shSpec == null && enemyPattern.equals(shooterPattern)) shSpec = enSpec;
if (enSpec == null || shSpec == null) {
System.err.println("[capture] could not match specs; enemy=" + enSpec + " shooter=" + shSpec);
System.exit(3);
}
System.out.println("[capture] enemy spec = " + enSpec.getName());
System.out.println("[capture] shooter spec = " + shSpec.getName());
// Determine indices from the repository order passed to the battle.
RobotSpecification[] chosen = new RobotSpecification[]{enSpec, shSpec};
// The engine assigns robot index by order in the robots array (0-based).
enemyIdx = 0;
shooterIdx = 1;
idxToName.put(0, enSpec.getName());
idxToName.put(1, shSpec.getName());
BattleSpecification spec = new BattleSpecification(
rounds, // numRounds
450L, // inactivity time (turns)
0.1, // gun cooling rate
new BattlefieldSpecification(800, 600),
chosen);
long t0 = System.currentTimeMillis();
engine.runBattle(spec, true);
engine.waitTillBattleOver();
engine.close();
long dt = System.currentTimeMillis() - t0;
System.out.println("[capture] battle done in " + dt + " ms, rows=" + rows.size());
// robust: verify index mapping by re-reading robot names once more is not possible; rely on order.
// Write JSONL
File of = new File(outFile);
of.getParentFile().mkdirs();
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(of)))) {
StringBuilder meta = new StringBuilder();
meta.append("{\"meta\":{");
meta.append("\"adversary\":\"").append(label).append("\",");
meta.append("\"source\":\"classic-robocode\",");
meta.append("\"perfect_info\":true,");
meta.append("\"arena\":{\"w\":800,\"h\":600},");
meta.append("\"note\":\"").append(escape(note)).append("\"");
meta.append("}}");
out.println(meta);
for (Row r : rows) {
StringBuilder sb = new StringBuilder();
sb.append("{\"tick\":").append(r.tick);
sb.append(",\"ex\":").append(f(r.ex));
sb.append(",\"ey\":").append(f(r.ey));
sb.append(",\"eh\":").append(f(r.eh));
sb.append(",\"es\":").append(f(r.es));
sb.append(",\"ee\":").append(f(r.ee));
sb.append(",\"sx\":").append(f(r.sx));
sb.append(",\"sy\":").append(f(r.sy));
sb.append(",\"sh\":").append(f(r.sh));
sb.append(",\"ss\":").append(f(r.ss));
sb.append(",\"se\":").append(f(r.se));
sb.append("}");
out.println(sb);
}
}
System.out.println("[capture] wrote " + of.length() + " bytes to " + of.getAbsolutePath());
// Sidecar with round boundaries (for statistics; not part of the shared fixture format).
try (PrintWriter rs = new PrintWriter(new BufferedWriter(new FileWriter(outFile + ".rounds.json")))) {
rs.print("{\"rounds\":[");
int start = 0;
boolean first = true;
for (Map.Entry<Integer, Integer> e : roundTicks.entrySet()) {
if (!first) rs.print(",");
first = false;
rs.print("{\"round\":" + e.getKey() + ",\"startTick\":" + start + ",\"count\":" + e.getValue() + "}");
start += e.getValue();
}
rs.println("]}");
}
System.out.println("[capture] rounds ticks: " + roundTicks);
if (!errors.isEmpty()) {
System.out.println("[capture] errors (" + errors.size() + "):");
for (String e : errors) System.out.println(" " + e);
}
// exit code 0 only if we captured something
System.exit(rows.isEmpty() ? 4 : 0);
}
static String escape(String s) {
return s.replace("\\", "\\\\").replace("\"", "\\\"");
}
}
+74
View File
@@ -0,0 +1,74 @@
# robocode_fixture_capture
Reproduces the classic-Robocode **DrussGT movement fixtures** in
`tools/fixtures/` (see `tools/fixtures/DRUSSGT_FIXTURES.md` for the data,
conversion and caveats).
## Run it
```sh
tools/robocode_fixture_capture/capture.sh # writes to tools/fixtures
tools/robocode_fixture_capture/capture.sh /tmp/out # or another directory
```
The script:
1. downloads classic Robocode 1.9.5.5 from SourceForge into `/tmp/robocode/`
(its "setup jar" is a plain zip of the full install),
2. downloads the third-party `DrussGT.jar` from the Robocode archive,
3. builds the trivial `trivial.StraightLine` contrast bot as a jar,
4. compiles `Capture.java` and runs the headless battles,
5. writes `*.jsonl` fixtures plus `drussgt_meta/*.rounds.json` sidecars.
**The Robocode distribution and the DrussGT jar are third-party
redistributables and are intentionally kept out of the repository** — they live
only under `/tmp/robocode/`. Nothing under `/tmp` is committed.
## Files
| File | Purpose |
|---|---|
| `capture.sh` | download + build + run everything |
| `Capture.java` | headless `RobocodeEngine` observer that dumps per-turn state to JSONL |
| `StraightLine.java` / `StraightLine.properties` | trivial constant-speed contrast bot |
| `analyze.py` | conversion validation + movement statistics |
## Running the engine headlessly
Robocode 1.9.5.5 installs a `SecurityManager` and reflects into
`sun.net.www.protocol.jar`. On Java 21 both are blocked by default, so the JVM
needs (this is what `capture.sh` uses):
```
-Djava.security.manager=allow
--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.desktop/sun.awt=ALL-UNNAMED
```
Java 17/11 work with fewer flags (the `--add-opens` for `sun.net` is still
required on 17+).
## Key API gotchas found while building this
- `RobocodeEngine.getLocalRepository(name)` requires the **full class name**
(`jk.mega.DrussGT`, not `DrussGT`). A robot added as loose `.class` files is
indexed but marked unusable (`trivial.StraightLine*`) and cannot be selected;
packaging it as a **jar** with a `robots:` manifest entry fixes it.
Delete `robots/robot.database` to force a repository rescan.
- `IRobotSnapshot.getBodyHeading()` / `getGunHeading()` / `getRadarHeading()`
return **radians** (classic convention: 0=north, clockwise) — the rest of the
classic robot API uses degrees. `getVelocity()` is signed px/turn.
See the conversion in `tools/fixtures/DRUSSGT_FIXTURES.md`.
## Validate / analyse
```sh
python3 tools/robocode_fixture_capture/analyze.py \
tools/fixtures/drussgt_vs_*.jsonl tools/fixtures/contrast_*.jsonl
```
`analyze.py` reports the coordinate-conversion check (mean angular error between
recorded displacement and the direction implied by `eh`+`es`; expect 0.000°),
speed / heading-change distributions, range statistics and the
perpendicular-vs-radial split.
@@ -0,0 +1,19 @@
package trivial;
import robocode.Robot;
/**
* Deliberately trivial reference opponent for fixture contrast.
* Moves in straight legs at constant speed; turns 180 degrees in place at walls.
* Never fires, never scans deliberately.
*/
public class StraightLine extends Robot {
public void run() {
// normalise body heading to east (classic Robocode heading 90 == east)
turnRight(90 - getHeading());
while (true) {
ahead(100000); // straight leg until blocked by a wall
turnRight(180); // reverse in place
}
}
}
@@ -0,0 +1,6 @@
robot.classname=trivial.StraightLine
robot.name=StraightLine
robot.version=1.0
robot.author.name=fixture-contrast
robot.description=Trivial straight-line contrast bot
robocode.version=1.9.5.5
+152
View File
@@ -0,0 +1,152 @@
#!/usr/bin/env python3
"""Analyze classic-Robocode fixture JSONL + validate the heading conversion.
Conversion claimed: tank_heading = (90 - classic_heading) mod 360
Since classic Robocode x/y axes match Tank Royale (origin bottom-left, x right,
y up), position deltas between ticks should align with the reported heading.
"""
import json, sys, math, statistics as st
def load(path):
rows = []
for line in open(path):
line = line.strip()
if not line:
continue
o = json.loads(line)
if "tick" in o:
rows.append(o)
rounds = []
import os
for cand in (path + ".rounds.json",
os.path.join(os.path.dirname(path), "drussgt_meta",
os.path.basename(path) + ".rounds.json")):
try:
rounds = json.load(open(cand))["rounds"]
break
except Exception:
rounds = None
return rows, rounds
def wrap180(a):
return ((a + 180.0) % 360.0) - 180.0
def unit(deg):
r = math.radians(deg)
return math.cos(r), math.sin(r)
def analyze(path):
rows, rounds = load(path)
# boundary ticks (first tick of a round)
starts = set()
if rounds:
for r in rounds:
starts.add(r["startTick"])
else:
# fallback heuristic: big jump
for i in range(1, len(rows)):
dx = rows[i]["ex"] - rows[i-1]["ex"]
dy = rows[i]["ey"] - rows[i-1]["ey"]
if math.hypot(dx, dy) > 20:
starts.add(rows[i]["tick"])
n = len(rows)
speeds = [abs(r["es"]) for r in rows]
signed = [r["es"] for r in rows]
heading_changes = []
dists = []
perp_sin = []
radial_cos = []
disp_err = [] # angular error between displacement dir and reported movement dir
disp_err_next = []
moving_ticks = 0
for i, r in enumerate(rows):
d = math.hypot(r["ex"] - r["sx"], r["ey"] - r["sy"])
dists.append(d)
if i == 0 or rows[i]["tick"] in starts:
continue
p = rows[i-1]
dh = wrap180(r["eh"] - p["eh"])
heading_changes.append(abs(dh))
dx = r["ex"] - p["ex"]
dy = r["ey"] - p["ey"]
step = math.hypot(dx, dy)
v = r["es"]
if abs(v) < 0.5 or step < 0.2:
continue
moving_ticks += 1
# movement direction implied by heading + velocity sign (tank convention)
mu = r["eh"] if v >= 0 else r["eh"] + 180.0
# radial direction from enemy to shooter
theta = math.degrees(math.atan2(r["sy"] - r["ey"], r["sx"] - r["ex"]))
delta = math.radians(mu - theta)
perp_sin.append(abs(math.sin(delta)))
radial_cos.append(abs(math.cos(delta)))
# conversion validation: displacement direction vs movement dir
phi = math.degrees(math.atan2(dy, dx))
disp_err.append(abs(wrap180(phi - mu)))
phi_prev = math.degrees(math.atan2(dy, dx))
mu_prev = p["eh"] if p["es"] >= 0 else p["eh"] + 180.0
disp_err_next.append(abs(wrap180(phi_prev - mu_prev)))
def pct(x, p):
if not x:
return float("nan")
s = sorted(x)
k = min(len(s)-1, int(round((p/100.0)*(len(s)-1))))
return s[k]
def hist(x, edges):
tot = len(x)
out = []
for lo, hi in zip(edges[:-1], edges[1:]):
c = sum(1 for v in x if lo <= v < hi)
out.append((f"[{lo},{hi})", c/tot if tot else 0.0))
return out
res = {
"path": path, "n": n,
"speed_hist": hist(speeds, [0, 0.5, 1, 2, 3, 4, 5, 6, 7, 7.5, 8.01]),
"speed_mean": st.mean(speeds), "speed_median": st.median(speeds),
"speed_std": (st.pstdev(speeds) if n > 1 else 0.0),
"speed_p90": pct(speeds, 90),
"frac_rest": sum(1 for v in speeds if v < 0.5)/n,
"frac_full": sum(1 for v in speeds if v >= 7.5)/n,
"frac_neg": sum(1 for v in signed if v < -0.5)/n,
"hc_mean": st.mean(heading_changes) if heading_changes else float("nan"),
"hc_median": st.median(heading_changes) if heading_changes else float("nan"),
"hc_p90": pct(heading_changes, 90), "hc_p99": pct(heading_changes, 99),
"hc_max": max(heading_changes) if heading_changes else float("nan"),
"frac_hc_lt1": (sum(1 for v in heading_changes if v < 1.0)/len(heading_changes)) if heading_changes else float("nan"),
"frac_hc_gt5": (sum(1 for v in heading_changes if v > 5.0)/len(heading_changes)) if heading_changes else float("nan"),
"hc_hist": hist(heading_changes, [0, 0.5, 1, 2, 3, 5, 7, 10, 11, 180.1]),
"dist_mean": st.mean(dists), "dist_median": st.median(dists),
"dist_p10": pct(dists, 10), "dist_p90": pct(dists, 90),
"moving_ticks": moving_ticks,
"perp_frac": (sum(1 for v in perp_sin if v > 0.866)/len(perp_sin)) if perp_sin else float("nan"),
"radial_frac": (sum(1 for v in radial_cos if v > 0.866)/len(radial_cos)) if radial_cos else float("nan"),
"mean_abs_sin": st.mean(perp_sin) if perp_sin else float("nan"),
"mean_abs_cos": st.mean(radial_cos) if radial_cos else float("nan"),
"conv_err_same_tick_mean": st.mean(disp_err) if disp_err else float("nan"),
"conv_err_prev_tick_mean": st.mean(disp_err_next) if disp_err_next else float("nan"),
"conv_err_same_tick_median": st.median(disp_err) if disp_err else float("nan"),
}
return res
if __name__ == "__main__":
for path in sys.argv[1:]:
r = analyze(path)
print("="*100)
print(r["path"], "ticks=", r["n"], "movingTicks=", r["moving_ticks"])
print(f" conversion check: mean |angle(displacement) - movementdir| = {r['conv_err_same_tick_mean']:.3f} deg "
f"(median {r['conv_err_same_tick_median']:.3f}); using prev-tick heading {r['conv_err_prev_tick_mean']:.3f}")
print(f" SPEED: mean={r['speed_mean']:.3f} median={r['speed_median']:.3f} std={r['speed_std']:.3f} p90={r['speed_p90']:.2f} "
f"rest(<0.5)={r['frac_rest']:.3f} full(>=7.5)={r['frac_full']:.3f} neg={r['frac_neg']:.3f}")
print(" speed hist:", " ".join(f"{k}:{v:.3f}" for k,v in r["speed_hist"]))
print(f" HEADING CHANGE: mean={r['hc_mean']:.3f} median={r['hc_median']:.3f} p90={r['hc_p90']:.2f} p99={r['hc_p99']:.2f} max={r['hc_max']:.2f} "
f"|d|<1={r['frac_hc_lt1']:.3f} |d|>5={r['frac_hc_gt5']:.3f}")
print(" heading-change hist:", " ".join(f"{k}:{v:.3f}" for k,v in r["hc_hist"]))
print(f" DISTANCE: mean={r['dist_mean']:.1f} median={r['dist_median']:.1f} p10={r['dist_p10']:.1f} p90={r['dist_p90']:.1f}")
print(f" LATERAL/RADIAL: perpFrac={r['perp_frac']:.3f} radialFrac={r['radial_frac']:.3f} "
f"mean|sin|={r['mean_abs_sin']:.3f} mean|cos|={r['mean_abs_cos']:.3f}")
+93
View File
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
#
# Reproduce the classic-Robocode DrussGT movement fixtures in tools/fixtures/.
#
# This script downloads classic Robocode 1.9.5.5 and the third-party DrussGT jar
# into /tmp (NOT into the repository), runs headless battles with the Capture
# observer, and writes JSONL fixtures + round-boundary sidecars.
#
# Requirements: bash, curl, unzip, javac/java (Java 11+; tested on Java 21 with
# -Djava.security.manager=allow and --add-opens flags below).
#
# Usage: tools/robocode_fixture_capture/capture.sh [output_dir]
# (default output_dir = tools/fixtures)
#
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
REPO="$(cd "$HERE/../.." && pwd)"
OUT="${1:-$REPO/tools/fixtures}"
WORK=/tmp/robocode
INSTALL="$WORK/install"
ROBOCODE_VER=1.9.5.5
ROBOCODE_SETUP_URL="https://sourceforge.net/projects/robocode/files/robocode/$ROBOCODE_VER/robocode-$ROBOCODE_VER-setup.jar/download"
DRUSSGT_URL="http://robocode-archive.strangeautomata.com/robots/jk.mega.DrussGT_3.1.4159.jar"
mkdir -p "$WORK/dl" "$WORK/work" "$OUT"
# ---------------------------------------------------------------------------
# 1. Classic Robocode (installer jar is a plain zip with the full install)
# ---------------------------------------------------------------------------
if [ ! -d "$INSTALL/libs" ]; then
echo "[capture] downloading classic Robocode $ROBOCODE_VER from SourceForge"
curl -sSL -o "$WORK/dl/robocode-$ROBOCODE_VER-setup.jar" "$ROBOCODE_SETUP_URL"
unzip -q -o "$WORK/dl/robocode-$ROBOCODE_VER-setup.jar" -d "$INSTALL"
fi
# ---------------------------------------------------------------------------
# 2. DrussGT (third-party, keep OUT of git)
# ---------------------------------------------------------------------------
if [ ! -f "$WORK/dl/DrussGT.jar" ]; then
echo "[capture] downloading DrussGT 3.1.4159"
curl -sSL -o "$WORK/dl/DrussGT.jar" "$DRUSSGT_URL"
fi
cp -f "$WORK/dl/DrussGT.jar" "$INSTALL/robots/jk.mega.DrussGT_3.1.4159.jar"
# ---------------------------------------------------------------------------
# 3. Trivial contrast bot, packaged as a jar so the repository indexes it
# ---------------------------------------------------------------------------
rm -rf "$WORK/work/trivialjar"
mkdir -p "$WORK/work/trivialjar/trivial"
javac -cp "$INSTALL/libs/robocode.jar" -d "$WORK/work/trivialjar" "$HERE/StraightLine.java"
cp "$HERE/StraightLine.properties" "$WORK/work/trivialjar/trivial/StraightLine.properties"
printf 'Manifest-Version: 1.0\nrobots: trivial.StraightLine\n\n' > "$WORK/work/trivialjar/MANIFEST.MF"
( cd "$WORK/work/trivialjar" && jar cfm "$INSTALL/robots/trivial.StraightLine.jar" \
MANIFEST.MF trivial/StraightLine.class trivial/StraightLine.properties )
# ---------------------------------------------------------------------------
# 4. Capture program
# ---------------------------------------------------------------------------
javac -cp "$INSTALL/libs/*" -d "$WORK/work" "$HERE/Capture.java"
rm -f "$INSTALL/robots/robot.database" # force repository re-scan
run_capture() { # enemy shooter rounds out label note
echo "[capture] $1 vs $2 ($3 rounds) -> $4"
( cd "$INSTALL" && java -Djava.security.manager=allow \
--add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.desktop/sun.awt=ALL-UNNAMED \
-cp "$WORK/work:$INSTALL/libs/*" -Xmx512M \
Capture "$1" "$2" "$3" "$4" "$5" "$6" ) | grep -E 'rows=|rounds ticks|errors' || true
}
NOTE_D="e*=DrussGT 3.1.4159 (jk.mega.DrussGT) on classic Robocode 1.9.5.5; s*=opponent. tick is global/continuous across all rounds, so positions jump at round boundaries (see drussgt_meta/*.rounds.json sidecar). es/ss are SIGNED velocity (classic getVelocity, px/tick; negative = reversing). Heading conversion: classic snapshot headings are radians (0=north, clockwise) -> deg=toDegrees(raw); tank=(90-deg) mod 360 (0=east, CCW). Positions x/y are unchanged (same axes). Captured headless via RobocodeEngine TurnEndedEvent (perfect info, no fog)."
run_capture jk.mega.DrussGT sample.SpinBot 20 "$OUT/drussgt_vs_spinbot.jsonl" DrussGT "$NOTE_D"
run_capture jk.mega.DrussGT sample.RamFire 20 "$OUT/drussgt_vs_ramfire.jsonl" DrussGT "$NOTE_D"
run_capture jk.mega.DrussGT sample.Crazy 20 "$OUT/drussgt_vs_crazy.jsonl" DrussGT "$NOTE_D"
run_capture jk.mega.DrussGT sample.Corners 20 "$OUT/drussgt_vs_corners.jsonl" DrussGT "$NOTE_D"
run_capture jk.mega.DrussGT jk.mega.DrussGT 2 "$OUT/drussgt_vs_drussgt.jsonl" DrussGT "$NOTE_D"
run_capture sample.SittingDuck sample.SittingDuck 1 "$OUT/contrast_stationary_sittingduck.jsonl" SittingDuck \
"e*=sample.SittingDuck (stationary). s*=sample.SittingDuck. Contrast fixture: zero movement by construction."
run_capture trivial.StraightLine sample.SittingDuck 1 "$OUT/contrast_straightline.jsonl" StraightLine \
"e*=trivial.StraightLine (constant-speed straight legs, 180-degree turns at walls). s*=sample.SittingDuck. Contrast fixture."
# Move sidecars out of the *.jsonl namespace
mkdir -p "$OUT/drussgt_meta"
for f in "$OUT"/*.jsonl.rounds.json; do
[ -e "$f" ] && mv -f "$f" "$OUT/drussgt_meta/"
done
echo "[capture] done. Validate with:"
echo " python3 $HERE/analyze.py $OUT/drussgt_vs_*.jsonl $OUT/contrast_*.jsonl"