# Cartório Simulator

> A daily browser game about Brazilian bureaucracy: get one stamp before lunch. Every day's chain is generated from a seed, solvable by construction, and checked by a solver over 10,000 days in the test suite.

Case study · Vinícius Albuquerque · https://www.vinicius-albuquerque.com.br/en

- Live site: https://allbdev.github.io/notary-office-simulator/
- View code: https://github.com/allbdev/notary-office-simulator
- Case study (HTML): https://www.vinicius-albuquerque.com.br/en/projeto/cartorio-simulator

## Overview

Cartório Simulator is a free daily browser game, in English and Portuguese, on desktop and phone: get one document stamped at a Brazilian cartório before the windows close for lunch. Window 3 says you need Form 27-B, Form 27-B needs a copy, the copy must be authenticated at Window 4, and Window 4 goes to lunch in 40 seconds. You take a ticket, queue, fill in forms where every form has a trap, get sent back and try again, then paste your result: time, forms, send-backs and your path through the windows. The game is a pure function of a seed and the player's inputs. A seeded generator builds a dependency graph of documents backwards from the day's goal, so every chain is solvable by construction. A discovery solver that plays like a careful first-time player runs over 10,000 consecutive days plus 500 random seeds on every test run and checks that each one finishes within a 6-minute fairness bound; the seed report puts the median at 1:18. Windows, queues, lunch breaks and the 30× cartório clock are state machines advanced in fixed ticks, so the run saved in localStorage is just a list of ticks and actions, and replaying it rebuilds the exact state: a bug report is a date plus that log. The hall is drawn on a canvas, and the paper (forms, ticket, folder, stamps) is real HTML form controls, playable with a keyboard and a screen reader and readable on a phone. Pure game logic lives in its own folder with no DOM, the bundle is held under 200 KB by the check script, and GitHub Actions runs the checks and a Playwright smoke test on every push and deploys to GitHub Pages.

## Highlights

- The whole game is a pure function of a seed and the player's inputs: a run is replayed exactly from an input log
- Seeded generator that builds a document dependency graph backwards from the goal, solvable by construction
- Property tests run a solver over 10,000 consecutive days plus 500 random seeds and enforce a 6-minute fairness bound
- Windows, queues, lunch breaks and a 30× clock as state machines advanced in fixed ticks
- Forms are real HTML form controls, playable by keyboard and screen reader, in English and Portuguese
- Bundle held under 200 KB, Playwright smoke test and deploy to GitHub Pages on every push


## Technologies

TypeScript, Canvas, Vite, Vitest, Property-based testing, Playwright, GitHub Actions

## Screenshots

![The cartório hall: five windows, their lines and the ticket board](https://www.vinicius-albuquerque.com.br/projects/cartorio-simulator/cartorio-hall.avif)

![A form with a trap, next to the ID card and today's rules at the window](https://www.vinicius-albuquerque.com.br/projects/cartorio-simulator/cartorio-form.avif)

![In line at Window 1, three people ahead](https://www.vinicius-albuquerque.com.br/projects/cartorio-simulator/cartorio-queue.avif)

![Result: the stamped declaration, time, forms and the path through the windows](https://www.vinicius-albuquerque.com.br/projects/cartorio-simulator/cartorio-result.avif)
