hammurabi

Crates.iohammurabi
lib.rshammurabi
version0.1.2
created_at2025-06-16 13:37:17.291448+00
updated_at2025-06-20 07:07:32.529049+00
descriptionA modern terminal-based recreation of the classic 1968 Hammurabi game
homepage
repositoryhttps://github.com/stjepangolemac/hammurabi
max_upload_size
id1714294
size139,081
Stjepan Golemac (stjepangolemac)

documentation

README

👑 Hammurabi

A modern terminal-based recreation of the classic 1968 BASIC game "Hammurabi" (originally "The Sumer Game"), written in Rust with a beautiful TUI interface.

Rust Terminal License: MIT

🏛️ About

Step into the sandals of ancient Babylon's mighty ruler! As Hammurabi, you must wisely manage your kingdom's resources through ten years of tribulation. Buy and sell land, plant crops, and feed your people while navigating the unpredictable forces of nature.

This implementation features:

  • 🎨 Beautiful terminal UI with responsive design
  • 🎲 Deterministic gameplay with optional seeded randomness
  • 📜 Authentic old English narrative style
  • 🌾 Classic resource management mechanics
  • 🏆 Performance evaluation after your reign

📸 Screenshots

Hammurabi Splash Screen

🚀 Installation

Download Pre-built Binary (Recommended)

Download the latest release for your platform from the releases page:

  • Windows: hammurabi-windows-amd64.zip
  • macOS (Intel): hammurabi-macos-amd64.tar.gz
  • macOS (Apple Silicon): hammurabi-macos-aarch64.tar.gz
  • Linux: hammurabi-linux-amd64.tar.gz

Extract and run:

# macOS/Linux
tar -xzf hammurabi-*.tar.gz
./hammurabi

# Windows
# Extract the zip file and run hammurabi.exe

From crates.io

If you have Rust installed:

cargo install hammurabi

From source

git clone https://github.com/stjepangolemac/hammurabi.git
cd hammurabi
cargo install --path .

🎮 How to Play

Starting the Game

hammurabi              # Start with random seed
hammurabi --seed 42    # Start with specific seed for reproducible gameplay

Gameplay

You rule for 10 years, making three crucial decisions each year:

  1. Land Management 🏛️

    • Buy or sell land (prices fluctuate between 17-26 bushels per acre)
    • More land = more potential crops
    • Enter negative numbers to sell
  2. Food Distribution 🍞

    • Each person needs 20 bushels per year to survive
    • Starving people will die!
    • Dead citizens can't work your fields
  3. Crop Planting 🌾

    • Each acre requires 1 bushel of grain for seed
    • Each person can work up to 10 acres
    • Harvest yields vary from 1-5 bushels per acre

Random Events

  • 🌾 Harvests: Yields vary based on weather conditions
  • 🐀 Rats: May eat 10-30% of your stored grain
  • 💀 Plague: Has a 15% chance to kill half your population
  • 👥 Immigration: New citizens arrive if you govern well

Winning

After 10 years, your performance is evaluated based on:

  • Average starvation rate
  • Population growth
  • Land per citizen

Achieve greatness and be remembered alongside history's finest leaders!

🛠️ Features

  • Responsive Design: Adapts to terminal sizes (optimized for 80x24 and larger)
  • Message Variety: 10 unique variations for each game message
  • Historical Atmosphere: Old English style text and period-appropriate language
  • Clean UI: Minimalist design focusing on readability
  • Deterministic Randomness: Use seeds for speedrun competitions or debugging

📋 Requirements

  • Rust 1.70 or higher
  • Terminal with UTF-8 support
  • Minimum terminal size: 40x20 (recommended: 80x24)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🎯 Roadmap

  • Add difficulty levels
  • Implement save/load functionality
  • Add achievements system
  • Create web assembly version
  • Add sound effects (optional)
  • Localization support

🙏 Acknowledgments

  • Original BASIC game by Doug Dyment (1968)
  • Inspired by David Ahl's version in "BASIC Computer Games" (1978)
  • Built with Ratatui TUI framework
  • ASCII art generated with tui-big-text

📚 Historical Note

The original Hammurabi game was one of the first strategy/resource management games ever created. It was written in BASIC in 1968 and became widely popular after being published in David Ahl's "BASIC Computer Games" book. This implementation stays true to the original mechanics while providing a modern, polished terminal experience.


Made with ❤️ and Rust

Commit count: 37

cargo fmt