ef16dd982d
Generalize the classic-Robocode shim so the hosted bot's main class, jar, extra classpath and data directory are configurable (SHIM_BOT_CLASS / SHIM_BOT_JAR / SHIM_EXTRA_CP / SHIM_DATA), with DrussGT kept as the default so every existing script, fixture and generated bot dir behaves identically. - LegacyBotBridge: generalized bridge (DrussGTBridge kept as an alias). - BotHost: (mainClass, jar, extraJars, dataDir); disableShield -> generic disableStaticBoolean. - ClassicPeer: implement ITeamRobotPeer; synthesize StatusEvent each turn; make move/turnBody/turnGun/turnRadar the immediate (turn-ending) variants; guard re-entrant execute() from event handlers; record delivered events. - make_botdir.sh / run_bridge_battle.sh / run_smoke.sh generalized, legacy invocations unchanged; generated launcher uses a per-process mktemp data dir so concurrent bots/battles cannot clobber one classic data directory. Validated 35 legacy bots against a real Tank Royale battle (2 rounds vs sample SpinBot): 28 usable (27 effective + DrussGT), 5 weak-but-playing, 2 failing. Adds robots.json (manifest) and LEGACY_BOTS.md (how-to, status, missing-API costs). No third-party jar is committed.
49 lines
1.9 KiB
Bash
Executable File
49 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build the Approach-(B) shim.
|
|
#
|
|
# Requires JAVA_HOME/javac on PATH, the genuine Robocode 1.9.5.5 jar (for the
|
|
# robocode.* API the peer implements) and the Tank Royale Java bot API jar (for
|
|
# DrussGTBridge / TrBattleCapture).
|
|
#
|
|
# ROBOCODE_JAR=/path/to/robocode.jar TR_BOT_API_JAR=/path/to/bot-api.jar ./build.sh
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROBOCODE_JAR="${ROBOCODE_JAR:-/tmp/robocode/install/libs/robocode.jar}"
|
|
TR_BOT_API_JAR="${TR_BOT_API_JAR:-$HOME/Downloads/sample-bots-java-1.0.2/lib/robocode-tankroyale-bot-api-1.0.2.jar}"
|
|
OUT="${OUT:-$HERE/out}"
|
|
RUNNER_JAR="${TR_RUNNER_JAR:-/home/davide/Projects/tank-royale/runner/examples/lib/robocode-tankroyale-runner.jar}"
|
|
|
|
if [[ ! -f "$ROBOCODE_JAR" ]]; then
|
|
echo "robocode.jar not found: $ROBOCODE_JAR" >&2
|
|
echo "Set ROBOCODE_JAR to a Robocode 1.9.5.5 install's libs/robocode.jar" >&2
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "$TR_BOT_API_JAR" ]]; then
|
|
echo "Tank Royale bot API jar not found: $TR_BOT_API_JAR" >&2
|
|
echo "Set TR_BOT_API_JAR to robocode-tankroyale-bot-api-*.jar" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$OUT"
|
|
javac -nowarn -cp "$ROBOCODE_JAR:$TR_BOT_API_JAR" -d "$OUT" \
|
|
"$HERE/src/robocode_shim/ClassicPeer.java" \
|
|
"$HERE/src/robocode_shim/BotHost.java" \
|
|
"$HERE/src/robocode_shim/TankRoyaleBridge.java" \
|
|
"$HERE/src/robocode_shim/ThreadManagerFix.java" \
|
|
"$HERE/src/robocode_shim/ThreadManagerFixTest.java" \
|
|
"$HERE/src/robocode_shim/LegacyBotBridge.java" \
|
|
"$HERE/src/robocode_shim/DrussGTBridge.java" \
|
|
"$HERE/src/robocode_shim/SmokeTest.java"
|
|
echo "shim built -> $OUT"
|
|
|
|
# The observer/capture program needs the battle-runner jar (which bundles the
|
|
# Tank Royale client model + embedded server) rather than the bot API.
|
|
if [[ -f "$RUNNER_JAR" ]]; then
|
|
javac -nowarn -cp "$RUNNER_JAR" -d "$OUT" \
|
|
"$HERE/src/robocode_shim/TrBattleCapture.java"
|
|
echo "capture built -> $OUT"
|
|
else
|
|
echo "runner jar not found ($RUNNER_JAR); skipped TrBattleCapture" >&2
|
|
fi
|