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.

arena state

Back to all declarations

maxBotsPerRealm

untyped bigint

Value

(5 <untyped> bigint)

startRating

untyped bigint

Value

(1200 <untyped> bigint)

Bot

type

Bot is a registered bot.

Value

arena.Bot

botsPerRealm

*v0.Tree

// realm path -> int

Open
OID
03dbb1…b9f9:7
botsPerRealm details

Inspect pointer

RegisterBot

func(name string, b bot.Bot)

RegisterBot enters a bot with a Move method. Call it from your bot realm, usually in init: func init(cur realm) { arena.RegisterBot(cross(cur), "my-bot", &myBot{}) }

Open
OID
03dbb1…b9f9:9
RegisterBot details

Inspect func

RegisterStrategy

func(name string, s bot.Strategy)

RegisterStrategy enters a bot written as a plain function. A function declared in a /p/ package has one extra guarantee: if it crashes, the arena can catch it straight away and score a forfeit without step mode.

Open
OID
03dbb1…b9f9:11
RegisterStrategy details

Inspect func

register

func(name string, b *arena.Bot)
Open
OID
03dbb1…b9f9:12
register details

Inspect func

validName

func(name string) string
Open
OID
03dbb1…b9f9:13
validName details

Inspect func

mustBot

func(name string) *arena.Bot
Open
OID
03dbb1…b9f9:14
mustBot details

Inspect func

BotInfo

type

BotInfo describes a bot for other realms and off-chain tools.

Value

arena.BotInfo

GetBot

func(name string) (arena.BotInfo, bool)

GetBot returns public information about a bot.

Open
OID
03dbb1…b9f9:15
GetBot details

Inspect func

BotCount

func() int

BotCount is the number of registered bots.

Open
OID
03dbb1…b9f9:16
BotCount details

Inspect func

bucketSize

untyped bigint

Value

(16 <untyped> bigint)

recSep

untyped string

// record separator inside a bucket

Value

"\x1e"

sep

untyped string

// field separator; never appears in names or reasons

Value

"\x1f"

byteOffset

untyped bigint

// coins (0-80) and moves (0-6) are shifted into printable bytes

Value

(40 <untyped> bigint)

codecV1

untyped string

Value

"1"

decode

func(id int, s string) *arena.Match
Open
OID
03dbb1…b9f9:23
decode details

Inspect func

record

func(id int) (string, bool)

record returns the stored string for match id.

Open
OID
03dbb1…b9f9:26
record details

Inspect func

eachRecent

func(maxScan int, fn func(...))

eachRecent calls fn on matches from newest to oldest, looking at no more than maxScan of them, until fn returns true.

Open
OID
03dbb1…b9f9:27
eachRecent details

Inspect func

MoveTimeout

untyped bigint

Value

(100 <untyped> bigint)

RatedCooldown

untyped bigint

Value

(1000 <untyped> bigint)

Status

type

Status of a match.

Value

arena.Status

Pending

arena.Status

// challenged, not played yet

Value

<zero>

Stepping

arena.Status

// being played one move per transaction

Value

<zero>

Finished

arena.Status

Value

<zero>

Match

type

Match is one game between two bots. Side 0 is A, side 1 is B.

Value

arena.Match

matches

*v0.Tree

// padded bucket number -> encoded matches (see codec.gno)

Open
OID
03dbb1…b9f9:29
matches details

Inspect pointer

lastID

int

Value

1

claimRatedSlot

func(a string, b string) bool

claimRatedSlot reports whether a new match between a and b is rated, and if so starts the pair's cooldown. The cooldown is kept on the bot whose name sorts first, as a short "opponent@block," list that drops expired entries, so it costs a few bytes instead of a tree node per pair.

Open
OID
03dbb1…b9f9:32
claimRatedSlot details

Inspect func

emit

func(typ string, attrs []string)
Open
OID
03dbb1…b9f9:36
emit details

Inspect func

mustMatch

func(id int) *arena.Match
Open
OID
03dbb1…b9f9:37
mustMatch details

Inspect func

seedFor

