THE HITCHHIKER'S GUIDE TO THE FOUNDATION
A text adventure that runs in your terminal. Three protagonists, three acts, thirty-four locations, one hundred and forty-six objects, twenty-three characters, and one towel.
The story takes place in the universe of Isaac Asimov's Foundation trilogy, narrated with the dry, cosmic absurdity of Douglas Adams' The Hitchhiker's Guide to the Galaxy. You play Gaal Dornick, Salvor Hardin, and Bayta Darell in turn — surviving, negotiating, and solving puzzles in the cracks of psychohistory, while deciding whether the future of the galaxy should be handed to a man in a clown suit.
This is a fan-made work, unaffiliated with the Asimov estate, the publishers, or the Second Foundation (which does not exist).
Quick Start
Install from PyPI
pip install foundation-guide
foundation-guide
Or install it as a standalone command-line tool:
uv tool install foundation-guide
foundation-guide
Run from source
Requirements: Python 3.11 or newer and uv. The game uses only the Python standard library, with no third-party dependencies.
On Windows, double-click:
play.bat
Or open a terminal in the project directory:
cd foundation-guide
uv run python -m foundation_guide
On other platforms:
uv run python -m foundation_guide
Command-line options
--no-color disable ANSI colour
--ascii use ASCII box drawing
--width N set the text width
--load [name] load a save (default: autosave)
--script FILE play commands from a file (testing / demos)
--debug show full tracebacks on errors
--version show the version
For example:
uv run python -m foundation_guide --no-color --width 88
uv run python -m foundation_guide --script tests\walkthrough_full.txt --no-color
The Three Acts
| Act | Title | Protagonist | Setting |
|---|---|---|---|
| I | The Psychohistorians | Gaal Dornick | Trantor |
| II | The Mayors | Salvor Hardin | Terminus |
| III | The Mule | Bayta Darell | Kalgan, Trantor, Rossem |
Each act has its own locations, characters, puzzle chain, scoring, and endings. Completing an act moves you automatically to the next one and writes an autosave between acts.
How to Play
The game accepts natural English commands. Articles, capitalisation, and punctuation are mostly ignored, and IT / THEM refer to the last object mentioned.
Movement
NORTH / SOUTH / EAST / WEST / UP / DOWN
N / S / E / W / U / D
GO <exit> ENTER <place> EXIT
BOARD <ship>
Exploration and objects
LOOK EXAMINE <object> READ <object>
SEARCH <object> TAKE <object> TAKE ALL
DROP <object> INVENTORY / I
OPEN / CLOSE <object>
UNLOCK <object> WITH <key>
WEAR / REMOVE <clothing>
PUT <object> IN / ON <container>
Characters and puzzles
TALK TO <character>
ASK <character> ABOUT <topic>
GIVE <object> TO <character>
SHOW <object> TO <character>
USE <object> [ON <object>]
PUSH / PULL / PRESS / TURN / SWITCH <object>
SET <object> TO <value>
TYPE <text>
SAY <words>
Meta commands
GUIDE list unlocked Guide entries
GUIDE <topic> read an entry
HINT a hint for the current puzzle (never costs points)
MAP show a map of visited locations
SCORE show score, rank, and statistics
SAVE [name] save (default: quicksave)
LOAD [name] load (default: quicksave)
UNDO undo one turn
RESTART start over (asks for confirmation)
ACHIEVEMENTS list achievements
QUIT leave the game
Features
- A complete three-act campaign: every act has its own map, puzzle chain, character dialogue, and endings.
- A forgiving parser: supports
PICK UP,LOOK AT,PUT X IN Y,USE X ON Y,ASK X ABOUT Y, pronouns,TAKE ALL, and direction abbreviations. - An unlockable Guide: 20 comic entries unlocked through exploration, conversation, and story progress. Read them any time with
GUIDE. - Death without dead ends: dying rewinds one turn and restores the state from before the fatal choice. There are no unrecoverable failures.
- Hints never cost points:
HINTonly affects the Guide's opinion of you, never your score. - Scoring and ranks: 100 points per act, 300 in total. Your final score determines your rank and unlocks achievements.
- Multiple endings: two political paths in Act II and two final choices in Act III. Every choice is worth full marks, and every choice has consequences.
- Saves: JSON format. Source runs keep saves in
saves/; installed copies use the platform's user-data directory (on Windows,%LOCALAPPDATA%\foundation-guide\saves). Override it withFOUNDATION_GUIDE_SAVE_DIR. The game autosaves between acts and lets you save at any time. - Standard library only: no third-party dependencies. Clone it and run.
Walkthrough and Tests
The full walkthrough is in walkthrough.md, with recommended routes for all three acts, both endings, and a scoring breakdown. It contains heavy spoilers; play the game once first.
Run the automated tests:
uv run python -m unittest discover -s tests -v
The current suite covers:
- parser behaviour: directions, compound verbs, articles, pronouns,
USE ... ON ...,SET ... TO ..., and more - integrity of all three worlds: exits, object placement, NPC placement, and Guide entries
- the 100-point route through Act I
- both Act II endings, "faith" and "trade", at 100 points each
- both Act III endings, the quiet shot and the silence, at 100 points each
- a continuous three-act run at 300 points
- hints not costing points, death rewind, save/load, and Guide lookup
You can also play the full script directly to watch the whole story:
uv run python -m foundation_guide --script tests\walkthrough_full.txt --no-color
Project Structure
foundation-guide/
├─ foundation_guide/
│ ├─ __main__.py command-line entry point and menu
│ ├─ engine.py game loop, command dispatch, scoring, saves
│ ├─ model.py Room / Object / NPC / Exit / World data model
│ ├─ state.py serialisable ActState and Meta state
│ ├─ parser.py forgiving English command parser
│ ├─ ui.py terminal output, wrapping, colour, script mode
│ ├─ guide.py 20 Guide entries
│ └─ episodes/
│ ├─ act1.py Act I: The Psychohistorians
│ ├─ act2.py Act II: The Mayors
│ └─ act3.py Act III: The Mule
├─ tests/
│ ├─ test_game.py automated tests
│ ├─ walkthrough_*.txt act-by-act and full-game scripts
│ └─ run_act.py single-act debugging runner
├─ saves/ save directory for source runs
├─ pyproject.toml
├─ play.bat
├─ walkthrough.md
└─ README.md
Design Notes
The game is data-driven. Each act is a World containing rooms, objects, NPCs, and exits. All mutable state lives in ActState, so saving, loading, and undo are just serialisation and snapshots. NPC dialogue, puzzle conditions, and scoring events are callbacks attached to the data objects, keeping story logic separate from the engine.
The prose aims for a mixture of the two authors: Asimov's historical scale and political logic, plus Adams' footnotes, bureaucratic absurdity, and a towel that should never be underestimated.
Credits
- Story and characters from Isaac Asimov's Foundation trilogy.
- Comic style inspired by Douglas Adams' The Hitchhiker's Guide to the Galaxy.
- A non-commercial fan work, made for learning and entertainment.
So don't panic. Bring a towel. History is watching.
Metadata
Release files for foundation-guide 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| foundation_guide-1.0.0.tar.gz | 128.1 kB | Without provenance | Details for foundation_guide-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| foundation_guide-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for foundation_guide-1.0.0-py3-none-any.whl |
Total release size: 251.4 kB
Release files / foundation_guide-1.0.0.tar.gz
| Download URL | foundation_guide-1.0.0.tar.gz |
|---|---|
| Size | 128.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08166ba2e315501f64ad75bc3faebb2109a1a72a59eba7e418e1c81c21ffc99f
|
|
BLAKE2b-256 checksum How to use checksums |
285f4f52605c0a7f363d6d17f613b8189ea91de8fadc434278230d76bc709a5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / foundation_guide-1.0.0-py3-none-any.whl
| Download URL | foundation_guide-1.0.0-py3-none-any.whl |
|---|---|
| Size | 123.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb434f00bcaf5899bd74bcc882b4af82c28f547a15ece7837058619d109ba862
|
|
BLAKE2b-256 checksum How to use checksums |
5d0a5797ed741a7351a936a5e180e93903466cacadeaf285850278e07b20adfa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for foundation-guide 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.