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

Readme View source

Connect Four

⚠️ 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 two-player Connect Four realm on a 7-wide × 6-tall board. The game creator plays 🔴 and moves first; the named opponent plays 🟡. Drop enforces turn order by caller, rejects full and out-of-range columns, and detects a horizontal, vertical, or diagonal 4-in-a-row (or a draw). Render draws the board with 🔴🟡· and shows whose turn it is or who won.

Realm path: gno.land/r/REPLACE_ADDR/connect4

Example calls

# create a game against another address (you are 🔴, returns the game id)
NewGame(g1zabc...opponent)   # -> 1

# drop discs into columns 0-6 (turns alternate, enforced by caller)
Drop(1, 3)   # 🔴 drops in column 3
Drop(1, 3)   # 🟡 drops in column 3 (called from opponent's key)

# view state
render:            # lists all games
render:1           # shows board for game 1

Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/r/moul/x/daily/connect4/v0 dependency graph

🧪 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.

Functions 3

func Drop

crossing Action
1func Drop(cur realm, gameID int64, column int)
source

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.

func NewGame

crossing Action
1func NewGame(cur realm, opponent address) int64
source

NewGame creates a match between the caller (🔴) and opponent (🟡). Returns the new game id.

func Render

1func Render(path string) string
source

Render draws the board with 🔴🟡· and shows whose turn / the winner. path "" lists all games; path "<id>" shows a single board.

Types 1

type Game

struct
 1type Game struct {
 2	ID       int64
 3	Red      address // 🔴 creator, moves first
 4	Yellow   address // 🟡 opponent
 5	Board    [rows][cols]int
 6	Turn     int  // whose turn: red or yel
 7	Winner   int  // empty until decided; red/yel = winner
 8	Draw     bool // true when board full with no winner
 9	Finished bool
10}
source

Game holds the full state of one Connect Four match. board is indexed board[row][col]; row 0 is the BOTTOM row.

Imports 6

Source Files 3