games

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package games defines what a game is and how games are found. It holds types only: the concrete games live in sub-packages, and internal/games/catalog wires them into a Registry (a game package imports this one, so this one cannot import them).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("no such game")

ErrNotFound is returned by Resolve when nothing matches.

Functions

This section is empty.

Types

type AmbiguousError

type AmbiguousError struct {
	Input      string
	Candidates []Entry
}

AmbiguousError is returned by Resolve when a prefix matches several games.

func (*AmbiguousError) Error

func (e *AmbiguousError) Error() string

type Entry

type Entry struct {
	Info Info
	New  func() Game
}

Entry pairs a game's Info with its constructor (nil while Planned).

type Game

type Game interface{ proto.Program }

Game is a program the persona can launch.

type Info

type Info struct {
	Number    int    // position on LIST GAMES, 1..n; 0 when not Listed
	Listed    bool   // shown by LIST GAMES (tic-tac-toe is not, as in the film)
	Name      string // the film's spelling, upper case
	Slug      string // lower-case words joined by '-'
	Aliases   []string
	Layout    proto.Layout
	PanelRows int // rows of View for LayoutPanel
	Status    Status
	Blurb     string // one line for --games and the README
	// Internal marks a program that games hand off to and players never choose: the
	// ending. Only Get finds it; Resolve, Exact, All and Listed skip it.
	Internal bool
}

Info describes a game. The registry is the only source of it.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is the ordered, validated set of games.

func NewRegistry

func NewRegistry(entries ...Entry) (*Registry, error)

NewRegistry validates entries and returns a registry in the given order.

func (*Registry) All

func (r *Registry) All() []Entry

All returns every game players can choose, in registry order.

func (*Registry) Exact

func (r *Registry) Exact(input string) (Entry, bool)

Exact finds a game whose slug, alias or name equals input after normalisation. Unlike Resolve it never matches numbers or prefixes, so conversation cannot start a game by accident.

func (*Registry) Get

func (r *Registry) Get(slug string) (Entry, bool)

Get returns the entry with the given slug.

func (*Registry) Listed

func (r *Registry) Listed() []Entry

Listed returns the entries shown by LIST GAMES, in Number order.

func (*Registry) Resolve

func (r *Registry) Resolve(input string) (Entry, error)

Resolve finds a game by, in order: listed number (1..n), slug, alias, exact name, then a unique prefix of a slug, alias or name. Matching ignores case and punctuation.

type Status

type Status uint8

Status says whether a game can be played yet.

const (
	Planned  Status = iota // listed, but WOPR declines in character
	Playable               // has a constructor
)

Statuses.

func (Status) String

func (s Status) String() string

Directories

