Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source realm

Package bullscows is a shared on-chain Bulls & Cows puzzle: one secret 4-digit code (distinct digits) per round, gues...

Readme View source

Bulls & Cows

⚠️ Experimental — generated with no human supervision. This realm was produced automatically by an MCP-driven agent to exercise the gno MCP server and tooling, and to generate test content for gno compilers, linters and formatters. Not audited. Not for production. Full context & folder README: r/moul/x/daily


A shared on-chain Bulls & Cows puzzle (the classic ancestor of Mastermind and Wordle-for-digits). One secret 4-digit code with no repeated digits is live at a time; anyone can call Guess with a candidate code and gets back bulls (right digit, right position) and cows (right digit, wrong position). First caller to land 4 bulls cracks the round, lands on the leaderboard, and a fresh secret is drawn immediately so the next round starts at once.

Realm: gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/bullscows

Example calls

Guess("1972")   -> "1972 -> 1 bulls, 2 cows"
Guess("7192")   -> "*** SOLVED *** 7192 was it — round 3 cracked in 5 guesses. New round 4 has begun, good luck!"
GiveUp()        -> "round 4's code was 4082 — round 5 is live now."

Render("") shows the current round, attempts so far, the last 10 guesses with their bulls/cows, and the top-5 fastest-solve leaderboard.

The secret is generated deterministically from the on-chain block height and the round counter via a small LCG (newSecret/nextRand in bullscows.gno) — no external randomness needed, and nobody can precompute the next code before its round actually starts.

Toolchain status

Verified locally with gno test -v . and gno lint . against a gno.land/gnolang/gno master checkout used as GNOROOT (the default installed gno binary had a stale/ missing GNOROOT, so GNOROOT=<path-to-gnolang/gno> gno test . was used instead). All 7 tests pass, lint is clean. This exercises current sapphire (gno 0.9) stdlib paths (chain/runtime, no std package) and the cur realm / cross(cur) crossing convention.


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.

Overview

Package bullscows is a shared on-chain Bulls & Cows puzzle: one secret 4-digit code (distinct digits) per round, guessed cooperatively/competitively by anyone who calls Guess. Bulls = right digit, right spot. Cows = right digit, wrong spot. Whoever hits 4 bulls wins the round and a leaderboard entry; a fresh secret is drawn immediately after.

Functions 3

func GiveUp

crossing Action
1func GiveUp(cur realm) string
source

GiveUp reveals the current secret and starts a fresh round without awarding a leaderboard record.

func Guess

crossing Action
1func Guess(cur realm, guess string) string
source

Guess submits a 4-distinct-digit code against the current round's secret. Returns the bulls/cows feedback, or "solved!" text when it's a win.

Imports 3

  • chain/runtime stdlib
  • strconv stdlib
  • strings stdlib

Source Files 3