Bridge Training

Constants

Everything exported by @workspace/bridge/constants, grouped by theme — cards, bids, players, vulnerability, scoring, defaults, locales, board numbering, PBN tags, game facts, core configs, teaching.

Import from @workspace/bridge/constants. A subset is also reachable as engine.constants (see Engine).

Cards

ExportValue / shapeDescription
SUIT{ spades: "S", hearts: "H", diamonds: "D", clubs: "C" }Named suits
SUITS["S", "H", "D", "C"]Standard order (♠ ♥ ♦ ♣)
Suitstypetypeof SUITS
SUIT_SYMBOLS{ S: "♠", H: "♥", D: "♦", C: "♣", NT: "SA" }Display symbols (Record<string, string>)
SUIT_COLOR{ S: "black", H: "red", D: "red", C: "black" }Ink colour, used to sort alternating layouts
RANKS["A", "K", "Q", "J", "T", "9", … "2"]Descending rank order
NO_TRUMP"NT"No-trump denomination
CARD_SET{ standard: "standard", petitBridge: "petit-bridge" }Deck names a mode can use
CardSettypeUnion of CARD_SET values
mapSuitRecord(fn)Record<Suit, T>Build a record over the four suits
mapDenominationRecord(fn)Record<Denomination, T>Same over the five denominations
constants.ts
SUITS; // => ["S", "H", "D", "C"]
SUIT.spades; // => "S"
SUIT_COLOR.H; // => "red"
RANKS; // => ["A", "K", "Q", "J", "T", "9", "8", "7", "6", "5", "4", "3", "2"]
NO_TRUMP; // => "NT"
SUIT_SYMBOLS.S; // => "♠"
SUIT_SYMBOLS.NT; // => "SA"
CARD_SET.petitBridge; // => "petit-bridge"

Bids and tricks

ExportValueDescription
BID_LEVELS[1, 2, 3, 4, 5, 6, 7]Bid levels
DENOMINATIONS["C", "D", "H", "S", "NT"]Biddable denominations, ascending
SPECIAL_BID{ pass: "Pass", double: "X", redouble: "XX", alert: "Alert" }Named special bids
SPECIAL_BIDS["Pass", "X", "XX", "Alert"]Special bids in canonical order
COUNTER_STATUS{ none: "none", doubled: "X", redoubled: "XX" }Double / redouble status
BOOK6Tricks a declarer wins before contract tricks count
TRICKS_PER_DEAL13Tricks in a full standard deal
constants.ts
BID_LEVELS; // => [1, 2, 3, 4, 5, 6, 7]
DENOMINATIONS; // => ["C", "D", "H", "S", "NT"]
SPECIAL_BID.double; // => "X"
SPECIAL_BIDS; // => ["Pass", "X", "XX", "Alert"]
COUNTER_STATUS.redoubled; // => "XX"
BOOK; // => 6
TRICKS_PER_DEAL; // => 13

Players

ExportValueDescription
PLAYER{ north: "N", east: "E", south: "S", west: "W" }Named seats
PLAYERS["N", "E", "S", "W"]Clockwise order
Playerstypetypeof PLAYERS
PLAYERS_PER_TRICK4One entry per seat; distinct from nbCardsPerHand
NS_PLAYERS / EW_PLAYERS["N", "S"] / ["E", "W"]Seats per partnership
PARTNERSHIP{ NS: "NS", EW: "EW" }Named partnerships
PLAYER_SIDE{ attack: "attack", defense: "defense" }Declaring vs defending side
DECLARER_PLAYER"S"Default declarer
mapPlayerRecord(fn)Record<Player, T>Build a record over the four seats
constants.ts
PLAYER.north; // => "N"
PLAYERS; // => ["N", "E", "S", "W"]
PLAYERS_PER_TRICK; // => 4
PARTNERSHIP.NS; // => "NS"

Vulnerability, scoring, result

