z2_agent_logs_filetest.gno
3.10 Kb · 45 lines
1// PKGPATH: gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/z2
2
3// Real logs from two agents that played through the relay (agents/live): the
4// hash chain the agent printed is the one the realm computes, and the chain's
5// rules replay both logs to the score the agents reached themselves.
6package z2
7
8import (
9 rules "gno.land/p/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/brawl/v4"
10 "gno.land/r/g1ftppd2jpfx0p8cy08th4u9whwvqcpychhlad28/live/v1"
11)
12
13const (
14 logA = "X%&&&&&&&&%%%%$$$$$$%%%%^;222222224#--,,,-----..########$$$$%%W$%%$$%%%%%%6%##((((9(00))((^*(())((((%%%%%%++++++++++_+**11111111111122110000//00c/++++''&&''''++++&&&&&&Y&------------00/@00////(9a-((((((A022(())B1((00$$W$----))))++))))))9(--,,X%A0##))00A0%%&&//@///00d0&&+<;;;;;;;*##1111%%%%X%*;++$$//(9--11222C##****]://$$$$#4((//111B((....c/'822&&'''8##''''/@..--Z'*;??>>?.%%&&''''''''--a-1122....................@/Z'&&###4_<CCfC_+a-a-((9J..2222(((())))----a-''''''####))))))++*;**Y&##22////####....))))))])//6%%%%%----++++**0A==_<c@V#++%%%6$$$$))##4###--,,dAQ///00++<<<<;;//R0----b.**#4######(911++"
15 logB = "---...---.......,,_++,,,<M+333311000333000000000111######''''33'''Y&&,,,33D***(((1B1***((((((((('''(((,,,,,,***---$$$V##//////////////////####...---......///...$$$%%%333%%%%%%X%%%%%000&77222///9((+++(((9((###''8333...'8'---[(((((((((((0A0///&&&;**111**;333###.?.###///...b?..P.+++<++)))$$$###2C2.....'7&&111)):$$$###->-`,,%%%;**...$$5&&&***///?..$$$$/@&&&***'8'333///Z8'***000&&&*********)))$$$//////333/////////&&7]))...)):####E##4#...&&&<++'''(((((('''///////////////a---######4###//////...///...&&&(((((('''5$$)))///c//333&&7$$$222#4#%%%###->-111%%%6%%+++U3D222///a>-,,,000>--...---,,=###222&7&---"
16)
17
18var anchorsA = []string{"6467079f9e3a44662c2b7929010905fc233c29402d473d662a09f8423fa6951d", "172ced2d89801b0a80d5f433e92c47787ed213e87a224448905ebce529060f81", "12b5dcb45d5bab15d6b070a060d7d0c854deb1baea2c88203195950976480ca3", "e5e225ea3ba0a15e9b11aa53c41285e24fd2a8ac557370cedc79c0ef345aedbf", "9e02ab76d7fb1dfefeab91ddca05c0fda1d5888753c6b7331b0836a6e7aaee97", "64f6830f9228cac824cdb49a21fa0651dd8925bbcbc37634a50b3129e00fe809"}
19var anchorsB = []string{"fd6472b773c0581e731675caea2763611822a5772e8c6c109a71392a02d7a6e0", "91f64b9104410bcce89f93f11eddf6ce64acb5c7b9ccfddffe78091999455a3f", "a4ae0111191974edadf501c6cc05f7d7a2a1f865afc11e518424c120bdf5176b", "d5f076956fd576140b9c6ebb854f12f580a1fa592c6bfbc6663d806c3a1e25ec", "c5571bf1939e0e71b0f03a7e12e39c3cf3c2628565b29cc1e13a0b208c5d9488", "c931906f2b0fd4c6dddf034a74e0c17b690b0b705f5ba74469bcb841d0a24e2d"}
20
21func main(cur realm) {
22 for _, c := range []struct {
23 log string
24 a []string
25 }{{logA, anchorsA}, {logB, anchorsB}} {
26 prev, ok := "", true
27 for k := 0; k < 6; k++ {
28 prev = live.AnchorHash(prev, c.log[k*100:(k+1)*100])
29 ok = ok && prev == c.a[k]
30 }
31 println("anchors match:", ok)
32 }
33 g := rules.NewLength(7, rules.Reader, rules.Hunter, 600)
34 for i := 0; i < 600 && !g.Over(); i++ {
35 m0, a0, _ := rules.Decode(logA[i])
36 m1, a1, _ := rules.Decode(logB[i])
37 g.Step(m0, a0, m1, a1)
38 }
39 println("replay:", g.F[0].Gold, g.F[1].Gold)
40}
41
42// Output:
43// anchors match: true
44// anchors match: true
45// replay: 31 35