func(id int, a string, b string) int

seedFor gives every match its own board. The pair is mixed in so two matches created back to back between different bots differ too.

Open
OID
03dbb1…b9f9:38
seedFor details

Inspect func

Challenge

func(a string, b string) int

Challenge records a new match between two registered bots and returns its id. It runs no bot code, so it always succeeds; play it with Play or, if that fails, with step mode.

Open
OID
03dbb1…b9f9:39
Challenge details

Inspect func

newMatch

func(a string, b string) *arena.Match
Open
OID
03dbb1…b9f9:40
newMatch details

Inspect func

Play

func(id int) string

Play runs the rest of a match in this transaction. If a bot written in realm code crashes or runs out of gas, the whole transaction fails and the match stays as it was: switch it to step mode with StartStepMode.

Open
OID
03dbb1…b9f9:41
Play details

Inspect func

Fight

func(a string, b string) string

Fight challenges and plays in one transaction, saving the match once. If it fails, nothing is recorded: use Challenge, then Play or step mode.

Open
OID
03dbb1…b9f9:42
Fight details

Inspect func

StartStepMode

func(id int)

StartStepMode switches a pending match to one move per transaction. Anyone may call it.

Open
OID
03dbb1…b9f9:43
StartStepMode details

Inspect func

SubmitMove

func(id int) string

SubmitMove asks the bot whose turn it is for its move and records it. The move comes from the bot's own code, so nobody can submit a fake one. Anyone may call it.

Open
OID
03dbb1…b9f9:44
SubmitMove details

Inspect func

ClaimForfeit

func(id int) string

ClaimForfeit ends a step-mode match whose waiting bot missed its deadline. Anyone may call it.

Open
OID
03dbb1…b9f9:45
ClaimForfeit details

Inspect func

MatchSummary

func(id int) string

MatchSummary returns the summary of a match, for other realms and tools.

Open
OID
03dbb1…b9f9:46
MatchSummary details

Inspect func

MatchCount

func() int

MatchCount is the number of matches ever created.

Open
OID
03dbb1…b9f9:47
MatchCount details

Inspect func

kFactor

untyped bigint

Value

(32 <untyped> bigint)

expected

func(ra int, rb int) int

expected is a's chance of beating b, in thousandths, from an Elo-style rating gap. It uses a straight-line approximation of the logistic curve: even ratings give 500, and a gap of 400 or more is capped at 50 / 950.

Open
OID
03dbb1…b9f9:48
expected details

Inspect func

rate

func(a *arena.Bot, b *arena.Bot, winner int) int

