N
untyped bigintValue
(4 <untyped> bigint)
DIR_UP
untyped bigintValue
(0 <untyped> bigint)
DIR_RIGHT
untyped bigintValue
(1 <untyped> bigint)
DIR_DOWN
untyped bigintValue
(2 <untyped> bigint)
DIR_LEFT
untyped bigintValue
(3 <untyped> bigint)
Board
typeBoard is one 4x4 game. Zero is an empty cell.
Value
v0.Board
NewBoard
func() v0.BoardNewBoard returns a fresh board with the two starting tiles.
- OID
- 0b3298…0ebc:3
NewBoard details
NewBoardSeeded
func(seed int) v0.BoardNewBoardSeeded returns a fresh board whose two starting tiles are placed from seed, so every game starts differently but reproducibly.
- OID
- 0b3298…0ebc:5
NewBoardSeeded details
slideRowLeft
func(row [4]int) (out [4]int, gained int)slideRowLeft collapses a row to the left, merging equal neighbours once. Returns the new row and the points added by the merges.
- OID
- 0b3298…0ebc:6
slideRowLeft details
applyDir
func(b [4][4]int, dir int) (nb [4][4]int, gained int, moved bool)applyDir runs a full-board move. It returns the new board, the gained score and whether the board changed at all.
- OID
- 0b3298…0ebc:7
applyDir details
HasMove
func(b [4][4]int) boolHasMove reports whether any move is still possible.
- OID
- 0b3298…0ebc:8
HasMove details
lcg
func(seed int) intlcg advances a deterministic PRNG from a seed; value in \[0,1024).
- OID
- 0b3298…0ebc:9
lcg details
Itoa
func(x int) stringItoa is a dependency-free int->string for realm Render.
- OID
- 0b3298…0ebc:10
Itoa details
realmPath
untyped stringrealmPath is the gnoweb path of this realm, used for in-page links.
Value
"/r/g15crxnxd79syggtha6ymfhy8m8a4ytqel58cwkg/tavern2048/v0"
MaxPlayMoves
untyped bigintMaxPlayMoves caps how many moves a single Play transaction may apply.
Value
(64 <untyped> bigint)
TopN
untyped bigintTopN is how many players the leaderboard shows.
Value
(10 <untyped> bigint)
Game
typeGame is one player's current game.
Value
v0.Game
games
*v0.Tree// player address -> \*Game (current game)
- OID
- 0b3298…0ebc:12
games details
best
*v0.Tree// player address -> int (best score ever)
- OID
- 0b3298…0ebc:15
best details
totalGames
intValue
1
totalMoves
intValue
35
NewGame
func() stringNewGame starts a fresh board for the signer, replacing any current game. The best score ever reached is kept for the leaderboard.
- OID
- 0b3298…0ebc:19
NewGame details
Move
func(dir string) stringMove applies a direction (0=up,1=right,2=down,3=left) to the board, awards merge points and spawns one new tile from the block-height seed. spawnSeed makes the spawn reproducible: pass blockheight() on chain. Returns the updated board and a human-readable outcome.
- OID
- 0b3298…0ebc:21
Move details
Play
func(moves string) stringPlay applies a sequence of moves in a single transaction, e.g. "lldrul" (u=up, d=down, l=left, r=right; spaces and commas are ignored). It stops early when the game is over. At most MaxPlayMoves moves per call.
- OID
- 0b3298…0ebc:22
Play details
ScoreOf
func(player .uverse.address) intScoreOf returns the current score of a player (0 if no game).
- OID
- 0b3298…0ebc:23
ScoreOf details
BestOf
func(player .uverse.address) intBestOf returns the best score a player ever reached.
- OID
- 0b3298…0ebc:24
BestOf details
mustGame
func(player string) *v0.Game- OID
- 0b3298…0ebc:25
mustGame details
step
func(player string, g *v0.Game, d int) (bool, string)step applies one direction and records score, best and events.
- OID
- 0b3298…0ebc:26
step details
BestOfKey
func(player string) intBestOfKey is BestOf for a raw address string.
- OID
- 0b3298…0ebc:27
BestOfKey details
parseDir
func(s string) (int, bool)- OID
- 0b3298…0ebc:28
parseDir details
dirName
func(d int) string- OID
- 0b3298…0ebc:29
dirName details
addrSeed
func(a string) intaddrSeed folds an address into a small positive salt.
- OID
- 0b3298…0ebc:30
addrSeed details
maxTile
func(b v0.Board) int- OID
- 0b3298…0ebc:31
maxTile details
shortAddr
func(a string) string- OID
- 0b3298…0ebc:32
shortAddr details
Render
func(path string) stringRender serves the tavern home (path "") or a player's board (path = g1...).
- OID
- 0b3298…0ebc:33
Render details
renderHome
func() string- OID
- 0b3298…0ebc:34
renderHome details
entry
typeValue
v0.entry
renderLeaderboard
func() string- OID
- 0b3298…0ebc:35
renderLeaderboard details
renderPlayer
func(player string) string- OID
- 0b3298…0ebc:36
renderPlayer details
tileColors
func(v int) (bg string, fg string)- OID
- 0b3298…0ebc:37
tileColors details
boardSVG
func(b v0.Board) stringboardSVG draws the board as an inline SVG image (data URI) for gnoweb.
- OID
- 0b3298…0ebc:38