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.

z3_realm_crash_step_filetest.gno

2.64 Kb · 74 lines
 1// PKGPATH: gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/z3
 2
 3// Step mode pins the crash on the realm bot that causes it: its move can't be
 4// submitted, the deadline passes, and anyone can claim the forfeit.
 5package z3
 6
 7import (
 8	"testing"
 9
10	"gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2"
11	_ "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/starter/v2"
12	_ "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/testbots/crasher"
13)
14
15func main(cur realm) {
16	id := arena.Challenge(cross(cur), "brawler", "realm-crasher")
17	arena.StartStepMode(cross(cur), id)
18	for i := 0; i < 200; i++ {
19		r := revive(func() { arena.SubmitMove(cross(cur), id) })
20		if r != nil {
21			println("move failed:", r)
22			break
23		}
24	}
25	println(arena.MatchSummary(id))
26
27	r := revive(func() { arena.ClaimForfeit(cross(cur), id) })
28	println("early claim:", r)
29
30	testing.SkipHeights(arena.MoveTimeout + 1)
31	println(arena.ClaimForfeit(cross(cur), id))
32	info, _ := arena.GetBot("realm-crasher")
33	println("losses:", info.Losses, "forfeits:", info.Forfeits)
34	println(arena.Render("match/1"))
35}
36
37// Output:
38// move failed: realm bot crashes on purpose
39// #1 brawler 2 - 3 realm-crasher (step mode, turn 9 of 50)
40// early claim: realm-crasher still has until block 223 to move
41// #1 brawler wins by forfeit: realm-crasher missed its move deadline on turn 10
42// losses: 1 forfeits: 1
43// # Match #1: brawler vs realm-crasher
44//
45// **#1 brawler wins by forfeit: realm-crasher missed its move deadline on turn 10**
46//
47// Rating change: brawler +16, realm-crasher -16
48//
49// ## After turn 9 of 50
50//
51// **A** = brawler, 2 gold · **B** = realm-crasher, 3 gold · **$** = coin
52//
53// ```
54// · · $ · · · · · ·
55// · · · · · · · · ·
56// · · · · · · · · ·
57// · · · · A $ $ · ·
58// · · · · B · · · ·
59// · · $ $ · · · · ·
60// · · · · · · · · ·
61// · · · · · · · · ·
62// · · · · · · $ · ·
63// ```
64//
65// [« start](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:match/1/0) · [‹ prev](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:match/1/8)
66//
67// Turn 9: brawler **attack** (stole a coin), realm-crasher **attack** (stole a coin)
68//
69// ## Key moments
70//
71// - [Turn 9](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:match/1/9): brawler stole a coin from realm-crasher
72// - [Turn 9](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:match/1/9): realm-crasher stole a coin from brawler
73//
74// Bots: [brawler](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:bot/brawler) · [realm-crasher](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:bot/realm-crasher) · [Back to the arena](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2)