Pachislo Game Simulator
A Rust-based simulation library for Japanese pachislo (slot machine) games, featuring configurable probability systems, realistic game state management, and extensible user interfaces.
Features
- Comprehensive Game State Management: Support for Uninitialized, Normal, and Rush game modes with seamless transitions
- Advanced Lottery System: Realistic probability-based lottery with configurable win/loss rates and fake results
- Sophisticated Slot Result Generation: Multi-reel slot machine simulation with customizable symbols and patterns
- Extensible Command System: Flexible command pattern architecture for game control and flow management
- Trait-based Interface Architecture: Generic input/output system supporting multiple UI implementations
- Rush Mode Mechanics: Advanced rush continuation system with decay probability functions
- Ball Management System: Comprehensive ball tracking with configurable rewards and increments
Game Modes
Normal Mode
- Standard pachislo gameplay with configurable base win probability
- Ball consumption and management with incremental rewards
- Automatic transition to Rush mode upon winning lottery
- Support for fake win/lose results to enhance realism
Rush Mode
- Enhanced win probability during rush periods (default: 48% vs 16% in normal mode)
- Dynamic rush continuation system with decreasing probability over time
- Bonus ball distribution system with rush-specific increments
- Configurable rush continuation decay function
Architecture
The simulator is built around several core components:
Game<I, O>: Main game controller with generic input/output interfacesGameState: State machine managing game progression (Uninitialized → Normal → Rush)Lottery: Advanced probability-based system handling win/loss determination with fake resultsSlotProducer<T>: Configurable slot machine result generator supporting custom symbolsLaunchBallFlowProducer: Manages ball launch mechanics and start hole probabilityConfig: Comprehensive configuration system for all game parameters
Quick Start
use ;
// Create game with your input/output implementations
let mut game = new.unwrap;
// Run the game loop
game.run;
Configuration
The game supports extensive configuration through the Config struct:
Ball Configuration
BallsConfig
Probability Configuration
Probability
Commands
The simulator supports the following command system:
StartGame: Initialize a new game session from uninitialized stateLaunchBallFlowProducer: Advanced ball launching with start hole probabilityFinishGame: End the current game session gracefullyCommand::FinishGame: Force terminate the game loop
Example: CLI Implementation
The project includes a complete CLI example demonstrating all features:
// Run the CLI example
cargo run --example cli
Controls:
s- Start new gamelorEnter- Launch ballq- Finish current gameq!- Force quit
Extending the Simulator
Custom Input/Output Implementation
Implement the UserInput<O> and UserOutput traits:
Custom Slot Symbols
Create slot machines with custom symbols:
let slot_producer = new;
Project Structure
pachislo/
├── src/
│ ├── lib.rs # Main library exports and example config
│ ├── game.rs # Core game logic and state management
│ ├── command.rs # Command pattern implementation
│ ├── config.rs # Configuration structures
│ ├── interface.rs # User input/output traits
│ ├── lottery.rs # Lottery probability system
│ └── slot.rs # Slot machine result generation
├── examples/
│ └── cli.rs # Complete CLI implementation
├── tests/ # Comprehensive test suite
└── Cargo.toml # Project configuration
Dependencies
rand 0.9.1: High-quality random number generation for lottery and slot systems
Development
# Run tests
# Run CLI example
# Build documentation
# Check code formatting
# Run clippy linting
License
This project is licensed under the terms specified in the LICENSE file.
Contributing
Contributions are welcome! Please ensure all tests pass and follow the existing code style.