Expand description
§bowling
A generic, typestate-driven bowling game engine that models the complete mechanics of bowling: multiple players, strikes, spares, fill balls, split detection, and per-pin deck tracking.
§Design highlights
-
Generic over ruleset via static dispatch. The
Rulesettrait defines pin count, frame count, deadwood policy, bonus scheme, and optional pin geometry. Three variants ship out of the box:TenPin,Candlepin, andDuckpin. -
Typestate state machines at both the frame and game level. Illegal transitions (e.g. rolling after the game is complete) are compile errors, not runtime panics.
-
Per-pin deck via
PinSet, a compactu16bitset. Split detection is powered byPinGeometryadjacency graphs, supplied per-ruleset.
§Quick start
use bowling::prelude::*;
// Build a single-player ten-pin game
let alice = Player::new("Alice").unwrap();
let mut progress = GameBuilder::<TenPin>::new(alice).build();
// Bowl a perfect game (12 strikes)
for _ in 0..12 {
match progress {
Progress::AwaitingRoll(g) => {
progress = g.roll_count(10).unwrap();
}
Progress::Complete(_) => break,
}
}
if let Progress::Complete(game) = progress {
assert_eq!(game.scoreboard(0).total, 300);
}Modules§
- error
- Error types for the bowling engine.
- frame
- Frame-level typestate machines for regular and final frames.
- game
- Game-level typestate machine with multiplayer turn rotation.
- geometry
- Pin geometry and split detection.
- pins
- Pin-deck representation as a compact bitset.
- player
- Player identity.
- prelude
- Convenience re-exports for the most commonly used types.
- roll
- A single delivery (roll) in a bowling game.
- ruleset
- Bowling ruleset abstraction and concrete implementations.
- scorecard
- Per-game score card for one player’s line.
- scoring
- Cumulative scoring engine.