// PKGPATH: gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/z3 // Alice picks her saved bot as fallback and misses every round: her side is // played by her profile bot, exactly as brawl.ProfileBot plays it. package z3 import ( "strconv" "strings" "testing" rules "gno.land/p/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/brawl/v2" "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/mybots/v2" "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/rooms/v2" ) var ( alice = address("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm") bob = address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") ) func as(cur realm, who address) { testing.SetRealm(testing.NewUserRealm(who)) } func main(cur realm) { const prof = "c3t3i0f7j2r8a9b1s7d2k1" as(cur, alice) mybots.Save(cross(cur), "Alice Bot", prof) id := rooms.Create(cross(cur), "Alice", rules.Hunter, rooms.MyBot, 4, 60, 30) as(cur, bob) rooms.Join(cross(cur), id, "Bob", rules.Brawler, rules.Hard) for round := 0; round < 4; round++ { testing.SkipHeights(30) rooms.Advance(cross(cur), id) } in := rooms.InputsJSON(id) seed, _ := strconv.Atoi(in[strings.Index(in, `"seed":`)+7 : strings.Index(in, `,"ticks"`)]) a := in[strings.Index(in, `"a":"`)+5:] a = a[:600] // the same match, played straight through by the two bots g := rules.NewLength(uint32(seed), rules.Hunter, rules.Brawler, 600) pa := rules.NewProfileBot(rules.MustProfile(prof), uint32(seed)+1) pb := rules.NewBot(rules.Hard, uint32(seed)+2) same := true for t := 0; t < 600; t++ { m0, a0 := pa.Act(g, 0) m1, a1 := pb.Act(g, 1) if rules.Encode(m0, a0) != a[t] { same = false } g.Step(m0, a0, m1, a1) } println("profile bot played alice's side:", same) st := rooms.StateJSON(id) println(st[strings.Index(st, `"gold"`):]) println("straight:", g.F[0].Gold, g.F[1].Gold) } // Output: // profile bot played alice's side: true // "gold":[12,30]} // straight: 12 30