ExportValueDescription
VULNERABILITY{ unset: "UNSET", none: "NONE", NS: "NS", EW: "EW", all: "ALL" }Named values; declaration order is the picker order
VULNERABILITIES["UNSET", "NONE", "NS", "EW", "ALL"]All values, in display order
VULNERABILITY_STATUS{ vulnerable: "vulnerable", nonVulnerable: "non-vulnerable", unset: "unset" }Per-player status values
SCORING{ unset: "UNSET", TPP: "TPP", IMP: "IMP" }Named scoring modes
SCORING_MODES["UNSET", "TPP", "IMP"]All scoring modes
RESULT_EXPECTED{ makeContract: "MAKE_CONTRACT", defeatContract: "DEFEAT_CONTRACT", par: "PAR", unset: "" }Expected-result sentinels
UNSET"UNSET"Shared "not yet defined" sentinel
constants.ts
VULNERABILITY.all; // => "ALL"
VULNERABILITIES; // => ["UNSET", "NONE", "NS", "EW", "ALL"]
VULNERABILITY_STATUS.nonVulnerable; // => "non-vulnerable"
SCORING.TPP; // => "TPP"
SCORING_MODES; // => ["UNSET", "TPP", "IMP"]
UNSET; // => "UNSET"
RESULT_EXPECTED.defeatContract; // => "DEFEAT_CONTRACT"

Defaults

ExportValue
DEFAULT_DEALER"S"
DEFAULT_SELECTED_PLAYER"S" (DECLARER_PLAYER)
DEFAULT_VULNERABILITY"UNSET"
DEFAULT_SCORING_MODE"UNSET"
DEFAULT_LOCALE"en"
DEFAULT_TEACHING_MODE"auction"
DEFAULT_BRIDGE_CONTEXT{ teachingMode: "auction", locale: "en" }
constants.ts
DEFAULT_DEALER; // => "S"
DEFAULT_BRIDGE_CONTEXT; // => { teachingMode: "auction", locale: "en" }

Locales

ExportDescription
LOCALES["en", "fr", "es", "it", "ca", "de", "pt", "el", "nl", "sv", "pl"]
parseLocale(value)unknown → Locale | null: the value when it is a known locale, else null; the caller applies its own fallback (?? DEFAULT_LOCALE)
constants.ts
LOCALES; // => ["en", "fr", "es", "it", "ca", "de", "pt", "el", "nl", "sv", "pl"]
parseLocale("fr"); // => "fr"
parseLocale("xx"); // => null
parseLocale(null) ?? DEFAULT_LOCALE; // => "en": the caller picks its fallback

Board numbering

Dealer and vulnerability follow the 16-board cycle of the Laws of Bridge.

ExportDescription
BOARD_VULNERABILITY_CYCLE16 PBN labels ("None", "NS", "EW", "All"), indexed by (board - 1) % 16
dealerForBoard(board)N, E, S, W cycling every four boards
constants.ts
dealerForBoard(1); // => "N"
dealerForBoard(5); // => "N"
BOARD_VULNERABILITY_CYCLE.length; // => 16

PBN tag values

ExportValue
PBN_VULNERABILITY{ None: "None", NS: "NS", EW: "EW", All: "All" }
PBN_SCORING{ IMP: "IMP", TPP: "TPP" }
PBN_TEACHINGThe twelve teaching mode values accepted in the PBN teaching tag

Game facts

Closed catalogues used by interaction traces.

ExportValue
GAME_FACT_KINDS["bid-placed", "card-played", "trick-completed", "state-replaced", "play-error", "hint"]
PLAY_ERROR_KINDS["follow-suit", "claim-rejected"]
AUCTION_ERROR_KINDS["wrong-bid", "no-expected-bid"]
STATE_REPLACED_REASONS["undo", "redo", "seek"]
GameFactKind, PlayErrorKind, AuctionErrorKind, StateReplacedReasonCorresponding union types
constants.ts
GAME_FACT_KINDS.includes("card-played"); // => true
PBN_TEACHING.length; // => 12

Record helpers

constants.ts
const lengths = mapSuitRecord(() => 0); // => { S: 0, H: 0, D: 0, C: 0 }
const scores = mapPlayerRecord(() => 0); // => { N: 0, E: 0, S: 0, W: 0 }
const byDenomination = mapDenominationRecord((d) => d === NO_TRUMP);
// => { S: false, H: false, D: false, C: false, NT: true }

Core configs

The per-mode CoreConfig values and their resolver are internal: a config depends on the mode, so it is read from the engine built for that mode (engine.hands.config, flags on engine.ctx). Game Modes documents every config, value by value.

Teaching

AUCTIONS, DEFAULT_AUCTION_MODE, DEFAULT_TEACH_DUMMY, TEACH_MODES, TEACHING_MODE_VALUES, isTeachingMode, PEDAGOGY_GROUP_IDS, PEDAGOGY_GROUPS and the TeachMode, PedagogyGroupId, PedagogyValue, PedagogyGroup types are documented on Teaching.