Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 1.25 KB

README.md

File metadata and controls

26 lines (20 loc) · 1.25 KB

Monte Carlo Simulation of Pi with SDL2

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.

Features

  • 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.

Requirements

  • 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).

Building the Project

To build the project, use the provided build.sh script. It compiles the source code with the necessary libraries.

Usage

  1. Run the build script:
    ./build.sh simPi.cpp <output>
  2. Execute the program by running (if no argument is provided, the default value is 10,000 point):
    ./<output> <number_of_points>