Dominion Protocol v1

In the grammar in figure 1, italicized names are non-terminals, text starting with a semi-colon is a comment about the grammar (i.e., not part of the grammar), and other non-italicized text is literal. Ellipses indicate zero or more repetitions of the preceding non-terminal. Extra whitespace may appear between any parenthesis, non-terminal, and other literal sequence (but not in the middle of a literal sequence that contains no parentheses).

Each player program runs as a process that receives notifications from its stdin and sometimes writes plays to its stdout. Each player is either in wait or move mode, starting out in wait mode:

For the most part, the constraints on plays should be clear based on the game rules. To clarify, here are some specific constraints:

Whenever a player reports a legal play message, it is broadcast to all other players through a (moved name play) notification, where name indicates the player who moved. In principle, many parts of state report information that players could track on their own via notifications, but state provides a basically complete snapshot of the game to support simpler player programs. More to the point, state reflects the information that a game controller needs to drive the game (but the controller needs a separate instance of the player-specific information in state for each player).

For now, the following elements of Dominion have been omitted from the player protocol: curse cards and all kingdom cards except mine. Expect future versions of the protocol to add additional kingdom cards and other player states (to respond to player actions, such as militia).

  state = 
((players name ...) ; in order, current first
 (supply card ...)
 (trash card ...) ; in order, top to bottom
 
 (actions number) ; actions remaining in turn
 (buys number) ; buys remaining in turn
 (coins number) ; coins available for buys
 
 (deck card ...) ; not in draw order
 (hand card ...)
 (plays card ...)
 (discards card ...))
     
  card = treasure
  | victory
  | action
     
  treasure = copper
  | gold
  | silver
     
  victory = estate
  | duchy
  | province
     
  action = mine
     
  play = (act mine treasure treasure)
  | (add treasure) ; adds coins
  | (buy card)
  | (clean) ; ending a turn with an empty hand
  | (clean card) ; card in hand is exposed
     
  notification = (move state)
  | (moved name play)
     
  name = a sequence of letters
     
  number = a sequence of decimal digits

Figure 1: Dominion protocol, version 1