{"id":32491925,"url":"https://github.com/seanwevans/pg_ttd","last_synced_at":"2026-07-13T11:32:15.964Z","repository":{"id":311977215,"uuid":"1045849083","full_name":"seanwevans/pg_ttd","owner":"seanwevans","description":"openTTD clone in postgres","archived":false,"fork":false,"pushed_at":"2025-09-27T19:35:01.000Z","size":219,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-27T21:18:11.277Z","etag":null,"topics":["database-experiment","game-clone","openttd","simulation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seanwevans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-27T19:58:29.000Z","updated_at":"2025-09-27T19:35:03.000Z","dependencies_parsed_at":"2025-09-27T21:09:44.836Z","dependency_job_id":null,"html_url":"https://github.com/seanwevans/pg_ttd","commit_stats":null,"previous_names":["seanwevans/pg_ttd"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/seanwevans/pg_ttd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanwevans%2Fpg_ttd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanwevans%2Fpg_ttd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanwevans%2Fpg_ttd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanwevans%2Fpg_ttd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seanwevans","download_url":"https://codeload.github.com/seanwevans/pg_ttd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seanwevans%2Fpg_ttd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35421716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-13T02:00:06.543Z","response_time":119,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database-experiment","game-clone","openttd","simulation"],"created_at":"2025-10-27T10:04:07.063Z","updated_at":"2026-07-13T11:32:15.959Z","avatar_url":"https://github.com/seanwevans.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg_ttd\n\u003cimg width=\"256\" alt=\"Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo\" src=\"https://github.com/user-attachments/assets/d46a4afa-aee9-4575-8338-bff952c32a3c\" /\u003e\n\n[![CI](https://github.com/seanwevans/pg_ttd/actions/workflows/tests.yml/badge.svg)](https://github.com/seanwevans/pg_ttd/actions/workflows/tests.yml)\n\n**pg_ttd** is a prototype of an attempt at *OpenTTD inside PostgreSQL*.\nWe attempt to reproduce at least part of OpenTTD within a Postgres database.\nThat is, all simulation, logic—world generation, tile updates, entities, economics, etc\nis implemented as stored procedures and tables in PostgreSQL.\n\n## Requirements\n\nPython utilities in this repository use the [`psycopg`](https://www.psycopg.org/psycopg3/) driver to\nconnect to PostgreSQL. Install the dependencies with:\n\n```bash\npip install -r requirements.txt\n```\n\nUtilities such as `python -m pgttd.run_tick` and `python -m pgttd.create_vehicle`\nexpect a PostgreSQL connection string via the `--dsn` option or the\n`DATABASE_URL` environment variable. The `create_vehicle` command defaults to\nplacing vehicles at coordinates `(1, 1)` when `--x` and `--y` are omitted.\n\n## Schema\n\nIndividual table definitions live in `sql/tables/`. Run the generator to\ncombine them into `sql/schema.sql` before applying the schema:\n\n```bash\nmake generate-schema\n```\n\nEdit the per-table files rather than `schema.sql` to avoid divergence.\n\n## Stored procedures\n\nDocumentation for the SQL procedures lives in [docs/procs.md](docs/procs.md). Notable\nentries include [`economy_tick()`](docs/procs.md#economy_tick) for economic updates\nand [`move_vehicles()`](docs/procs.md#move_vehicles) which advances vehicles along\ntheir routes.\n\n## Renderer\n\nA tiny curses-based renderer is included to visualise the map stored in\nPostgreSQL and advance the simulation.\n\n### Launch\n\n1. Ensure the database is populated with the required schema.\n2. Provide connection parameters using the standard `PGHOST`, `PGPORT`,\n   `PGDATABASE`, `PGUSER` and `PGPASSWORD` environment variables **or** create a\n   JSON configuration file and reference it with `PGTTD_CONFIG`. A PostgreSQL\n   DSN may also be supplied via the `--dsn` option (overriding any environment\n   variables).\n3. Run the viewer:\n\n   ```bash\n   python renderer/cli_viewer.py [--dsn DSN] [--refresh SECONDS] [--step]\n   ```\n\n   * `--refresh` – delay between screen updates in seconds (default: 0.5)\n   * `--step` – advance the simulation only when `t` is pressed\n\nPress `q` to quit. By default each refresh calls `tick()` in the database to\nadvance the world state. When `--step` is supplied the simulation advances only\nwhen `t` is pressed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseanwevans%2Fpg_ttd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseanwevans%2Fpg_ttd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseanwevans%2Fpg_ttd/lists"}