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. The client uses the v2 React API: react-match-api.
  3. Write the rules first. Replace /src/lib.rs with your game's rules: config, kinds, available_actions, apply_action, scores and is_game_over. Change state only through Table, and use Rng for anything random.
  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; inspect_state reads the state. Use set_state to jump to a position you want to test. Check that the legal actions, scores and game over are what the rules say.
  6. Write the client. Update /src/frontend.tsx for your board, using useGameState, useAvailableActions and match.click. Piece and space sizes come from kinds().
  7. 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.