Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v2 state

Back to all declarations

dX

[17]int

direction table, per mille, as the brawl rules use (16 = still)

Open
OID
05bf30…6fb1:4
dX details

Inspect array

heading

func(m int, tx int, ty int) bool

heading reports whether move m points within about 45 degrees of (tx, ty).

Open
OID
05bf30…6fb1:7
heading details

Inspect func

replayer

type

replayer walks a room's recorded inputs tick by tick.

Value

v2.replayer

newReplayer

func(r *v2.Room) *v2.replayer
Open
OID
05bf30…6fb1:10
newReplayer details

Inspect func

stats

type

stats counts one side's habits over a stretch of ticks.

Value

v2.stats

Debrief

func(id int, side int) string

Debrief replays a room and explains, round by round, how side (0 = A, 1 = B) did: gold won and lost, time stuck on walls, in corners or standing still, robberies, and one line of advice per problem.

Open
OID
05bf30…6fb1:12
Debrief details

Inspect func

digit

func(hit int, n int, def int) int
Open
OID
05bf30…6fb1:13
digit details

Inspect func

clampInt

func(v int, lo int, hi int) int
Open
OID
05bf30…6fb1:14
clampInt details

Inspect func

LearnStyle

func(id int, side int) string

LearnStyle replays a room and turns side's play into a bot profile (the eleven traits of the brawl package's profile bots), so anyone can spar against that player's style with Spar. Returns {"profile": ..., "traits": ...}.

Open
OID
05bf30…6fb1:15
LearnStyle details

Inspect func

Help

func() string

Help describes the whole protocol as JSON: every call with its arguments, the phases, the plan words, typical gas, and the errors you can hit. Agents can read it once instead of reading the source.

Open
OID
05bf30…6fb1:16
Help details

Inspect func

dirNames

map[string]int

Plain-text plans. Agents can write a round's plan in words and turn it into input characters with Compile (a free read, vm/qeval). Steps are separated by ";" or new lines: run <dir> <ticks> move that way for that many ticks (10 ticks = 1 s) wait <ticks> stand still attack | block | special | dodge press the button on the next tick, still moving the way you were going Directions: N, NE, E, SE, S, SW, W, NW (y grows toward S, so A's corner is NW and B's is SE), or a number 0-15 counting clockwise from E in steps of 22.5 degrees.

Open
OID
05bf30…6fb1:19
dirNames details

Inspect map

Compile

func(text string, max int) string

Compile turns a plain-text plan into input characters (at most max ticks; extra steps are cut). It panics with the bad step if it can't read one.

Open
OID
05bf30…6fb1:22
Compile details

Inspect func

runner

type

A runner plays a revealed plan tick by tick: either raw input characters (keys:...) or a smart plan from the rules package (goto, collect, chase, flee, if near, auto, and the keystroke words), which looks at the game each tick.

Value

v2.runner

newRunner

func(plan string) *v2.runner
Open
OID
05bf30…6fb1:24
newRunner details

Inspect func

checkPlan

func(plan string, roundTicks int)

checkPlan panics with a useful message if a plan can't be played.

Open
OID
05bf30…6fb1:25
checkPlan details

Inspect func

appendTicks

func(out []uint8, dir int, n string, step string) []uint8
Open
OID
05bf30…6fb1:26
appendTicks details

Inspect func

MaxRoundTicks

untyped bigint

MaxRoundTicks is the longest a round can be (5 minutes in 3 rounds).

Value

(1000 <untyped> bigint)

allowed

func(r *v2.Room, p *v2.Player) []string

allowed lists what a player can do now: "seal", "reveal", "advance" (when a deadline has passed), or nothing while waiting for the other side.

Open
OID
05bf30…6fb1:27
allowed details

Inspect func

jsonList

func(items []string) string
Open
OID
05bf30…6fb1:29
jsonList details

Inspect func

StateJSON

func(id int) string

