This project demonstrates the Monte Carlo method for estimating the value of Pi using SDL2 for graphical visualization. It simulates random points within a square and checks how many fall within a circle, providing a graphical view of the simulation as it progresses.
- Monte Carlo Simulation: Estimates Pi by generating random points within a square and counting how many fall inside a circle.
- Real-Time Visualization: Uses SDL2 to render the points and show the real-time Pi approximation.
- Pause/Resume: You can pause the simulation with the spacebar and resume it by pressing it again.
- SDL2: Graphics library used for rendering.
- SDL2_ttf: For displaying text on the screen.
- g++: Compiler for building the project.
- Font: Make sure the required font is available (DejaVuSans-Bold.ttf is used).
To build the project, use the provided build.sh
script. It compiles the source code with the necessary libraries.
- Run the build script:
./build.sh simPi.cpp <output>
- Execute the program by running (if no argument is provided, the default value is 10,000 point):
./<output> <number_of_points>