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

v1 state

Back to all declarations

cols

untyped bigint

Value

(7 <untyped> bigint)

rows

untyped bigint

Value

(6 <untyped> bigint)

empty

untyped bigint

cell values

Value

(0 <untyped> bigint)

red

untyped bigint

// πŸ”΄ game creator (caller of NewGame)

Value

(1 <untyped> bigint)

yel

untyped bigint

// 🟑 opponent

Value

(2 <untyped> bigint)

Game

type

Game holds the full state of one Connect Four match. board is indexed board\[row]\[col]; row 0 is the BOTTOM row. It carries no ID field: the id belongs to the store, which hands it back on lookup and iteration.

Value

v1.Game

games

*v0.Store

games assigns the game ids. v1 kept its own nextID plus an idKey() that zero-padded to width 12, which stopped ordering the Render list past 10^12.

Open
OID
0596a2…747c:4
games details

Inspect pointer

NewGame

func(opponent .uverse.address) int64

NewGame creates a match between the caller (πŸ”΄) and opponent (🟑). Returns the new game id.

Open
OID
0596a2…747c:7
NewGame details

Inspect func

getGame

func(id int64) (*v1.Game, .uverse.error)
Open
OID
0596a2…747c:9
getGame details

Inspect func

Drop

func(gameID int64, column int)

Drop places the caller's disc into the given column (0-6). Enforces turn order by caller, rejects full columns, and detects a 4-in-a-row win or a draw.

Open
OID
0596a2…747c:10
Drop details

Inspect func

wins

func(b *[6][7]int, r int, c int, p int) bool

wins checks whether the disc just placed at (r,c) for player p completes a run of 4 in any of the four directions.

Open
OID
0596a2…747c:12
wins details

Inspect func

run

func(b *[6][7]int, r int, c int, dr int, dc int, p int) int
Open
OID
0596a2…747c:13
run details

Inspect func

Render

func(path string) string

Render draws the board with πŸ”΄πŸŸ‘Β· and shows whose turn / the winner. path "" lists all games; path "\<id>" shows a single board.

Open
OID
0596a2…747c:15
Render details

Inspect func

renderGame

func(id v0.ID, g *v1.Game) string
Open
OID
0596a2…747c:17
renderGame details

Inspect func
cols : untyped bigint =(7 <untyped> bigint)
rows : untyped bigint =(6 <untyped> bigint)
empty : untyped bigint =(0 <untyped> bigint)
red : untyped bigint =(1 <untyped> bigint)
yel : untyped bigint =(2 <untyped> bigint)
Game : type =v1.Game
games : *v0.Store Inspect
NewGame : func(opponent .uverse.address) int64 Inspect
getGame : func(id int64) (*v1.Game, .uverse.error) Inspect
Drop : func(gameID int64, column int) Inspect
full : func(b *[6][7]int) bool Inspect
wins : func(b *[6][7]int, r int, c int, p int) bool Inspect
run : func(b *[6][7]int, r int, c int, dr int, dc int, p int) int Inspect
glyph : func(v int) string Inspect
Render : func(path string) string Inspect
renderList : func() string Inspect
renderGame : func(id v0.ID, g *v1.Game) string Inspect