z1_fight_filetest.gno
5.74 Kb · 81 lines
1// PKGPATH: gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/z1
2
3// Starter bots and the realm bot with memory fight each other; results,
4// ratings and pages are recorded.
5package z1
6
7import (
8 "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2"
9 _ "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/reader/v2"
10 _ "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/starter/v2"
11)
12
13func main(cur realm) {
14 println(arena.Fight(cross(cur), "hunter", "brawler"))
15 println(arena.Fight(cross(cur), "reader", "coward"))
16 println(arena.Fight(cross(cur), "brawler", "reader"))
17 println(arena.Fight(cross(cur), "hunter", "brawler")) // new board for the rematch
18 info, _ := arena.GetBot("hunter")
19 println("hunter rating:", info.Rating, "played:", info.Played)
20 println(arena.Render(""))
21}
22
23// Output:
24// #1 hunter 0 - 3 brawler, brawler wins
25// #2 reader 12 - 13 coward, coward wins
26// #3 brawler 0 - 11 reader, reader wins
27// #4 hunter 8 - 2 brawler, hunter wins (friendly)
28// hunter rating: 1184 played: 2
29// # Code Arena
30//
31// Bots are realms. Deploy one, register it, and the chain referees every match by calling each bot's code turn by turn. Every bot's source is public, so you can study a rival before you challenge it.
32//
33// **6 bots** · **4 matches** · **0 tournaments** · [Start a fight](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=Fight&a=&b=)
34//
35// ## Season 1 leaderboard
36//
37// Ends at block 720123 (about 30 days). Ratings reset each season; the top 10 is kept. [Past seasons](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:seasons)
38//
39// | # | Bot | Elo | Season W-L-D | |
40// |---|---|---|---|---|
41// | 1 | [coward](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:bot/coward) | 1216 | 1-0-0 | [code](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/starter/v2$source) · [fight](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=Fight&a=&b=coward) |
42// | 2 | [reader](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:bot/reader) | 1201 | 1-1-0 | [code](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/reader/v2$source) · [fight](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=Fight&a=&b=reader) |
43// | 3 | [realm-crasher](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:bot/realm-crasher) | 1200 | 0-0-0 | [code](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/testbots/crasher$source) · [fight](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=Fight&a=&b=realm-crasher) |
44// | 4 | [trickster](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:bot/trickster) | 1200 | 0-0-0 | [code](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/starter/v2$source) · [fight](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=Fight&a=&b=trickster) |
45// | 5 | [brawler](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:bot/brawler) | 1199 | 1-2-0 | [code](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/starter/v2$source) · [fight](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=Fight&a=&b=brawler) |
46// | 6 | [hunter](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:bot/hunter) | 1184 | 1-1-0 | [code](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/starter/v2$source) · [fight](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=Fight&a=&b=hunter) |
47//
48// ## Tournaments
49//
50// No tournaments yet.
51//
52// [Open a tournament](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=CreateTournament&capacity=8&name=) · [All tournaments](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:tournaments)
53//
54// ## Recent matches
55//
56// - [#4 hunter 8 - 2 brawler, hunter wins (friendly)](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:match/4)
57// - [#3 brawler 0 - 11 reader, reader wins](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:match/3)
58// - [#2 reader 12 - 13 coward, coward wins](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:match/2)
59// - [#1 hunter 0 - 3 brawler, brawler wins](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2:match/1)
60//
61// ## Rules
62//
63// - 9×9 board, 50 turns. Bots start in opposite corners; coins are placed point-symmetrically, so neither corner has an advantage. A new pair of coins appears every 5 turns.
64// - Each turn both bots choose at once: `Up`, `Down`, `Left`, `Right`, `Stay`, `Attack` or `Defend`.
65// - Step on a coin to take it. Bots never share a square: if both step onto the same one, priority alternates each turn.
66// - Next to the enemy, `Attack` steals one coin. But attacking into a `Defend` is parried, and the defender takes a coin from you instead.
67// - Most gold after 50 turns wins. Ratings are Elo-style; a pair of bots plays at most one rated match every 1000 blocks, and rematches in between are friendlies.
68//
69// Each turn a bot sees the board, both scores, and what both bots did last turn, so a bot can learn its opponent's habits.
70//
71// ## Build a bot
72//
73// 1. Import [`gno.land/p/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bot`](/p/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bot) and write a `Move(bot.State) bot.Action` method (a realm bot can keep memory) or a plain function.
74// 2. Register it from your realm's `init`: `arena.RegisterBot(cross(cur), "my-bot", &myBot{})`.
75// 3. [Fight](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/arena/v2$help&func=Fight&a=my-bot&b=) anyone on the leaderboard.
76//
77// Starter bots to read and beat: [strategies](/p/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/strategies) · [reader](/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/bots/reader/v2), a realm bot that learns each opponent's habits.
78//
79// ## No escaping a loss
80//
81// A crash inside a realm cancels the whole transaction, so a bot could crash on purpose to cancel a match it is losing. It doesn't work here: the match switches to step mode, one move per transaction, and a bot that can't make its move by the deadline loses by forfeit.