A ten-pin bowling simulation library for modeling games
Project description
VirtualLanes: Ten-Pin Bowling Simulation
VirtualLanes is an extensive simulation toolkit designed for modeling ten-pin bowling games. It offers a comprehensive suite of classes that simulate games, tournaments, leagues, and more, providing a realistic and detailed representation of bowling dynamics. The project also includes a scoring system compatible with various bowling rules, a database for persisting game results, and multiple interfaces (CLI, TUI, Web) for interacting with the library.
Features
- Simulation Classes: Simulate bowling games frame by frame or as complete games using different probabilities for strikes, spares, and opens.
- Scoring Systems: Includes traditional, current frame, and 9-pin no-tap scoring systems.
- Bowling Database: A SQLite database integration for storing and managing bowling games, bowlers, alleys, and tournaments.
- League and Tournament Support: Organize and run bowling tournaments and leagues with multiple games and multiple bowlers, customizable for different team sizes and frequencies.
- Multiple Interfaces:
- Command Line Interface (CLI): Using Typer for a rich command-line experience
- Terminal User Interface (TUI): Using Textual for an interactive terminal application
- Web Interface: Using FastHTML for a modern, responsive web application
- Documentation: Auto-generated API documentation using MkDocs for easy reference and usage.
Installation
Using pip
pip install virtual-lanes
From source
Clone the repository and install using pip or uv:
git clone https://github.com/michael-borck/virtual-lanes.git
cd virtual-lanes
# Using pip
pip install -e .
# Or using uv (recommended)
uv pip install -e .
Usage
As a Python Library
from virtual_lanes import Bowler, Game, Scoring
# Create a bowler
player = Bowler("John Doe", 180)
# Create a game
game = Game(player)
game.roll(10) # Strike
game.roll(5) # 5 pins
game.roll(5) # Spare
# Get the score
score = Scoring.calculate_score(game)
print(f"{player.name}'s score: {score}")
Command Line Interface (CLI)
VirtualLanes provides a command-line interface with various subcommands:
# Show CLI help
virtual-lanes --help
# Manage bowlers
virtual-lanes bowlers list
virtual-lanes bowlers add "John Doe" 180
# Manage games
virtual-lanes games list
virtual-lanes games add "John Doe" 210
# Start the Terminal UI
virtual-lanes tui start
# Start the Web Interface
virtual-lanes web start
Terminal User Interface (TUI)
Start the interactive terminal interface:
virtual-lanes tui start
Or from Python:
import virtual_lanes
virtual_lanes.run_tui()
Web Interface
Start the web server:
virtual-lanes web start --host 0.0.0.0 --port 8080
Or from Python:
import virtual_lanes
virtual_lanes.run_web(host="0.0.0.0", port=8080, debug=True)
Then open your browser at http://localhost:8080.
Documentation
Generate and view the documentation locally:
# Install development dependencies
uv pip install "virtual-lanes[dev]"
# or using pip
pip install "virtual-lanes[dev]"
# Serve the documentation
mkdocs serve
Development Setup
For a quick development setup with uv, run:
./setup_uv.sh
This will:
- Install uv if needed
- Create a virtual environment
- Install all dependencies
- Show usage instructions
Testing, Linting and Type Checking
Run tests using pytest:
pytest
Run linting with ruff:
ruff check src tests
Run type checking with mypy:
mypy src tests
Contributing
Contributions are welcome! Please read the contributing guide for directions on how to submit pull requests to the project.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file virtual_lanes-0.2.3.tar.gz.
File metadata
- Download URL: virtual_lanes-0.2.3.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4185ba45e275443e45f18fb2109dd7fe079cc60700cdc96bd2d83d6c1145f79
|
|
| MD5 |
f3a466d550799d68ae44c2d08f1d516e
|
|
| BLAKE2b-256 |
c36457476cf3a8df595e568effc5912ac38886a451481ee2e6b82110ce433a53
|
File details
Details for the file virtual_lanes-0.2.3-py3-none-any.whl.
File metadata
- Download URL: virtual_lanes-0.2.3-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45a74b0e88341d2c030d646038c8f8cfdc69875a0a6a8a91adce730ad04e9025
|
|
| MD5 |
448cbf6e1fe7425c380387c80471ae10
|
|
| BLAKE2b-256 |
756e3c4b400adc4cd14d0932c402ef86e0e6f9c0300fb40092a97e873df33d4d
|