Have more questions? Join our

Build a v3 game (workflow)

  1. Create the game on v3. Call create_game with frameworkMajor: 3. It starts as tic-tac-toe: /src/lib.rs in Rust and /src/frontend.tsx in React. Read both with read_file before changing anything. get_example with reversi-rust shows a bigger game.
  2. Read the SDK. get_doc_section with v3-rust-sdk is the whole Rust API, and v3-react-client is the client's. For hidden information, get_example with cards-rust is a worked hand of face-down cards.
  3. Write the rules first. Replace /src/lib.rs with your game's rules: config, available_actions, apply_action, scores and is_game_over. Change state only through Table, use Rng for anything random, and put anything a player must not learn in a private part rather than in meta_data.
  4. Validate. validate_code compiles the game with Cargo. Fix every error it reports; they point at /src/lib.rs:LINE:COL.
  5. Play it. start_game starts a session; apply_action makes moves, naming a piece by { spaceId, index }; inspect_state reads the state. Check that the legal actions, scores and game over are what the rules say. apply_action returns each move's intent and log entries, and takes back an undoable move with { "type": "Undo", "moveId": ... }.
  6. Check what each player sees. inspect_state with viewer set to a player id, or "spectator", shows exactly what that player receives. Anything secret that appears there is a leak: move it into a private part, or into a Collection space.
  7. Write the client. Update /src/frontend.tsx for your board, using useSpace, useAvailableActions and match.click. Key and click pieces by their viewKey, and read privateKind defensively: it is absent for a piece this player may not see.
  8. Commit. commit builds and saves the game. A match started after that plays the committed version.

render_game does not work on preview environments, so check the client by playing a real match.