ai-code-battle/starters/python/strategy.py
jedarden fe04cd275d fix(starter-kits): complete incomplete refactoring and fix build errors
The starter kits had uncommitted changes from a refactoring that broke
the Rust and TypeScript builds. This commit completes the refactoring
and fixes the build errors.

**Rust starter fixes:**
- Add `http::header` import to fix `header::HeaderName` reference
- Replace `hmac::compare_digest` (non-existent) with constant-time comparison

**TypeScript starter fixes:**
- Rename `GameState` -> `VisibleState` and `MoveResponse` -> `TurnResponse`
- Fix `strategy.ts` to use `bot.position.row` instead of `bot.row`
- Fix Move type to use `position: {row, col}` structure

**Go starter fixes:**
- Remove unused `strings` import

All 8 starter kits now build successfully with their respective toolchains.

Closes: bf-2rwz

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 22:40:37 -04:00

52 lines
1.5 KiB
Python

"""
Strategy module for AI Code Battle bot.
Implement your bot logic in the compute_moves() function.
"""
from typing import List, Dict, Any
def compute_moves(state: Dict[str, Any]) -> List[Dict[str, Any]]:
"""
Compute moves for all visible bots.
Args:
state: Game state with visible bots, energy, cores, walls
- bots: List of visible bots with position and owner
- energy: List of energy positions
- cores: List of core positions
- walls: List of wall positions
- you: Your bot's ID, energy, and score
Returns:
List of move objects, one per bot:
{
"position": {"row": int, "col": int},
"direction": "N" | "E" | "S" | "W" | ""
}
Example:
# Move all bots toward nearest energy
moves = []
for bot in state["bots"]:
if bot["owner"] == state["you"]["id"]:
# TODO: Implement your strategy here
moves.append({
"position": bot["position"],
"direction": "" # Hold position
})
return moves
"""
moves = []
# TODO: Implement your strategy here
# This stub holds all bots in place
for bot in state.get("bots", []):
if bot.get("owner") == state["you"]["id"]:
moves.append({
"position": bot["position"],
"direction": "" # Empty string = no move
})
return moves