I create an guided and solved assignment in which I show how to calculate the relevant statistics for a game in which you draw two coins and bet on the number of tails. The scope is to show Monte Carlo methods in gaming application. The code is written in C++ and use class. The RNG is a Mersenne Twister taken from Standard Library. The user can vary the number of simulations. Please provide a lightweight readme to insert in this repository.
Assistant
Monte Carlo Simulation for Coin Toss Game
This repository provides a guided and solved assignment that demonstrates how to calculate relevant statistics for a game where you draw two coins and bet on the number of tails. The focus is to showcase Monte Carlo methods in gaming applications using C++ with object-oriented programming.
Features
Simple Game Simulation: Two coins are drawn, and you bet on the number of tails.
Monte Carlo Method: Utilizes the Monte Carlo simulation technique to calculate probabilities and statistics.
Object-Oriented Design: Implements C++ class structures for better code organization.
Random Number Generation: Employs the Mersenne Twister engine from the C++ <random> Standard Library.
Customizable Simulations: Allows users to modify the number of simulations to adjust the precision and computation time.
Prerequisites
A C++ compiler that supports C++11 or later.
Basic understanding of C++ programming.
Familiarity with Monte Carlo methods is beneficial but not required.
Getting Started
Clone the Repository:
bash
git clone https://github.com/your-username/coin-toss-monte-carlo.git
cd coin-toss-monte-carlo
Compile the Code:
Use the following command to compile the project.
bash
g++ -std=c++11 main.cpp -o coin_toss_simulation
Run the Simulation:
Execute the compiled program and specify the number of simulations.
bash
./coin_toss_simulation
Modify the Number of Simulations:
To experiment with different sample sizes, modify the relevant parameters in the main function or via command-line arguments if implemented.
Code Structure
main.cpp: Contains the main logic for setting up and running the Monte Carlo simulation.
CoinGame.h / CoinGame.cpp: Defines the CoinGame class, which encapsulates the logic for simulating the coin toss game including the betting logic and statistics calculation.
RandomGenerator.h / RandomGenerator.cpp: Handles the setup and generation of random numbers using the Mersenne Twister engine.
Example Usage
Inside main.cpp, you will find an example of how to set up the game and run simulations with customizable parameters. You can follow this example or modify it to suit your needs.
Contribution
Contributions to enhance this project are welcome. Feel free to fork the repository and submit pull requests with improvements.
License
This project is licensed under the MIT License. See the LICENSE file for details.