Next steps

At the start of this tutorial, the rules of checkers had to apply to each move from each program. Now the rules are in the database. The move and jump mutations select no row for an incorrect move, so an incorrect move writes nothing. The crown reactor makes a king in the same transaction as the move that takes a piece to its king row. The board subscription keeps the displayed board current. A slow reader can receive one result for several moves.

The events worker uses those same saved rules. Bob’s double jump removes both red pieces in one transaction. After reconnecting, the generated board query finds his king on 18 even though the last turn notification went unread. To change a rule, you change definitions/checkers/boards.dust and run go run ./seed again.

Extend the game

In a full game, a player must capture when a capture is possible, and a piece can jump again in the same turn after a capture. The double-jump mutation covers two captures by a king. Extend it to handle longer paths and enforce mandatory captures. A full game also has a start position with 12 pieces of each color, and a rule that ends the game when a player cannot move.

Reference and theory pages

  • Database query functions give the full syntax of queries, patches, mutations and reactors.
  • Schemas and contracts give the contracts that set the SDK types.
  • SDK generation shows the generator settings and the files that the generator writes.
  • Reactors tells why a reactor runs in rounds, and how the database selects between the changes of two reactors by priority.
  • Tutorials lists the quickstart and this tutorial.