Skip to content

This project implements a Monte Carlo simulation to estimate the value of Pi, using random sampling of points within a square and an inscribed circle. The simulation visualizes the process in real-time with SDL2, showing points inside the circle in red and outside in green.

Notifications You must be signed in to change notification settings

acboujida/simulation-pi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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>
    

About

This project implements a Monte Carlo simulation to estimate the value of Pi, using random sampling of points within a square and an inscribed circle. The simulation visualizes the process in real-time with SDL2, showing points inside the circle in red and outside in green.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published