Have more questions? Join our Discord

Build a game

Follow these steps in order. Each step ends on a condition you can check. Finish the condition before you start the next step.

Read How a game works first. It defines the words these steps use: seat, view, offer, intent, step, decision, draft, reveal.

1. Create the game

Call create_game with frameworkMajor: 3.

The new game starts as tic-tac-toe: /src/lib.rs holds the game logic and /src/frontend.tsx holds the client.

Done when list_doc_sections with the new gameDefinitionId answers frameworkVersion 3. Pass the gameDefinitionId to every docs call from now on, so you get these sections.

2. Read the seed

Call get_example for tic-tac-toe-rust and tic-tac-toe-rust-client.

Done when you can point to each of the six game functions in the game logic, and to the place where the client takes an offer.

3. Model the state

Decide how the design maps onto the state: one space for each area of the board, hand, deck or pile, one piece for each card, token or tile, and maps for the rest. Decide who owns each space and piece, because ownership decides who sees private parts.

References: The state, Hidden information.

Done when every rule of the design names the spaces, pieces or maps it reads, and every hidden fact has an owner who may see it.

4. Write setup and the offers

Write setup. Then write offers: for every situation, every legal move of the seat, each with its intent. A move that needs several values is several steps, one value each.

References: The game functions, Offers, intents and decisions.

Done when, for every situation inside an open decision, the seat has at least one choice or confirm offer, no choice can bring the decision back to a state it had before, and every offer whose result depends on hidden information is marked with .revealing().

5. Write the moves, the scores and the end

Write apply_action, scores, score_labels and is_game_over. Change the state only through Table. Write each step's log lines with table.log.

Replace the seed's tic-tac-toe tests with a #[test] for each rule you write.

Then play a session with start_game and apply_action at each seat count the game allows.

References: Changing the state, Randomness and determinism, Testing a game, Playing a session.

Done when validate_code answers no errors for the game logic, its tests counts a passed test for each rule, and a session at each seat count plays to the end of the game. Fix each error from its message; the codes are in Builds, limits and errors.

6. Write the client

Change /src/frontend.tsx to draw this game's board, offers, draft, undo, failures and scores, and its end.

References: The React client, boardweaver/react reference.

Done when validate_code answers valid: true and commit succeeds.

7. Play it

Ask a person to play the game on its beta channel, which plays the newest commit, once for each seat count the game allows.

References: Testing a game.

Done when a match at each seat count reaches the end and shows the right winner.

8. Add the pages and the theme

Write the rules pages, the marketing page and the theme.

References: Write the rules pages, Write the marketing page, Design the theme.

Done when validate_code answers valid: true and commit succeeds.