|
| 1 | +# Importing a classic Robocode bot into the CodeClash arena |
| 2 | + |
| 3 | +This arena is **classic Robocode** (Java, `robocode.jar`), NOT Tank Royale. Importing an |
| 4 | +open-source classic bot is mostly a mechanical **copy-in + rename**, not a strategy rewrite. |
| 5 | + |
| 6 | +## The submission contract |
| 7 | +The submission is a directory `robots/custom/` containing Java source. The arena harness then: |
| 8 | +1. copies `robots/custom/*` into `robots/<player>/`, |
| 9 | +2. runs `sed 's/custom/<player>/g'` over every `.java` (this renames the `package custom` → |
| 10 | + `package <player>` so bots are namespaced), |
| 11 | +3. compiles `javac -cp "libs/robocode.jar" robots/<player>/*.java` ← **flat glob, one directory**, |
| 12 | +4. runs battles selecting `<player>.MyTank*`. |
| 13 | + |
| 14 | +`validate_code` requires `robots/custom/MyTank.java` to exist, compile, and produce `MyTank.class`. |
| 15 | + |
| 16 | +## Hard rules for a port (`ports/<slug>/`) |
| 17 | +Produce a directory `scripts/ladder/ports/<slug>/` containing: |
| 18 | +- **`MyTank.java`** — the bot's main class, **renamed to `public class MyTank`** (rename the source's |
| 19 | + main class everywhere: declaration, constructors, and any self-references). It must |
| 20 | + `extends robocode.Robot` (or `AdvancedRobot` / `TeamRobot` / `RateControlRobot` / `JuniorRobot`). |
| 21 | +- **`package custom;`** as the package line in `MyTank.java` and in *every* helper file. Replace any |
| 22 | + original `package a.b.c;`. |
| 23 | +- **Helper classes** (if the bot is multi-file) as additional flat `.java` files in the same dir, |
| 24 | + also `package custom;`. **No nested subdirectories** — the compile is a flat `*.java` glob, so a |
| 25 | + bot that uses nested packages (e.g. `voidious/gun/…`) must be flattened or it won't compile. |
| 26 | + Inner classes inside one file are fine (preferred). |
| 27 | +- **The literal substring `custom` must NOT appear anywhere except the `package custom;` lines.** |
| 28 | + The harness's `sed s/custom/<player>/g` is a blind global replace, so any identifier, comment, or |
| 29 | + string containing "custom" would be corrupted. Rename such tokens. |
| 30 | + |
| 31 | +## What's allowed / what breaks |
| 32 | +- Only the classic `robocode.*` API. No Tank Royale (`dev.robocode.tankroyale.*`). |
| 33 | +- Robocode runs under a security manager: **raw `java.io`, threads, reflection, and network are |
| 34 | + blocked.** Persistent gun/enemy stats via the sanctioned `getDataFile()` + |
| 35 | + `RobocodeFileOutputStream` are allowed but **may not persist** across our battles — such a bot |
| 36 | + still compiles and plays, it just degrades to no saved data (fine; note it). If the source uses |
| 37 | + raw `java.io`/threads/reflection, it will fail — flag and skip, or strip that path if it's optional. |
| 38 | +- Keep behavior faithful: do not "improve" the bot; only rename/repackage/flatten. |
| 39 | + |
| 40 | +## Deliverable + report |
| 41 | +Write the port dir `scripts/ladder/ports/<slug>/` (at minimum `MyTank.java`). It must be valid Java |
| 42 | +that would compile against `robocode.jar`. In your report note per bot: source repo/author, base |
| 43 | +class, #files, and any caveat (data-file use, "custom"-token rename you had to do, multi-file, or |
| 44 | +anything you had to strip). A reference `MyTank.java` lives at |
| 45 | +`scripts/ladder/examples/robots/custom/MyTank.java`. |
0 commit comments