rate updates both ratings for a result (0, 1, or -1 for a draw) and returns the change for a (b's is the opposite).

Open
OID
03dbb1…b9f9:50
rate details

Inspect func

self

string

// this realm's path as gnoweb links it, e.g. "/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena"

Value

"/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena"

tx

v0.Realm

// builds transaction links to this realm

Value

<gnolang.StringValue>

Render

func(path string) string

Render draws the arena pages in gnoweb: "" leaderboard, recent matches, rules "bot/<name>" a bot's record, source link and a challenge button "match/<id>" the final board, key moments and actions "match/<id>/<turn>" the board after one turn

Open
OID
03dbb1…b9f9:55
Render details

Inspect func

leaderboard

func() []*arena.Bot
Open
OID
03dbb1…b9f9:60
leaderboard details

Inspect func

better

func(a *arena.Bot, b *arena.Bot) bool
Open
OID
03dbb1…b9f9:61
better details

Inspect func

writeRecent

func(sb *strings.Builder, botName string, limit int)

writeRecent lists the latest matches, optionally only those of one bot among the last 500.

Open
OID
03dbb1…b9f9:63
writeRecent details

Inspect func

renderBot

func(name string) string
Open
OID
03dbb1…b9f9:64
renderBot details

Inspect func

renderMatch

func(m *arena.Match, turn int) string
Open
OID
03dbb1…b9f9:65
renderMatch details

Inspect func

writeActions

func(sb *strings.Builder, m *arena.Match)

writeActions shows the buttons that move an unfinished match along.

Open
OID
03dbb1…b9f9:66
writeActions details

Inspect func

writeMoments

func(sb *strings.Builder, m *arena.Match)

writeMoments lists the turns where coins changed hands.

Open
OID
03dbb1…b9f9:67
writeMoments details

Inspect func

eventNote

func(ev game.Events, side int) string
Open
OID
03dbb1…b9f9:69
eventNote details

Inspect func

drawBoard

func(pos [2]bot.Pos, coins []bot.Pos) string
Open
OID
03dbb1…b9f9:70
drawBoard details

Inspect func
maxBotsPerRealm : untyped bigint =(5 <untyped> bigint)
startRating : untyped bigint =(1200 <untyped> bigint)
Bot : type =arena.Bot
bots : *v0.Tree Inspect
botsPerRealm : *v0.Tree Inspect
RegisterBot : func(name string, b bot.Bot) Inspect
RegisterStrategy : func(name string, s bot.Strategy) Inspect
register : func(name string, b *arena.Bot) Inspect
validName : func(name string) string Inspect
mustBot : func(name string) *arena.Bot Inspect
BotInfo : type =arena.BotInfo
GetBot : func(name string) (arena.BotInfo, bool) Inspect
BotCount : func() int Inspect
bucketSize : untyped bigint =(16 <untyped> bigint)
recSep : untyped string ="\x1e"
sep : untyped string ="\x1f"
byteOffset : untyped bigint =(40 <untyped> bigint)
codecV1 : untyped string ="1"
shift : func(raw string) string Inspect
unshift : func(enc string) string Inspect
itoa : func(n int) string Inspect
i64 : func(n int64) string Inspect
flag : func(b bool) string Inspect
decode : func(id int, s string) *arena.Match Inspect
bucketKey : func(id int) string Inspect
bucket : func(id int) []string Inspect
record : func(id int) (string, bool) Inspect
eachRecent : func(maxScan int, fn func(...)) Inspect
MoveTimeout : untyped bigint =(100 <untyped> bigint)
RatedCooldown : untyped bigint =(1000 <untyped> bigint)
Status : type =arena.Status
Pending : arena.Status =<zero>
Stepping : arena.Status =<zero>
Finished : arena.Status =<zero>
Match : type =arena.Match
matches : *v0.Tree Inspect
lastID : int =1
claimRatedSlot : func(a string, b string) bool Inspect
key : func(id int) string Inspect
height : func() int64 Inspect
emit : func(typ string, attrs []string) Inspect
mustMatch : func(id int) *arena.Match Inspect
seedFor : func(id int, a string, b string) int Inspect
Challenge : func(a string, b string) int Inspect
newMatch : func(a string, b string) *arena.Match Inspect
Play : func(id int) string Inspect
Fight : func(a string, b string) string Inspect
StartStepMode : func(id int) Inspect
SubmitMove : func(id int) string Inspect
ClaimForfeit : func(id int) string Inspect
MatchSummary : func(id int) string Inspect
MatchCount : func() int Inspect
kFactor : untyped bigint =(32 <untyped> bigint)
expected : func(ra int, rb int) int Inspect
rate : func(a *arena.Bot, b *arena.Bot, winner int) int Inspect
self : string ="/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena"
tx : v0.Realm =<gnolang.StringValue>
init.57 : func() Inspect
Render : func(path string) string Inspect
renderHome : func() string Inspect
leaderboard : func() []*arena.Bot Inspect
better : func(a *arena.Bot, b *arena.Bot) bool Inspect
writeRecent : func(sb *strings.Builder, botName string, limit int) Inspect
renderBot : func(name string) string Inspect
renderMatch : func(m *arena.Match, turn int) string Inspect
writeActions : func(sb *strings.Builder, m *arena.Match) Inspect
writeMoments : func(sb *strings.Builder, m *arena.Match) Inspect
signed : func(n int) string Inspect
eventNote : func(ev game.Events, side int) string Inspect
drawBoard : func(pos [2]bot.Pos, coins []bot.Pos) string Inspect