Skip to content

Commit 7131488

Browse files
committed
LightCycles: render rock obstacles + note them in arena description
1 parent 9d04647 commit 7131488

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

codeclash/arenas/lightcycles/lightcycles.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ class LightCyclesArena(CodeArena):
1212
name: str = "LightCycles"
1313
submission: str = "main.py"
1414
description: str = """Your bot (`main.py`) drives a cycle in LightCycles, a Tron light-cycles game. Each
15-
player rides around a bordered grid leaving a solid trail behind. Every tick all cycles move one cell
16-
simultaneously; you crash (and are eliminated) if you move into a wall/border, any trail (yours or an
17-
opponent's), or the same cell as another cycle (a head-on). The last cycle riding wins; if all remaining
18-
cycles crash on the same tick it's a draw; at the tick cap the most territory (trail cells) wins.
15+
player rides around a bordered grid leaving a solid trail behind. The board may contain static rock
16+
obstacles too. Every tick all cycles move one cell simultaneously; you crash (and are eliminated) if you
17+
move into a wall/border, a rock, any trail (yours or an opponent's), or the same cell as another cycle (a
18+
head-on). The last cycle riding wins; if all remaining cycles crash on the same tick it's a draw; at the
19+
tick cap the most territory (trail cells) wins.
1920
2021
Your bot must implement:
2122
def get_move(obs: dict) -> str
@@ -25,7 +26,7 @@ def get_move(obs: dict) -> str
2526
2627
`obs` gives the full deterministic state each tick: obs["tick"]/["max_ticks"], obs["width"]/["height"],
2728
obs["you"] (your id), obs["players"] (list of {id, x, y, dir, alive}), and obs["grid"]
28-
(grid[y][x] = owning player id, or -1 for empty; off-grid is a wall). Origin is top-left; N is -y.
29+
(grid[y][x] = player id >=0, -1 empty, or -2 rock; off-grid is a wall). Origin is top-left; N is -y.
2930
"""
3031

3132
def __init__(self, config, **kwargs):

codeclash/arenas/lightcycles/replay.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
DRAW_JS = """
2525
const ARENA = (function(){
2626
const PAL = ['#e5484d','#4593ff','#46a758','#f5d90a','#8e4ec6','#f76b15','#e93d82','#12a594'];
27-
const BG = '#0d1117', GRID_LINE = 'rgba(255,255,255,0.05)';
27+
const BG = '#0d1117', GRID_LINE = 'rgba(255,255,255,0.05)', ROCK_COL = '#4b5563';
2828
let W, H, CELL;
2929
function col(i){ return PAL[i % PAL.length]; }
3030
function setup(cv, G){
@@ -38,6 +38,9 @@
3838
ctx.strokeStyle = GRID_LINE; ctx.lineWidth = 1;
3939
for(let x=0;x<=W;x++){ ctx.beginPath(); ctx.moveTo(x*CELL,0); ctx.lineTo(x*CELL,cv.height); ctx.stroke(); }
4040
for(let y=0;y<=H;y++){ ctx.beginPath(); ctx.moveTo(0,y*CELL); ctx.lineTo(cv.width,y*CELL); ctx.stroke(); }
41+
// static rock obstacles
42+
ctx.fillStyle = ROCK_COL;
43+
(G.rocks || []).forEach(r => ctx.fillRect(r[0]*CELL, r[1]*CELL, CELL, CELL));
4144
const n = (G.frames[0].heads || []).length;
4245
// rebuild trails by accumulating every head cell up to frame i
4346
for(let p=0;p<n;p++){
@@ -118,7 +121,12 @@ def parse(self, raw: bytes, players: list[dict] | None = None) -> ReplayData:
118121
frames=frames,
119122
winner=winner,
120123
draw=draw,
121-
extra={"names": names, "num_players": n, "max_ticks": log.get("max_ticks")},
124+
extra={
125+
"names": names,
126+
"num_players": n,
127+
"max_ticks": log.get("max_ticks"),
128+
"rocks": log.get("rocks", []),
129+
},
122130
)
123131

124132
def peek_winner(self, raw: bytes, players: list[dict] | None = None) -> tuple[str | None, bool] | None:

0 commit comments

Comments
 (0)