|
|
||
|---|---|---|
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
README.md
ShoddyCast Graveler Soft Lock
The inspiration for this project comes from a YouTube video by ShoddyCast where he explores a soft lock scenario in the Pokémon Fire Red/Leaf Green games.
This project simulates rolling a virtual die to determine the maximum number of consecutive rolls resulting in the number 4. The simulation is run in parallel across multiple iterations to improve performance. The project leverages the Xoshiro256++ pseudorandom number generator (PRNG) and the Rayon library for multi-threading.
Features
- High-Performance Random Number Generation: Uses the Xoshiro256++ algorithm for fast and statistically sound random number generation.
- Parallel Processing: Utilizes the Rayon library to perform simulations concurrently across multiple threads, speeding up the computation.
- Detailed Timing: Measures and outputs the time taken to complete the simulation, broken down into days, hours, minutes, seconds, and milliseconds.
Prerequisites
- Rust: Ensure that you have Rust installed on your system. If not, you can install it from rust-lang.org.
Running the Code
- Clone the Repository:
git clone https://github.com/your-username/random-dice-simulation.git
cd random-dice-simulation
- Build the Project:
cargo build --release
- Run the Simulation:
cargo run --release
This will start the simulation with 1,000,000 iterations. The program will output the highest number of consecutive rolls resulting in the number 4, along with the time taken to complete the simulation.
Configuration
- Total Iterations: You can modify the total_iterations variable in the main function to change the number of simulations performed.
- Random Number Generator: The code uses the Xoshiro256++ RNG, initialized with a seed of 1234. You can change the seed in the Xoshiro256PlusPlus::initialize_states call if needed.
Code Structure
- main.rs: Contains the main simulation logic, including RNG initialization, parallel processing, and timing.
- roll_dice function: Simulates rolling a virtual die and returns a value between 0 and 3, with 4 being treated as 0 for simplicity.
- TimerResult struct: Converts and stores the duration of the simulation in a human-readable format.
Example Output
Highest number of Ones: 7 (completed in 0 days, 0 hours, 0 minutes, 12 seconds, and 345 milliseconds)
Dependencies
- gpu_rand: For Xoshiro256++ random number generation.
- rayon: For parallel processing.
- anyhow: For simplified error handling.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
Contact
If you have any questions or issues, feel free to open an issue in the repository or contact the me at r0r-5chach.xyz@proton.me.