Branching (fork/merge)¶
engine.fork() makes a branch of the game document from its current state. The branch has its own Automerge actor ID. Dispatch moves on the branch to preview a turn, compare strategies, or let an AI look ahead without altering the parent game. If you only need the result of the simulation, discard the branch.
engine.mergeFrom(fork) merges document changes. It does not replay the branch's actions or rerun legality checks. If the parent and the branch both drew the same card, for example, the combined state can contain that card in two hands. For a move that should count in the live game, submit the move to the authoritative game and validate it there, rather than merging a simulation.
A branch is not a save file. Saving restores a position; branching lets separate lines of play evolve from it. Compaction keeps the current state while discarding older document history.