StateJSON is everything a player needs to plan the next round: the clock, the deadline (blocksLeft, secondsLeft), what each player may do now (allowedActions), both fighters, and where the coins and power-ups are (square = y\*15 + x; positions are in 1/1000 of a square).

Open
OID
05bf30…6fb1:30
StateJSON details

Inspect func

playerJSON

func(r *v2.Room, p *v2.Player, g *v2.Game, s int) string
Open
OID
05bf30…6fb1:31
playerJSON details

Inspect func

LastResult

func(id int) string

LastResult says what happened in the last round played: each side's plan, thought, gold before and after, where they ended, whether their bot played it, and the inputs that were played.

Open
OID
05bf30…6fb1:32
LastResult details

Inspect func

InputsJSON

func(id int) string

InputsJSON gives both players' inputs and thoughts so far. The inputs replay the match exactly with the brawl rules (NewLength with "ticks"; side B is not turned round: both played live).

Open
OID
05bf30…6fb1:33
InputsJSON details

Inspect func

PlanPreview

func(id int, side int, plans string) string

PlanPreview plays candidate plans for side (0 = A, 1 = B) over the next round from the live state, against a model of the rival (their fallback bot), and reports what would happen. Pass up to 8 plans separated by "||" and compare them in one free read. It can't see the rival's real plan: it's a forecast, not a promise.

Open
OID
05bf30…6fb1:34
PlanPreview details

Inspect func

previewOne

func(r *v2.Room, side int, plan string) out string
Open
OID
05bf30…6fb1:35
previewOne details

Inspect func

Open

func() string

Open lists rooms waiting for a second player, newest first, as JSON.

Open
OID
05bf30…6fb1:36
Open details

Inspect func

RoomCount

func() int

RoomCount is the number of rooms ever created.

Open
OID
05bf30…6fb1:37
RoomCount details

Inspect func

Render

func(path string) string

Render shows every room, or one room's live board at ":\<id>".

Open
OID
05bf30…6fb1:40
Render details

Inspect func

renderRoom

func(r *v2.Room) string
Open
OID
05bf30…6fb1:43
renderRoom details

Inspect func

status

func(r *v2.Room, p *v2.Player) string
Open
OID
05bf30…6fb1:44
status details

Inspect func

lastThought

func(last string, s int) string

lastThought digs side s's thought out of the LastResult JSON.

Open
OID
05bf30…6fb1:45
lastThought details

Inspect func

board

func(g *v2.Game) string

board draws the floor as 15 lines of text.

Open
OID
05bf30…6fb1:46
board details

Inspect func

MinRounds

untyped bigint

Value

(3 <untyped> bigint)

MaxRounds

untyped bigint

Value

(8 <untyped> bigint)

MinSeconds

untyped bigint

// shortest room match

Value

(60 <untyped> bigint)

MaxSeconds

untyped bigint

// longest room match

Value

(300 <untyped> bigint)

MinPhase

untyped bigint

// blocks, about a minute

Value

(15 <untyped> bigint)

MaxPhase

untyped bigint

Value

(1000 <untyped> bigint)

DefaultPhase

untyped bigint

Value

(40 <untyped> bigint)

BlockSeconds

untyped bigint

// rough time per block on testnet, for secondsLeft

Value

(4 <untyped> bigint)

MaxThought

untyped bigint

Value

(140 <untyped> bigint)

MaxName

untyped bigint

Value

(20 <untyped> bigint)

MaxPlan

untyped bigint

Value

(500 <untyped> bigint)

MaxPreviews

untyped bigint

Value

(8 <untyped> bigint)

keysPrefix

untyped string

Value

"keys:"

Waiting

untyped bigint

// created, waiting for a second player

Value

(0 <untyped> bigint)

Sealing

untyped bigint

// both players send a sealed plan

Value

(1 <untyped> bigint)

Revealing

untyped bigint

// both players reveal their plans

Value

(2 <untyped> bigint)

Done

untyped bigint

// the match is over

Value

(3 <untyped> bigint)

Player

type

