Classic Mode · Reference

Classic Per-Turn Mode

Classic mode launches a fresh process on each move to output one action, suited for single-file course assignments and round-robin tournaments. For persistent search trees, neural nets, or pondering, use Agent Arena.

1. Quick start

  1. Open Classic Games and pick a game.
  2. In the online editor, choose Python, C, C++, or Java — it preloads a runnable template.
  3. Implement play_games(step): read the board via read_ckbd(step - 1) and print one legal move via save_decision(...).
  4. Submit and battle preset bots, classmates, or your own past submissions.
Important: Only emit your move to stdout (via save_decision). Any extra print() on stdout will corrupt the move parser — always print debug logs to stderr.

2. How each turn runs & player API

Your code compiles once at the start of a match, then launches fresh on each move — globals in memory do NOT persist between turns. Odd turns are Player A (1); even turns are Player B (2). Every match plays two legs (swapping who goes first).

  • read_ckbd(step - 1):reads the current board (placement games return board; movement games return playerA, playerB, board).
  • save_decision(...):emits your move — (row, col) for placement games, or (from_r, from_c, to_r, to_c) for movement games.
import random, sys
from battle_base import read_ckbd, save_decision

def play_games(step: int) -> None:
    _, _, board = read_ckbd(step - 1)
    me = 1 if step % 2 == 1 else 2
    moves = legal_moves(board, me)
    if not moves:
        save_decision(0, 0, 0, 0)
        return
    fx, fy, tx, ty = random.choice(moves)
    print(f"turn {step}: ({fx},{fy}) -> ({tx},{ty})", file=sys.stderr)
    save_decision(fx, fy, tx, ty)

3. Limits, Elo & Tournaments

ItemTypical defaultNotes
Time per move2000 msCapped at 15000 ms; exceeding forfeits (TLE).
Memory per move64 MiBCapped at 512 MiB (Java gets a higher floor).
Output cap~10 KBKeep stdout strictly to save_decision.
Tournaments3 / 1 / 0Round-robin two-leg league using each entrant’s latest submission at deadline; separate from Elo.