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 state

Back to all declarations

round

type

round holds the mutable state of the active game round.

Value

v0.round

winRecord

type

winRecord is one leaderboard entry.

Value

v0.winRecord

leaderboard

[]v0.winRecord

Value

<zero>

newRound

func(number int, height int64) *v0.round

newRound builds a fresh round whose target derives deterministically from the start height. Gno has no runtime RNG, so height is the only entropy.

Open
OID
03d1c7…23a1:10
newRound details

Inspect func

targetFromHeight

func(h int64) int

targetFromHeight maps a block height to a hidden number in 1..100. Deterministic and cheap: a small integer mix so consecutive rounds don't land on obviously adjacent targets.

Open
OID
03d1c7…23a1:11
targetFromHeight details

Inspect func

Guess

func(n int) string

Guess submits a guess for the current round. It records the caller's attempt count and returns "higher", "lower" or "correct". Crossing function: caller invokes as Guess(cross(cur), n).

Open
OID
03d1c7…23a1:12
Guess details

Inspect func

NewRound

func() string

NewRound resets the game with a fresh target when the current round is solved. Panics if the current round is still open. Crossing function.

Open
OID
03d1c7…23a1:13
NewRound details

Inspect func

incAttempt

func(addr string)

incAttempt bumps the caller's attempt counter for the current round.

Open
OID
03d1c7…23a1:14
incAttempt details

Inspect func

attemptsOf

func(addr string) int

attemptsOf returns how many guesses addr has made this round.

Open
OID
03d1c7…23a1:15
attemptsOf details

Inspect func

totalAttempts

func() int

totalAttempts sums all attempts made in the current round.

Open
OID
03d1c7…23a1:16
totalAttempts details

Inspect func

Render

func(path string) string

Render produces the gnoweb Markdown view of the current game state.

Open
OID
03d1c7…23a1:17
Render details

Inspect func

renderLeaderboard

func() string

renderLeaderboard formats winners ranked by fewest guesses (ties: earlier round first). Sorted on a copy so state is untouched.

Open
OID
03d1c7…23a1:18
renderLeaderboard details

Inspect func

sortByFewestTries

func(rs []v0.winRecord)

sortByFewestTries does an in-place insertion sort: fewer tries first, then earlier round first on ties. Small n; insertion sort keeps it deterministic and dependency-free.

Open
OID
03d1c7…23a1:19
sortByFewestTries details

Inspect func

less

func(a v0.winRecord, b v0.winRecord) bool
Open
OID
03d1c7…23a1:20
less details

Inspect func
round : type =v0.round
winRecord : type =v0.winRecord
current : *v0.round Inspect
attempts : *v0.Tree Inspect
leaderboard : []v0.winRecord =<zero>
init.5 : func() Inspect
newRound : func(number int, height int64) *v0.round Inspect
targetFromHeight : func(h int64) int Inspect
Guess : func(n int) string Inspect
NewRound : func() string Inspect
incAttempt : func(addr string) Inspect
attemptsOf : func(addr string) int Inspect
totalAttempts : func() int Inspect
Render : func(path string) string Inspect
renderLeaderboard : func() string Inspect
sortByFewestTries : func(rs []v0.winRecord) Inspect
less : func(a v0.winRecord, b v0.winRecord) bool Inspect