ai-code-battle/starters/javascript
jedarden 6c1f031071 feat(config): add season_id + rules_version to Config per §4.2
- SeasonID and RulesVersion already present in engine/types.go Config struct
- Worker already populates from active season row via DB join
- Config embedded in VisibleState sent to bots each turn (including turn 0)
- All starter kits (go, python, rust, java, csharp) already expose and log fields
- Add season_id/rules_version logging to JavaScript starter on turn 0
- TypeScript Config interface already includes season_id and rules_version

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 18:09:26 -04:00
..
.github/workflows feat(starters,web): add 6-language bot starter kits per §6 2026-04-21 13:58:27 -04:00
Dockerfile feat(evolver): persist cross-pollination state to Postgres per §10.2 2026-04-22 16:04:15 -04:00
grid.js feat(evolver): persist cross-pollination state to Postgres per §10.2 2026-04-22 16:04:15 -04:00
index.js feat(config): add season_id + rules_version to Config per §4.2 2026-04-22 18:09:26 -04:00
package.json feat(starters,web): add 6-language bot starter kits per §6 2026-04-21 13:58:27 -04:00
README.md feat(evolver): persist cross-pollination state to Postgres per §10.2 2026-04-22 16:04:15 -04:00

acb-starter-javascript

Node.js starter kit for AI Code Battle — a competitive bot programming platform.

Uses Node.js built-in http module with zero external dependencies.

Quick Start

# Run locally
BOT_SECRET=dev-secret node index.js

# Run with Docker
docker build -t my-bot .
docker run -e BOT_SECRET=your-secret -p 8080:8080 my-bot

Your bot listens on port 8080 and responds to POST /turn with move commands.

Register Your Bot

Once your bot is deployed and accessible via HTTPS:

curl -X POST https://api.aicodebattle.com/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-js-bot",
    "endpoint_url": "https://my-bot.example.com",
    "owner": "your-name",
    "description": "My awesome bot"
  }'

Save the bot_id and shared_secret from the response — the secret is shown only once.

Project Structure

index.js     # HTTP server, HMAC auth, and strategy entry point
grid.js      # Grid utilities (toroidal distance, BFS, neighbors)
package.json # Node.js project definition
Dockerfile   # Container build

Grid Helpers

grid.js provides utility functions for the toroidal grid:

  • toroidalManhattan(r1, c1, r2, c2, cols, rows) — Manhattan distance with wrap-around
  • toroidalChebyshev(r1, c1, r2, c2, cols, rows) — Chebyshev distance with wrap-around
  • neighbors(row, col, rows, cols) — 8-directional neighbors with wrap
  • bfs(start, goal, passable, rows, cols) — BFS pathfinding, returns path or null

Customization

Edit computeMoves() in index.js to implement your strategy. The state object provides:

  • bots — all visible bots (yours and enemies)
  • energy — visible energy pickup locations
  • cores — visible core positions
  • walls — visible wall positions
  • you.energy — your current energy count
  • you.score — your current score
  • config — match parameters (grid size, etc.)

Return an array of moves, each with position (your bot's current position) and direction ("N", "E", "S", or "W"). Bots not included in the response stay in place.

Protocol

  • Endpoint: POST /turn — receives game state JSON, returns moves JSON
  • Health: GET /health — must return 200
  • Timeout: 3 seconds per turn
  • Auth: HMAC-SHA256 via X-ACB-Signature header