v0 source pure
Package rps is the rock-paper-scissors move: parsing it, naming it, and deciding a throw. It holds no state, so every...
View source
gno.land/p/moul/x/daily/rps/v0
The rock-paper-scissors move: Parse, Move.String, Beats. Stateless, so
every realm that plays the game agrees on what "r" means and who wins.
1import "gno.land/p/moul/x/daily/rps/v0"
2
3m, ok := rps.Parse(" Paper ") // rps.Paper, true; "p" works too
4m.String() // "paper"
5rps.Beats(rps.Paper, rps.Rock) // 1: the first move wins (0 tie, 2 the second wins)
Move is ordered rock, paper, scissors so that (a - b) mod 3 is the verdict.
Consumers: rps,
rpsmatch,
rpsoracle,
rpsduel, each of
which carried its own copy of this logic before.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.
Package rps is the rock-paper-scissors move: parsing it, naming it, and deciding a throw. It holds no state, so every realm that plays the game agrees on what "r" means and who wins.
Imported by r/moul/x/daily/rps(/r/moul/x/daily/rps/v1), r/moul/x/daily/rpsmatch(/r/moul/x/daily/rpsmatch/v1), r/moul/x/daily/rpsoracle(/r/moul/x/daily/rpsoracle/v1) and r/moul/x/daily/rpsduel(/r/moul/x/daily/rpsduel/v1).
1
2
1
type Move
identMove is one of rock, paper, or scissors, ordered so that (winner - loser + 3) % 3 == 1 for every winning pair.