| Crates.io | deadwood |
| lib.rs | deadwood |
| version | 0.1.8 |
| created_at | 2025-11-03 02:15:12.487418+00 |
| updated_at | 2025-11-06 05:03:13.966106+00 |
| description | Gin Rummy TUI featuring full knock, gin, and undercut rules with an algorithmic bot opponent. |
| homepage | https://github.com/fn/deadwood |
| repository | https://github.com/fn/deadwood |
| max_upload_size | |
| id | 1913784 |
| size | 100,173 |
Deadwood is a terminal user interface (TUI) implementation of Gin Rummy written in Rust. It delivers a full single–player experience against an algorithmic bot, complete with proper Gin scoring, knock/deadwood rules, and a responsive Crossterm/Ratatui front end.
Clone the repository and build the project:
git clone https://github.com/fibnas/deadwood.git
cd deadwood
cargo build
cargo run
The game launches directly into the TUI. Resize the terminal as needed; Ratatui adapts to larger viewports.
On first launch Deadwood writes a config file to your OS config directory (for example ~/.config/deadwood/config.toml). You can tweak these options:
persist_stats – keep cumulative scores and the latest round summaries between runs (creates session.json alongside the config).auto_brackets – toggle automatic braces around detected melds/runs in your hand view.[suit_colors] – override suit colours with recognised names (Red, Blue, …), #RRGGBB hex strings, or rgb(r,g,b) values.There is a starter template at config.example.toml; copy or adapt it for your setup.
Game controls change depending on the current phase, and the status panel always reminds you what to press.
| Phase | Keys |
|---|---|
| Menu / Round over | Enter/n – start next round · ? – rules · q/Esc – quit |
| Draw phase | s – draw stock · d – draw discard · ? – rules · q/Esc – quit |
| Discard / knock phase | ←/→ or h/l – move selector · Enter/Space – discard · k – toggle knock intent · ? – rules · q/Esc – quit |
Deadwood follows standard Gin Rummy rules:
Deadwood values: Ace = 1, 2–9 = face value, 10/J/Q/K = 10.
The engine searches all valid combinations of runs (same suit, sequential ranks) and sets (same rank). When a knock occurs, the opponent is allowed to lay off deadwood onto the knocker’s melds, extending runs or sets when legal. These mechanics are handled automatically and reflected in the round summary.
The bot evaluates both drawing sources, simulates discard outcomes, and will knock based on configurable difficulty thresholds (default: Challenging). On the easier setting it occasionally injects randomness to appear less perfect. All logic lives in src/bot.rs.
src/
├─ main.rs # Terminal bootstrap, event loop
├─ app.rs # App state machine, input handling, round orchestration
├─ ui.rs # Ratatui rendering functions
├─ cards.rs # Card, rank, suit types and helpers
├─ meld.rs # Meld detection, deadwood analysis, layoff logic
├─ game.rs # Core Gin Rummy rules, scoring, turn phases
└─ bot.rs # Bot strategy and difficulty helpers
Issues and PRs are welcome. Please format with cargo fmt and ensure cargo check passes before submitting.
Deadwood is released under the MIT License.