Path Synopsis
Package ai is the game-tree search WOPR plays board games with: negamax with alpha-beta pruning, iterative deepening, and an optional quiescence search.
Package ai is the game-tree search WOPR plays board games with: negamax with alpha-beta pruning, iterative deepening, and an optional quiescence search.
Package airtoground is Air-to-Ground Actions: a short air campaign against WOPR's defended targets (docs/PLAN.md §6.3, a bespoke game on the sim engine's combat-results and kill-ratio tables).
Package airtoground is Air-to-Ground Actions: a short air campaign against WOPR's defended targets (docs/PLAN.md §6.3, a bespoke game on the sim engine's combat-results and kill-ratio tables).
Package biotoxic is Theaterwide Biotoxic and Chemical Warfare on the sim engine.
Package biotoxic is Theaterwide Biotoxic and Chemical Warfare on the sim engine.
Package blackjack is Black Jack against WOPR's dealer: one deck, the dealer stands on soft 17 (DefaultRules; Rules.StandSoft17 changes it), black jack pays 3 to 2, double down on any first two cards, and one split of a pair a round.
Package blackjack is Black Jack against WOPR's dealer: one deck, the dealer stands on soft 17 (DefaultRules; Rules.StandSoft17 changes it), black jack pays 3 to 2, double down on any first two cards, and one split of a pair a round.
Package board draws 8x8 boards for checkers and chess, and parses their squares.
Package board draws 8x8 boards for checkers and chess, and parses their squares.
Package bridge is minimal contract bridge (docs/PLAN.md §3, decision 14): WOPR bids all four hands by point count, the player's side always declares (the table turns when East and West hold the cards), and the player plays both declarer's hand and dummy's while WOPR defends.
Package bridge is minimal contract bridge (docs/PLAN.md §3, decision 14): WOPR bids all four hands by point count, the player's side always declares (the table turns when East and West hold the cards), and the player plays both declarer's hand and dummy's while WOPR defends.
Package cards is the playing cards the card games share: cards and their text, decks, shuffling with the session's seed, tricks (trick.go), and the cards drawn in ASCII (art.go).
Package cards is the playing cards the card games share: cards and their text, decks, shuffling with the session's seed, tricks (trick.go), and the cards drawn in ASCII (art.go).
Package catalog is the one place where game constructors are wired into a registry.
Package catalog is the one place where game constructors are wired into a registry.
Package checkers is 8x8 checkers (English draughts) against WOPR: compulsory captures, multiple jumps, kings that move both ways, and a draw after 40 moves each without progress.
Package checkers is 8x8 checkers (English draughts) against WOPR: compulsory captures, multiple jumps, kings that move both ways, and a draw after 40 moves each without progress.
Package chess is chess against WOPR.
Package chess is chess against WOPR.
Package desertwarfare is Desert Warfare on the sim engine: armour against armour along a coast road, with supply lines.
Package desertwarfare is Desert Warfare on the sim engine: armour against armour along a coast road, with supply lines.
Package ending is the film's climax after zero players (docs/PLAN.md §6.2): WOPR plays tic-tac-toe against itself faster and faster while it cracks the last of the launch code, runs every war scenario to WINNER: NONE, and concludes that the only winning move is not to play.
Package ending is the film's climax after zero players (docs/PLAN.md §6.2): WOPR plays tic-tac-toe against itself faster and faster while it cracks the last of the launch code, runs every war scenario to WINNER: NONE, and concludes that the only winning move is not to play.
Package falkensmaze is Falken's Maze: a maze under fog of war, walked with the arrow keys.
Package falkensmaze is Falken's Maze: a maze under fog of war, walked with the arrow keys.
Package fightercombat is Fighter Combat: a turn-based dogfight of energy and aspect against WOPR (docs/PLAN.md §6.3, a bespoke game on the sim engine's combat-results and kill-ratio tables).
Package fightercombat is Fighter Combat: a turn-based dogfight of energy and aspect against WOPR (docs/PLAN.md §6.3, a bespoke game on the sim engine's combat-results and kill-ratio tables).
Package gamestest provides stub programs for tests of the host, persona and ui.
Package gamestest provides stub programs for tests of the host, persona and ui.
Package ginrummy is two-player gin rummy against WOPR: ten cards each, draw from the stock or take the discard, then discard; knock with 10 or less deadwood, or go gin with none.
Package ginrummy is two-player gin rummy against WOPR: ten cards each, draw from the stock or take the discard, then discard; knock with 10 or less deadwood, or go gin with none.
Package gtw is Global Thermonuclear War, the film's set piece (docs/PLAN.md §6.2): choose a side and list targets; the first strike flies on the big board at once, then you order two more as DEFCON falls, and WOPR takes the last rung alone.
Package gtw is Global Thermonuclear War, the film's set piece (docs/PLAN.md §6.2): choose a side and list targets; the first strike flies on the big board at once, then you order two more as DEFCON falls, and WOPR takes the last rung alone.
Package guerrilla is Guerrilla Engagement on the sim engine: an asymmetric campaign.
Package guerrilla is Guerrilla Engagement on the sim engine: an asymmetric campaign.
Package hearts is four-handed Hearts: the player sits South and WOPR plays West, North and East.
Package hearts is four-handed Hearts: the player sits South and WOPR plays West, North and East.
Package poker is heads-up five-card draw against WOPR: an ante of 1, fixed-limit betting of 5 before the draw and 10 after (a bet and three raises a round), and up to three cards drawn.
Package poker is heads-up five-card draw against WOPR: an ante of 1, fixed-limit betting of 5 before the draw and 10 after (a bet and three raises a round), and up to three cards drawn.
Package testkit drives proto programs through the real host runner, with no terminal, and records a transcript: what WOPR printed and what the user typed, as the console would show it.
Package testkit drives proto programs through the real host runner, with no terminal, and records a transcript: what WOPR printed and what the user typed, as the console would show it.
Package theaterwide is Theaterwide Tactical Warfare on the sim engine: corps and air wings on a European front, with an escalation ladder.
Package theaterwide is Theaterwide Tactical Warfare on the sim engine: corps and air wings on a European front, with an escalation ladder.
Package tictactoe is the game that ends the film: perfect minimax, so nobody can win against WOPR.
Package tictactoe is the game that ends the film: perfect minimax, so nobody can win against WOPR.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL