What drawing primitives does the Tank Royale bot API expose for debug visualization? Specifically: what procs are available (drawLine, drawCircle, drawText, etc.), what coordinate system do they use, are they per-tick, and what are the limitations? This determines how the SNN debug overlay is designed.
## Question
What drawing primitives does the Tank Royale bot API expose for debug visualization? Specifically: what procs are available (drawLine, drawCircle, drawText, etc.), what coordinate system do they use, are they per-tick, and what are the limitations? This determines how the SNN debug overlay is designed.
Parent map: #147
Arena coordinates: bot absolute position (same as getX(), getY())
Y=0 is south, Y increases northward (standard Tank Royale frame)
All coordinates are float
Per-Tick Behavior:
Graphics are cleared automatically each tick after being flushed to BotIntent
The SVG buffer is wrapped in <g> tags and sent as debugGraphics JSON field
After each go() call, clearGraphics() resets:
SVG buffer (empty string)
Stroke color (WHITE)
Fill color (WHITE)
Stroke width (1.0)
Font family ("Arial")
Font size (12.0)
Style Control (persistent within tick):
setStrokeColor(color) — outline/line color
setFillColor(color) — fill color
setStrokeWidth(width) — line thickness
setFont(family, size) — text font and size
Color Support:
141 named color constants (Java Color class palette): RED, BLUE, GREEN, YELLOW, GRAY, CYAN, MAGENTA, etc.
Custom colors via fromRgb(r, g, b) or fromRgba(r, g, b, a) where r,g,b,a are uint8
Hex parsing via fromHex("#RRGGBB") or fromHex("#RRGGBBAA")
Alpha channel support for transparency (0 = fully transparent, 255 = opaque)
Limitations:
SVG-based rendering (client-side browser display, not server-side)
Primitives accumulate in memory each tick (buffer-only, no batching)
No hardware acceleration; suitable for debug visualization, not real-time heavy graphics
Text rendering limited to browser-supported SVG text (basic styling only)
Usage Pattern:
All draw calls within a single run() iteration accumulate in a buffer. When go() is called, the SVG is serialized into BotIntent and sent to the server, then the buffer is cleared for the next tick.
This answers the SNN debug overlay design requirements: use stroked primitives + text for lightweight visualization, with per-tick refresh guaranteed by automatic clearing.
## Tank Royale Debug Drawing API — Research Summary
**Drawing Primitives Available:**
The Tank Royale bot API (Nim) exposes these SVG-based debug drawing procs in the `graphics` module:
- `drawLine(x1, y1, x2, y2)` — line from point to point
- `drawRectangle(x, y, w, h)` — outline rectangle
- `fillRectangle(x, y, w, h)` — filled rectangle
- `drawCircle(x, y, r)` — outline circle
- `fillCircle(x, y, r)` — filled circle
- `drawPolygon(points: seq[(float, float)])` — outline polygon
- `fillPolygon(points: seq[(float, float)])` — filled polygon
- `drawText(text, x, y)` — text at position
**Coordinate System:**
- Arena coordinates: bot absolute position (same as `getX()`, `getY()`)
- Y=0 is south, Y increases northward (standard Tank Royale frame)
- All coordinates are `float`
**Per-Tick Behavior:**
- Graphics are **cleared automatically each tick** after being flushed to BotIntent
- The SVG buffer is wrapped in `<g>` tags and sent as `debugGraphics` JSON field
- After each `go()` call, `clearGraphics()` resets:
- SVG buffer (empty string)
- Stroke color (WHITE)
- Fill color (WHITE)
- Stroke width (1.0)
- Font family ("Arial")
- Font size (12.0)
**Style Control (persistent within tick):**
- `setStrokeColor(color)` — outline/line color
- `setFillColor(color)` — fill color
- `setStrokeWidth(width)` — line thickness
- `setFont(family, size)` — text font and size
**Color Support:**
- 141 named color constants (Java Color class palette): RED, BLUE, GREEN, YELLOW, GRAY, CYAN, MAGENTA, etc.
- Custom colors via `fromRgb(r, g, b)` or `fromRgba(r, g, b, a)` where r,g,b,a are `uint8`
- Hex parsing via `fromHex("#RRGGBB")` or `fromHex("#RRGGBBAA")`
- Alpha channel support for transparency (0 = fully transparent, 255 = opaque)
**Limitations:**
- SVG-based rendering (client-side browser display, not server-side)
- Primitives accumulate in memory each tick (buffer-only, no batching)
- No hardware acceleration; suitable for debug visualization, not real-time heavy graphics
- Text rendering limited to browser-supported SVG text (basic styling only)
**Usage Pattern:**
All draw calls within a single `run()` iteration accumulate in a buffer. When `go()` is called, the SVG is serialized into BotIntent and sent to the server, then the buffer is cleared for the next tick.
---
**Example (from GotoTest.nim):**
```nim
for i, (wx, wy) in waypoints:
if i == bot.waypointIdx:
setStrokeColor(RED)
else:
setStrokeColor(GRAY)
drawCircle(wx, wy, 10.0)
setStrokeColor(YELLOW)
drawLine(bx, by, tx, ty)
go() # sends SVG, clears buffer
```
This answers the SNN debug overlay design requirements: use stroked primitives + text for lightweight visualization, with per-tick refresh guaranteed by automatic clearing.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Question
What drawing primitives does the Tank Royale bot API expose for debug visualization? Specifically: what procs are available (drawLine, drawCircle, drawText, etc.), what coordinate system do they use, are they per-tick, and what are the limitations? This determines how the SNN debug overlay is designed.
Parent map: #147
Tank Royale Debug Drawing API — Research Summary
Drawing Primitives Available:
The Tank Royale bot API (Nim) exposes these SVG-based debug drawing procs in the
graphicsmodule:drawLine(x1, y1, x2, y2)— line from point to pointdrawRectangle(x, y, w, h)— outline rectanglefillRectangle(x, y, w, h)— filled rectangledrawCircle(x, y, r)— outline circlefillCircle(x, y, r)— filled circledrawPolygon(points: seq[(float, float)])— outline polygonfillPolygon(points: seq[(float, float)])— filled polygondrawText(text, x, y)— text at positionCoordinate System:
getX(),getY())floatPer-Tick Behavior:
<g>tags and sent asdebugGraphicsJSON fieldgo()call,clearGraphics()resets:Style Control (persistent within tick):
setStrokeColor(color)— outline/line colorsetFillColor(color)— fill colorsetStrokeWidth(width)— line thicknesssetFont(family, size)— text font and sizeColor Support:
fromRgb(r, g, b)orfromRgba(r, g, b, a)where r,g,b,a areuint8fromHex("#RRGGBB")orfromHex("#RRGGBBAA")Limitations:
Usage Pattern:
All draw calls within a single
run()iteration accumulate in a buffer. Whengo()is called, the SVG is serialized into BotIntent and sent to the server, then the buffer is cleared for the next tick.Example (from GotoTest.nim):
This answers the SNN debug overlay design requirements: use stroked primitives + text for lightweight visualization, with per-tick refresh guaranteed by automatic clearing.