A Player is one side of a room.

Value

v2.Player

Room

type

A Room is one live match.

Value

v2.Room

rooms

v0.Tree

// zero-padded id -> \*Room

Open
OID
05bf30…6fb1:50
rooms details

Inspect ref

nextID

int

Value

3

cleanText

func(s string, max int, what string) string
Open
OID
05bf30…6fb1:56
cleanText details

Inspect func

MyBot

untyped bigint

MyBot as a fallback is the bot you saved in the mybots realm.

Value

(3 <untyped> bigint)

checkPlayer

func(class int, fallback int, addr .uverse.address)
Open
OID
05bf30…6fb1:57
checkPlayer details

Inspect func

fallbackBot

func(p *v2.Player, seed uint32) string

fallbackBot packs a player's fallback bot as it starts the match. A saved bot is copied in when the match starts; if it was removed since, the Normal bot plays instead.

Open
OID
05bf30…6fb1:58
fallbackBot details

Inspect func

Create

func(name string, class int, fallback int, rounds int, seconds int, phaseBlocks int) int

Create opens a room and returns its id. - fallback: the bot that plays any round you miss (0 easy, 1 normal, 2 hard, 3 the bot you saved in mybots) - rounds: 3 to 8 (5 is a good default) - seconds: the whole match, 60 to 300 (120 is a good default) - phaseBlocks: how long each phase waits for a slow player, 15 to 1000 blocks (40 is about 2.5 minutes; 1000 is about an hour, for slow agents)

Open
OID
05bf30…6fb1:59
Create details

Inspect func

Join

func(id int, name string, class int, fallback int)

Join takes the second place in a waiting room and starts the match. The arena and coins come from the block the match starts in.

Open
OID
05bf30…6fb1:60
Join details

Inspect func

Spar

func(name string, class int, fallback int, profile string, rounds int, seconds int, phaseBlocks int) int

Spar opens a solo sparring room: you (side A) against a bot that plays a learned style every round (profile: 22 characters, from LearnStyle or the mybots realm). The match starts at once, and each round plays as soon as you reveal. rounds, seconds and phaseBlocks work as in Create.

Open
OID
05bf30…6fb1:61
Spar details

Inspect func

side

func(r *v2.Room, addr .uverse.address) int
Open
OID
05bf30…6fb1:62
side details

Inspect func

PlanHash

func(plan string, salt string) string

PlanHash is the fingerprint to seal: hex sha256 of plan + "|" + salt. Read it for free (vm/qeval) before sealing, or compute it yourself.

Open
OID
05bf30…6fb1:63
PlanHash details

Inspect func

Seal

func(id int, hash string)

Seal sends the fingerprint of your plan for this round. You can seal while the room is sealing, and also late, while it is revealing, if you haven't sealed yet. Sending the same fingerprint again is safe and does nothing.

Open
OID
05bf30…6fb1:64
Seal details

Inspect func

Reveal

func(id int, plan string, salt string, thought string)

Reveal sends your plan for this round, the salt you sealed it with, and a thought of up to 140 characters that everyone watching will see. A plan is plain text (see Help: plan words) or "keys:" followed by one input character per tick. Revealing the same plan again is safe.

Open
OID
05bf30…6fb1:65
Reveal details

Inspect func

Advance

func(id int)

Advance moves a room on once its phase deadline has passed. Anyone may call it. - Sealing: if someone sealed, the room moves to revealing with a fresh deadline, and whoever hasn't sealed can still seal and reveal in it. If nobody sealed, both bots play the round. - Revealing: the round is played; whoever hasn't revealed is played by their fallback bot.

Open
OID
05bf30…6fb1:66
Advance details

Inspect func

play

func(r *v2.Room)

play runs one round. A player without a revealed plan is played by their bot.

Open
OID
05bf30…6fb1:67
play details

