round
typeround holds the mutable state of the active game round.
Value
v0.round
winRecord
typewinRecord is one leaderboard entry.
Value
v0.winRecord
current
*v0.round- OID
- 03d1c7…23a1:21
current details
attempts
*v0.Tree// addr(string) -> \*int
- OID
- 03d1c7…23a1:5
attempts details
leaderboard
[]v0.winRecordValue
<zero>
init.5
func()- OID
- 03d1c7…23a1:8
init.5 details
newRound
func(number int, height int64) *v0.roundnewRound builds a fresh round whose target derives deterministically from the start height. Gno has no runtime RNG, so height is the only entropy.
- OID
- 03d1c7…23a1:10
newRound details
targetFromHeight
func(h int64) inttargetFromHeight 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.
- OID
- 03d1c7…23a1:11
targetFromHeight details
Guess
func(n int) stringGuess 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).
- OID
- 03d1c7…23a1:12
Guess details
NewRound
func() stringNewRound resets the game with a fresh target when the current round is solved. Panics if the current round is still open. Crossing function.
- OID
- 03d1c7…23a1:13
NewRound details
incAttempt
func(addr string)incAttempt bumps the caller's attempt counter for the current round.
- OID
- 03d1c7…23a1:14
incAttempt details
attemptsOf
func(addr string) intattemptsOf returns how many guesses addr has made this round.
- OID
- 03d1c7…23a1:15
attemptsOf details
totalAttempts
func() inttotalAttempts sums all attempts made in the current round.
- OID
- 03d1c7…23a1:16
totalAttempts details
Render
func(path string) stringRender produces the gnoweb Markdown view of the current game state.
- OID
- 03d1c7…23a1:17
Render details
renderLeaderboard
func() stringrenderLeaderboard formats winners ranked by fewest guesses (ties: earlier round first). Sorted on a copy so state is untouched.
- OID
- 03d1c7…23a1:18
renderLeaderboard details
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.
- OID
- 03d1c7…23a1:19
sortByFewestTries details
less
func(a v0.winRecord, b v0.winRecord) bool- OID
- 03d1c7…23a1:20