Skip to main content

Colossal Cave Adventure over Gemini

Project description

Colossal Cave Adventure over Gemini

A faithful port of the classic 350-point Colossal Cave Adventure (Crowther & Woods, 1977) served over the Gemini protocol. Players explore the cave, solve puzzles, and collect treasure — all through a Gemini client.

Built with xitzin (a Gemini web framework) and nauyaca (a Gemini server).

Features

  • Full 350-point game with all rooms, items, puzzles, and encounters from the original
  • Player authentication via Gemini client certificates
  • Per-player game state persisted in SQLite
  • Dwarf and pirate encounters with faithful AI behavior
  • Structured logging with optional fingerprint hashing for privacy

Quickstart

Requires Python 3.13+ and uv.

# Install dependencies
uv sync

# Generate TLS certificates (required for Gemini)
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 \
  -days 365 -nodes -keyout key.pem -out cert.pem \
  -subj "/CN=localhost"

# Start the server
ADVENTURE_CERTFILE=cert.pem ADVENTURE_KEYFILE=key.pem uv run adventure

Then connect with any Gemini client to gemini://localhost:1965/.

Configuration

All settings are read from environment variables prefixed with ADVENTURE_:

Variable Default Description
DATABASE_URL sqlite:///./adventure.db SQLite database path
HOST localhost Bind address
PORT 1965 Bind port
CERTFILE Path to TLS certificate (required)
KEYFILE Path to TLS private key (required)
LOG_LEVEL INFO Logging level
LOG_FILE Log to file instead of stdout
JSON_LOGS false Output logs as JSON
HASH_FINGERPRINTS true Hash client fingerprints in logs for privacy

Project Structure

src/adventure/
├── engine/          # Synchronous, pure-Python game logic
│   ├── world.py     # Immutable data structures (Room, Obj, Word, Hint, World)
│   ├── state.py     # Mutable GameState (position, inventory, lamp, dwarves, score)
│   ├── loader.py    # Parses the 12-section advent.dat into a World
│   └── commands.py  # Command dispatch: movement, items, puzzles, combat, scoring
├── routes/          # Xitzin route handlers
│   ├── play.py      # Game routes (require client certificate)
│   └── home.py      # Public pages: /, /help, /about
├── templates/       # Jinja2 .gmi templates for Gemtext responses
├── app.py           # App factory
├── config.py        # Configuration from environment variables
├── logging.py       # structlog setup
├── models.py        # SQLModel entities (Player, SavedGame)
├── session.py       # Load/save/reset game state from DB
└── users.py         # Player upsert by fingerprint
data/
└── advent.dat       # Original game data file

Development

# Run tests
uv run pytest

# Lint and format
uv run ruff check src/ tests/
uv run ruff format src/ tests/

# Type check
uv run ty check src/

Credits

  • Original game: Will Crowther (1976) and Don Woods (1977)
  • Data file format: Public domain
  • Parsing reference: Brandon Rhodes' python-adventure (Apache 2.0)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adventure_gemini-0.1.3.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adventure_gemini-0.1.3-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file adventure_gemini-0.1.3.tar.gz.

File metadata

  • Download URL: adventure_gemini-0.1.3.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for adventure_gemini-0.1.3.tar.gz
Algorithm Hash digest
SHA256 996e0e2b6e1441aa1c3799cd6fa1504d2d8db7d8e70852b7b054c1ac49436c03
MD5 ce7f2453e64952bedc8d01528086b74a
BLAKE2b-256 27db797ebfe7422f38f691bcbb7058920a65c6e42dda14d666e56e8f5574441d

See more details on using hashes here.

Provenance

The following attestation bundles were made for adventure_gemini-0.1.3.tar.gz:

Publisher: release-pypi.yml on alanbato/adventure-gemini

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file adventure_gemini-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for adventure_gemini-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fa4aeb6a83d3fd9dcddc23403266a03c1f480769ba3ccc7da0bb4f134de4db5c
MD5 6b1adfe11e14c245c1eef5216ff20457
BLAKE2b-256 a05c68e6aa95133aeac03419284643f9cf3fed9ede5ed0314ed2e5ac770d7745

See more details on using hashes here.

Provenance

The following attestation bundles were made for adventure_gemini-0.1.3-py3-none-any.whl:

Publisher: release-pypi.yml on alanbato/adventure-gemini

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page