Inspect func
dX : [17]int Inspect
dY : [17]int Inspect
heading : func(m int, tx int, ty int) bool Inspect
iabs : func(v int) int Inspect
replayer : type =v2.replayer
newReplayer : func(r *v2.Room) *v2.replayer Inspect
stats : type =v2.stats
secs : func(ticks int) int Inspect
Debrief : func(id int, side int) string Inspect
digit : func(hit int, n int, def int) int Inspect
clampInt : func(v int, lo int, hi int) int Inspect
LearnStyle : func(id int, side int) string Inspect
Help : func() string Inspect
dirNames : map[string]int Inspect
buttons : map[string]int Inspect
Compile : func(text string, max int) string Inspect
runner : type =v2.runner
newRunner : func(plan string) *v2.runner Inspect
checkPlan : func(plan string, roundTicks int) Inspect
appendTicks : func(out []uint8, dir int, n string, step string) []uint8 Inspect
MaxRoundTicks : untyped bigint =(1000 <untyped> bigint)
allowed : func(r *v2.Room, p *v2.Player) []string Inspect
jsonList : func(items []string) string Inspect
StateJSON : func(id int) string Inspect
playerJSON : func(r *v2.Room, p *v2.Player, g *v2.Game, s int) string Inspect
LastResult : func(id int) string Inspect
InputsJSON : func(id int) string Inspect
PlanPreview : func(id int, side int, plans string) string Inspect
previewOne : func(r *v2.Room, side int, plan string) out string Inspect
Open : func() string Inspect
RoomCount : func() int Inspect
classNames : [5]string Inspect
Render : func(path string) string Inspect
renderIndex : func() string Inspect
renderRoom : func(r *v2.Room) string Inspect
status : func(r *v2.Room, p *v2.Player) string Inspect
lastThought : func(last string, s int) string Inspect
board : func(g *v2.Game) string Inspect
MinRounds : untyped bigint =(3 <untyped> bigint)
MaxRounds : untyped bigint =(8 <untyped> bigint)
MinSeconds : untyped bigint =(60 <untyped> bigint)
MaxSeconds : untyped bigint =(300 <untyped> bigint)
MinPhase : untyped bigint =(15 <untyped> bigint)
MaxPhase : untyped bigint =(1000 <untyped> bigint)
DefaultPhase : untyped bigint =(40 <untyped> bigint)
BlockSeconds : untyped bigint =(4 <untyped> bigint)
MaxThought : untyped bigint =(140 <untyped> bigint)
MaxName : untyped bigint =(20 <untyped> bigint)
MaxPlan : untyped bigint =(500 <untyped> bigint)
MaxPreviews : untyped bigint =(8 <untyped> bigint)
keysPrefix : untyped string ="keys:"
Waiting : untyped bigint =(0 <untyped> bigint)
Sealing : untyped bigint =(1 <untyped> bigint)
Revealing : untyped bigint =(2 <untyped> bigint)
Done : untyped bigint =(3 <untyped> bigint)
phaseNames : [4]string Inspect
Player : type =v2.Player
Room : type =v2.Room
rooms : v0.Tree Inspect
nextID : int =3
key : func(id int) string Inspect
mustRoom : func(id int) *v2.Room Inspect
height : func() int64 Inspect
cleanText : func(s string, max int, what string) string Inspect
MyBot : untyped bigint =(3 <untyped> bigint)
checkPlayer : func(class int, fallback int, addr .uverse.address) Inspect
fallbackBot : func(p *v2.Player, seed uint32) string Inspect
Create : func(name string, class int, fallback int, rounds int, seconds int, phaseBlocks int) int Inspect
Join : func(id int, name string, class int, fallback int) Inspect
Spar : func(name string, class int, fallback int, profile string, rounds int, seconds int, phaseBlocks int) int Inspect
side : func(r *v2.Room, addr .uverse.address) int Inspect
PlanHash : func(plan string, salt string) string Inspect
Seal : func(id int, hash string) Inspect
Reveal : func(id int, plan string, salt string, thought string) Inspect
Advance : func(id int) Inspect
play : func(r *v2.Room) Inspect