Skip to main content

Board Games

WEFA includes deterministic board games as the social play component of the core loop. Each game uses a pure rules engine that is fully testable and independent of UI or sync.

Available Games

Tic-Tac-Toe

The first game and primary V1 experience. Simple rules, fast feedback loop.

  • Board: 3x3 grid (9 cells, value 7 = empty, 0 = player A, 1 = player B)
  • Move: Cell index (0-8)
  • Win: 8 winning line patterns checked after each move
  • Draw: All cells filled with no winner

Mancala

Strategic, culturally resonant, supports learning.

  • Board: 14 cells (6 pits + 1 store per player)
  • Setup: 4 seeds per pit initially
  • Move: Pit index (0-5 for player A, 7-12 for player B)
  • Sowing: Counter-clockwise, skip opponent's store
  • Capture: Last seed lands in own empty pit AND opposite pit has seeds -> capture both to own store
  • Extra turn: Last seed lands in own store
  • Game end: One side all empty -> sweep remaining to that side's store
  • Winner: Most seeds in store

Ludo

Phase 2 game. Longer sessions, social play, more reward hooks.

Rules Engine Interface

All games implement the GameRulesEngine<TBoard, TMove> interface:

interface GameRulesEngine<TBoard, TMove> {
initialBoard(): TBoard;
isValidMove(board: TBoard, move: TMove, player: number): boolean;
applyMove(board: TBoard, move: TMove, player: number): MoveResult<TBoard>;
getValidMoves(board: TBoard, player: number): TMove[];
getScore(board: TBoard): { p0: number; p1: number };
}

This keeps game logic pure, deterministic, and testable with 100% branch coverage.

Game Registry

The registry maps game types to their engines and board configurations:

// src/modules/games/registry.ts
getEngine(type) // returns the rules engine
getBoardConfig(type) // returns dimensions, cellSize, cellShape, storePositions

Key Files

  • src/modules/games/tic-tac-toe.ts - Tic-Tac-Toe rules engine
  • src/modules/games/mancala.ts - Mancala rules engine
  • src/modules/games/registry.ts - Game type registry
  • src/modules/games/*.test.ts - Rules tests (100% branch coverage required)