Versions in this module Expand all Collapse all v0 v0.1.2 Oct 1, 2026 v0.1.1 Oct 1, 2026 Changes in this version + var ErrAlreadyQueued = errors.New("player already queued") v0.1.0 Jun 14, 2026 Changes in this version + const DefaultRating + const Draw + var ErrClosed = errors.New("connection closed") + var ErrIllegalMove = errors.New("illegal move") + var ErrNoOpponent = errors.New("no opponent found") + var ErrTimeout = errors.New("move timeout") + var ErrUnknownGame = errors.New("unknown game") + func EloUpdate(ra, rb, scoreA float64) (na, nb float64) + func Expected(a, b float64) float64 + func Outcome(winner, player int) string + func ScoreFor(winner, p int) float64 + type Bot interface + Move func(s State) string + Name func() string + type Connect4 struct + func (Connect4) ID() string + func (Connect4) Start() State + func (Connect4) Title() string + type FinishedMatch struct + EndedAt time.Time + Game string + Moves []Move + Players [2]string + RatingAfter [2]float64 + RatingBefore [2]float64 + Reason string + StartedAt time.Time + Winner int + type Game interface + ID func() string + Start func() State + Title func() string + type GreedyBot struct + R *rand.Rand + func (GreedyBot) Name() string + func (b GreedyBot) Move(s State) string + type JSONLineConn struct + func NewJSONLineConn(name string, r io.Reader, w io.Writer) *JSONLineConn + func (c *JSONLineConn) Name() string + func (c *JSONLineConn) ReadJoin(deadline time.Time) (string, error) + func (c *JSONLineConn) ReadMove(deadline time.Time) (string, error) + func (c *JSONLineConn) Send(v any) error + type MatchResult struct + Game string + Moves []Move + Players [2]string + Reason string + Winner int + func RunMatch(g Game, p [2]PlayerIO, moveTimeout time.Duration) *MatchResult + type Matchmaker struct + func NewMatchmaker(reg *Registry, store Store, moveTimeout, queueWait time.Duration) *Matchmaker + func (mm *Matchmaker) Play(ctx context.Context, gameID string, io PlayerIO) error + type Move struct + Move string + Player int + type PlayerIO interface + Name func() string + ReadMove func(deadline time.Time) (string, error) + Send func(v any) error + type Registry struct + func Catalog() *Registry + func NewRegistry(gs ...Game) *Registry + func (r *Registry) All() []Game + func (r *Registry) Get(id string) (Game, bool) + func (r *Registry) IDs() []string + type ResultMsg struct + Outcome string + Rating float64 + Reason string + Type string + Winner int + type State interface + Apply func(move string) (State, error) + Legal func() []string + Observe func() map[string]any + Render func() string + Terminal func() (over bool, winner int) + ToMove func() int + type Store interface + Rating func(user, game string) (float64, error) + SaveMatch func(FinishedMatch) error + type TTT struct + func (TTT) ID() string + func (TTT) Start() State + func (TTT) Title() string