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

jsonString

func(s string) string
Open
OID
00df69…e035:3
jsonString details

Inspect func

jsonObj

type

Value

v2.jsonObj

jsonArray

func(items []string) string
Open
OID
00df69…e035:5
jsonArray details

Inspect func

ArenaJSON

func() string

ArenaJSON returns counts, the current season and the block height.

Open
OID
00df69…e035:8
ArenaJSON details

Inspect func

BotsJSON

func() string

BotsJSON returns every bot, ranked like the leaderboard.

Open
OID
00df69…e035:9
BotsJSON details

Inspect func

BotJSON

func(name string) string

BotJSON returns one bot, with its earlier versions.

Open
OID
00df69…e035:10
BotJSON details

Inspect func

matchSummaryJSON

func(m *v2.Match) string
Open
OID
00df69…e035:11
matchSummaryJSON details

Inspect func

MatchesJSON

func(botName string, limit int) string

MatchesJSON returns up to limit matches, newest first, optionally only those of one bot (looking at no more than the last 500).

Open
OID
00df69…e035:12
MatchesJSON details

Inspect func

MatchJSON

func(id int) string

MatchJSON returns a match with every turn, for replays: positions, gold and coins after each turn, both actions and what happened.

Open
OID
00df69…e035:13
MatchJSON details

Inspect func

frameJSON

func(g *game.Game, acts [2]bot.Action, ev game.Events) string
Open
OID
00df69…e035:14
frameJSON details

Inspect func

tournamentJSON

func(t *v2.Tournament, full bool) string
Open
OID
00df69…e035:15
tournamentJSON details

Inspect func

TournamentsJSON

func() string

TournamentsJSON returns every tournament, newest first.

Open
OID
00df69…e035:16
TournamentsJSON details

Inspect func

TournamentJSON

func(id int) string

TournamentJSON returns one tournament with its table and schedule.

Open
OID
00df69…e035:17
TournamentJSON details

Inspect func

SeasonsJSON

func() string

SeasonsJSON returns the top 10 of every finished season, newest first.

Open
OID
00df69…e035:18
SeasonsJSON details

Inspect func

maxBotsPerRealm

untyped bigint

Value

(5 <untyped> bigint)

startRating

untyped bigint

Value

(1200 <untyped> bigint)

Bot

type

Bot is a registered bot.

Value

v2.Bot

botsPerRealm

*v0.Tree

// realm path -> int

Open
OID
00df69…e035:23
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
00df69…e035:25
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
00df69…e035:27
RegisterStrategy details

Inspect func

register

func(name string, b *v2.Bot)
Open
OID
00df69…e035:28
register details

Inspect func

reserveRealmSlot

func(realmPath string)

reserveRealmSlot counts one more bot for realmPath, up to maxBotsPerRealm.

Open
OID
00df69…e035:29
reserveRealmSlot details

Inspect func

currentOrigin

func() .uverse.address
Open
OID
00df69…e035:30
currentOrigin details

Inspect func

validName

func(name string) string
Open
OID
00df69…e035:31
validName details

Inspect func

mustBot

func(name string) *v2.Bot
Open
OID
00df69…e035:32
mustBot details

Inspect func

BotInfo

type

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

Value

v2.BotInfo

GetBot

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

GetBot returns public information about a bot.

Open
OID
00df69…e035:33
GetBot details

Inspect func

BotCount

func() int

BotCount is the number of registered bots.

Open
OID
00df69…e035:34
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)

codecV2

untyped string

Value

"2"

decode

func(id int, s string) *v2.Match
Open
OID
00df69…e035:41
decode details

Inspect func

record

func(id int) (string, bool)

record returns the stored string for match id.

Open
OID
00df69…e035:44
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
00df69…e035:45
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

v2.Status

Pending

v2.Status

// challenged, not played yet

Value

<zero>

Stepping

v2.Status

// being played one move per transaction

Value

<zero>

Finished

v2.Status

Value

<zero>

Match

type

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

Value

v2.Match

matches

*v0.Tree

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

Open
OID
00df69…e035:47
matches details

Inspect pointer

lastID

int

Value

14

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
00df69…e035:50
claimRatedSlot details

Inspect func

emit

func(typ string, attrs []string)
Open
OID
00df69…e035:54
emit details

Inspect func

mustMatch

func(id int) *v2.Match
Open
OID
00df69…e035:55
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
00df69…e035:56
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
00df69…e035:57
Challenge details

Inspect func

newMatch

func(a string, b string) *v2.Match
Open
OID
00df69…e035:58
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
00df69…e035:59
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
00df69…e035:60
Fight details

Inspect func

StartStepMode

func(id int)

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

Open
OID
00df69…e035:61
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
00df69…e035:62
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
00df69…e035:63
ClaimForfeit details

Inspect func

MatchSummary

func(id int) string

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

Open
OID
00df69…e035:64
MatchSummary details

Inspect func

MatchCount

func() int

MatchCount is the number of matches ever created.

Open
OID
00df69…e035:65
MatchCount details

Inspect func

maxDescription

untyped bigint

Value

(200 <untyped> bigint)

mustOwn

func(name string) *v2.Bot
Open
OID
00df69…e035:66
mustOwn details

Inspect func

cleanText

func(s string) string

cleanText keeps a description on one line and drops characters that would turn it into markdown links, images, tables or HTML on the bot's page.

Open
OID
00df69…e035:68
cleanText details

Inspect func

SetDescription

func(name string, text string)

SetDescription sets the one-line description shown on the bot's page.

Open
OID
00df69…e035:69
SetDescription details

Inspect func

Retire

func(name string)

Retire takes a bot off the leaderboard and stops new challenges against it. Its history stays. Matches already created can still be finished.

Open
OID
00df69…e035:70
Retire details

Inspect func

Unretire

func(name string)

Unretire brings a retired bot back.

Open
OID
00df69…e035:71
Unretire details

Inspect func

UpgradeBot

func(name string, b bot.Bot)

UpgradeBot points an existing bot at new code, keeping its name, rating and record. Call it from the new bot realm's init, sent by the bot's owner: func init(cur realm) { arena.UpgradeBot(cross(cur), "my-bot", &myBotV2{}) }

Open
OID
00df69…e035:72
UpgradeBot details

Inspect func

UpgradeStrategy

func(name string, s bot.Strategy)

UpgradeStrategy is UpgradeBot for a bot written as a plain function.

Open
OID
00df69…e035:73
UpgradeStrategy details

Inspect func

upgrade

func(name string, impl bot.Bot, fn bot.Strategy)
Open
OID
00df69…e035:74
upgrade details

Inspect func

appendHistory

func(h string, realmPath string) string

appendHistory adds a realm to a bot's "realm@block," history.

Open
OID
00df69…e035:75
appendHistory 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
00df69…e035:76
expected details

Inspect func

rate

func(a *v2.Bot, b *v2.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
00df69…e035:78
rate details

Inspect func

self

string

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

Value

"/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2"

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 "tournaments" all tournaments "tournament/<id>" a tournament's table, schedule and actions "seasons" champions of past seasons

Open
OID
00df69…e035:83
Render details

Inspect func

better

func(a *v2.Bot, b *v2.Bot) bool
Open
OID
00df69…e035:89
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
00df69…e035:91
writeRecent details

Inspect func

renderBot

func(name string) string
Open
OID
00df69…e035:92
renderBot details

Inspect func

renderMatch

func(m *v2.Match, turn int) string
Open
OID
00df69…e035:93
renderMatch details

Inspect func

writeActions

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

writeActions shows the buttons that move an unfinished match along.

Open
OID
00df69…e035:94
writeActions details

Inspect func

writeMoments

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

writeMoments lists the turns where coins changed hands.

Open
OID
00df69…e035:95
writeMoments details

Inspect func

eventNote

func(ev game.Events, side int) string
Open
OID
00df69…e035:97
eventNote details

Inspect func

drawBoard

func(pos [2]bot.Pos, coins []bot.Pos) string
Open
OID
00df69…e035:98
drawBoard details

Inspect func

blockSeconds

untyped bigdec

blockSeconds is Onyx's approximate block time, for "about N days" hints.

Value

(3.6 <untyped> bigdec)

seasonLine

func() string

seasonLine describes the current season's timing.

Open
OID
00df69…e035:99
seasonLine details

Inspect func

activeLeaderboard

func() []*v2.Bot

activeLeaderboard is the leaderboard without retired bots.

Open
OID
00df69…e035:101
activeLeaderboard details

Inspect func

writeTournamentList

func(sb *strings.Builder, limit int)
Open
OID
00df69…e035:102
writeTournamentList details

Inspect func

renderTournaments

func() string
Open
OID
00df69…e035:103
renderTournaments details

Inspect func

renderTournament

func(t *v2.Tournament) string
Open
OID
00df69…e035:104
renderTournament details

Inspect func

renderSeasons

func() string
Open
OID
00df69…e035:105
renderSeasons details

Inspect func

SeasonLength

untyped bigint

SeasonLength is about 30 days at Onyx's ~3.6 s blocks.

Value

(720000 <untyped> bigint)

season

int

Value

1

seasonStart

int64

// set on the first activity

Value

1455149

pastSeasons

*v0.Tree

// padded season number -> "name:rating:w-l-d," top 10

Open
OID
00df69…e035:109
pastSeasons details

Inspect pointer

seasonTop

int

Value

10

SeasonInfo

func() (number int, endsAt int64)

SeasonInfo reports the current season number and the block it ends at.

Open
OID
00df69…e035:112
SeasonInfo details

Inspect func

rollSeason

func()

rollSeason closes the current season if it is over. Call it before any state change that touches ratings.

Open
OID
00df69…e035:114
rollSeason details

Inspect func

SeasonStanding

type

SeasonStanding is one line of a finished season's top 10.

Value

v2.SeasonStanding

PastSeason

func(number int) []v2.SeasonStanding

PastSeason returns the top 10 of a finished season.

Open
OID
00df69…e035:116
PastSeason details

Inspect func

minEntrants

untyped bigint

Value

(2 <untyped> bigint)

maxEntrants

untyped bigint

Value

(8 <untyped> bigint)

TournamentStatus

type

TournamentStatus of a tournament.

Value

v2.TournamentStatus

Open

v2.TournamentStatus

Value

<zero>

Running

v2.TournamentStatus

Value

<zero>

Done

v2.TournamentStatus

Value

<zero>

Tournament

type

Tournament is a round-robin between up to maxEntrants bots.

Value

v2.Tournament

tournaments

*v0.Tree

// padded id -> \*Tournament

Open
OID
00df69…e035:118
tournaments details

Inspect pointer

lastTID

int

Value

1

mustTournament

func(id int) *v2.Tournament
Open
OID
00df69…e035:121
mustTournament details

Inspect func

CreateTournament

func(name string, capacity int) int

CreateTournament opens a round-robin for up to capacity bots (2 to 8).

Open
OID
00df69…e035:123
CreateTournament details

Inspect func

JoinTournament

func(id int, botName string)

JoinTournament enters a bot you own into an open tournament.

Open
OID
00df69…e035:124
JoinTournament details

Inspect func

StartTournament

func(id int)

StartTournament closes entries and fixes the schedule. Only the creator can start it.

Open
OID
00df69…e035:125
StartTournament details

Inspect func

roundRobin

func(entrants []string) []string

roundRobin schedules every pair once, round by round (circle method), so no bot plays twice in a row more than it must. Sides alternate by round.

Open
OID
00df69…e035:126
roundRobin details

Inspect func

NextTournamentMatch

func(id int) int

NextTournamentMatch creates the tournament's next match and returns its id. Play it with Play, or step mode if a bot keeps it from finishing. Anyone may call it.

Open
OID
00df69…e035:127
NextTournamentMatch details

Inspect func

PlayTournament

func(id int) string

PlayTournament creates the next match and plays it in one transaction. If a bot makes it fail, nothing is recorded: use NextTournamentMatch, then Play or step mode. Anyone may call it.

Open
OID
00df69…e035:128
PlayTournament details

Inspect func

CloseTournament

func(id int)

CloseTournament marks a tournament finished once all its matches are settled (matches finished through step mode don't do it themselves). Anyone may call it.

Open
OID
00df69…e035:129
CloseTournament details

Inspect func

Standing

type

Standing is one bot's line in a tournament table.

Value

v2.Standing

aheadOf

func(a v2.Standing, b v2.Standing) bool
Open
OID
00df69…e035:130
aheadOf details

Inspect func

TournamentCount

func() int

TournamentCount is the number of tournaments ever created.

Open
OID
00df69…e035:131
TournamentCount details

Inspect func

TournamentNext

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

TournamentNext returns the next pairing still to be created, if any.

Open
OID
00df69…e035:132
TournamentNext details

Inspect func
jsonString : func(s string) string Inspect
jsonObj : type =v2.jsonObj
jsonArray : func(items []string) string Inspect
posJSON : func(p bot.Pos) string Inspect
botJSON : func(b *v2.Bot) string Inspect
ArenaJSON : func() string Inspect
BotsJSON : func() string Inspect
BotJSON : func(name string) string Inspect
matchSummaryJSON : func(m *v2.Match) string Inspect
MatchesJSON : func(botName string, limit int) string Inspect
MatchJSON : func(id int) string Inspect
frameJSON : func(g *game.Game, acts [2]bot.Action, ev game.Events) string Inspect
tournamentJSON : func(t *v2.Tournament, full bool) string Inspect
TournamentsJSON : func() string Inspect
TournamentJSON : func(id int) string Inspect
SeasonsJSON : func() string Inspect
maxBotsPerRealm : untyped bigint =(5 <untyped> bigint)
startRating : untyped bigint =(1200 <untyped> bigint)
Bot : type =v2.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 *v2.Bot) Inspect
reserveRealmSlot : func(realmPath string) Inspect
currentOrigin : func() .uverse.address Inspect
validName : func(name string) string Inspect
mustBot : func(name string) *v2.Bot Inspect
BotInfo : type =v2.BotInfo
GetBot : func(name string) (v2.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)
codecV2 : untyped string ="2"
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) *v2.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 =v2.Status
Pending : v2.Status =<zero>
Stepping : v2.Status =<zero>
Finished : v2.Status =<zero>
Match : type =v2.Match
matches : *v0.Tree Inspect
lastID : int =14
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) *v2.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) *v2.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
maxDescription : untyped bigint =(200 <untyped> bigint)
mustOwn : func(name string) *v2.Bot Inspect
cleanText : func(s string) string Inspect
SetDescription : func(name string, text string) Inspect
Retire : func(name string) Inspect
Unretire : func(name string) Inspect
UpgradeBot : func(name string, b bot.Bot) Inspect
UpgradeStrategy : func(name string, s bot.Strategy) Inspect
upgrade : func(name string, impl bot.Bot, fn bot.Strategy) Inspect
appendHistory : func(h string, realmPath string) string Inspect
kFactor : untyped bigint =(32 <untyped> bigint)
expected : func(ra int, rb int) int Inspect
rate : func(a *v2.Bot, b *v2.Bot, winner int) int Inspect
self : string ="/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2"
tx : v0.Realm =<gnolang.StringValue>
init.85 : func() Inspect
Render : func(path string) string Inspect
renderHome : func() string Inspect
leaderboard : func() []*v2.Bot Inspect
better : func(a *v2.Bot, b *v2.Bot) bool Inspect
writeRecent : func(sb *strings.Builder, botName string, limit int) Inspect
renderBot : func(name string) string Inspect
renderMatch : func(m *v2.Match, turn int) string Inspect
writeActions : func(sb *strings.Builder, m *v2.Match) Inspect
writeMoments : func(sb *strings.Builder, m *v2.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
blockSeconds : untyped bigdec =(3.6 <untyped> bigdec)
seasonLine : func() string Inspect
activeLeaderboard : func() []*v2.Bot Inspect
writeTournamentList : func(sb *strings.Builder, limit int) Inspect
renderTournaments : func() string Inspect
renderTournament : func(t *v2.Tournament) string Inspect
renderSeasons : func() string Inspect
SeasonLength : untyped bigint =(720000 <untyped> bigint)
season : int =1
seasonStart : int64 =1455149
pastSeasons : *v0.Tree Inspect
seasonTop : int =10
SeasonInfo : func() (number int, endsAt int64) Inspect
rollSeason : func() Inspect
closeSeason : func() Inspect
SeasonStanding : type =v2.SeasonStanding
PastSeason : func(number int) []v2.SeasonStanding Inspect
minEntrants : untyped bigint =(2 <untyped> bigint)
maxEntrants : untyped bigint =(8 <untyped> bigint)
TournamentStatus : type =v2.TournamentStatus
Open : v2.TournamentStatus =<zero>
Running : v2.TournamentStatus =<zero>
Done : v2.TournamentStatus =<zero>
Tournament : type =v2.Tournament
tournaments : *v0.Tree Inspect
lastTID : int =1
mustTournament : func(id int) *v2.Tournament Inspect
CreateTournament : func(name string, capacity int) int Inspect
JoinTournament : func(id int, botName string) Inspect
StartTournament : func(id int) Inspect
roundRobin : func(entrants []string) []string Inspect
NextTournamentMatch : func(id int) int Inspect
PlayTournament : func(id int) string Inspect
CloseTournament : func(id int) Inspect
Standing : type =v2.Standing
aheadOf : func(a v2.Standing, b v2.Standing) bool Inspect
TournamentCount : func() int Inspect
TournamentNext : func(id int) (a string, b string, ok bool) Inspect