Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bots/python/Vector/Vector.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
python "%~dp0src\Vector.py" %*
10 changes: 10 additions & 0 deletions bots/python/Vector/Vector.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "Vector",
"version": "1.0.0",
"authors": ["Tank Royale Rumble maintainers"],
"description": "A small source-only bot that drives in wide arcs across the arena.",
"platform": "Python",
"programmingLang": "Python 3",
"gameTypes": ["1v1", "melee", "twinduel"],
"license": "Apache-2.0"
}
10 changes: 10 additions & 0 deletions bots/python/Vector/Vector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env sh
set -eu
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -n "${RUMBLE_PYTHON:-}" ]; then
exec "$RUMBLE_PYTHON" "$SCRIPT_DIR/src/Vector.py" "$@"
fi
if command -v python3 >/dev/null 2>&1; then
exec python3 "$SCRIPT_DIR/src/Vector.py" "$@"
fi
exec python "$SCRIPT_DIR/src/Vector.py" "$@"
35 changes: 35 additions & 0 deletions bots/python/Vector/src/Vector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""A compact Rumble catalog bot used for the first live ranked 1v1 proof."""

import os


if os.environ.get("RUMBLE_SMOKE") == "1":
print("RUMBLE_SMOKE_READY Vector")
raise SystemExit(0)

from robocode_tank_royale.bot_api.bot import Bot
from robocode_tank_royale.bot_api.events import ScannedBotEvent


class Vector(Bot):
"""Sweeps the radar while travelling in a wide arc."""

def run(self) -> None:
self.turn_radar_right(360)
while self.running:
self.set_turn_right(30)
self.forward(10_000)

def on_scanned_bot(self, event: ScannedBotEvent) -> None:
"""Aim at the detected opponent and fire before continuing the scan."""
self.turn_gun_right(self.gun_bearing_to(float(event.x), float(event.y)))
self.fire(3)
self.rescan()


def main() -> None:
Vector().start()


if __name__ == "__main__":
main()
7 changes: 4 additions & 3 deletions tests/test_validate_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def test_valid_submission_generates_an_active_catalog_entry(self) -> None:
result = self.run_validator("--smoke", "--generate")
self.assertEqual(0, result.returncode, result.stderr)
catalog = json.loads((self.root / "bots" / "index.json").read_text(encoding="utf-8"))
active_entry = next(entry for entry in catalog["bots"] if entry["status"] == "active")
self.assertEqual("Orbit", active_entry["name"])
orbit = next(entry for entry in catalog["bots"] if entry["name"] == "Orbit")
self.assertEqual("active", orbit["status"])

def test_invalid_license_is_rejected(self) -> None:
config_path = self.root / "bots" / "python" / "Orbit" / "Orbit.json"
Expand All @@ -101,7 +101,8 @@ def test_version_increase_supersedes_the_previous_catalog_entry(self) -> None:
config_path.write_text(json.dumps(config), encoding="utf-8")
self.assertEqual(0, self.run_validator("--generate").returncode)
catalog = json.loads((self.root / "bots" / "index.json").read_text(encoding="utf-8"))
self.assertEqual(["superseded", "active"], [entry["status"] for entry in catalog["bots"]])
orbit = [entry for entry in catalog["bots"] if entry["name"] == "Orbit"]
self.assertEqual(["superseded", "active"], [entry["status"] for entry in orbit])

def test_new_bot_from_another_owner_ignores_unchanged_catalog_entries(self) -> None:
self.assertEqual(0, self.run_validator("--generate").returncode)
Expand Down
Loading