Skip to content

Latest commit

 

History

History
71 lines (52 loc) · 2.83 KB

File metadata and controls

71 lines (52 loc) · 2.83 KB

Simulation output

Traffic Intersection Simulation with Stats

Python version License: MIT

A simulation developed from scratch using Pygame to simulate the movement of vehicles across a traffic intersection having traffic lights with a timer. Some statistics and analytical features added to the previous version to help in Modelling problems, Data Analysis tasks, and AI applications.


Features added:

  • Vehicle counts - The number of vehicles that have crossed the intersection is displayed adjacent to each traffic signal for each direction.
  • Time Elapsed - The time elapsed since the start of the simulation is displayed at the top right.
  • Simulation Duration - The total duration of simulation or end time can be set. The simulation will quit automatically when the time elapsed is equal to the simulation duration.
  • Printing timers on Terminal - The timer values of all signals are printed on the Terminal every second. This is useful for effective debugging while customizing the simulation according to your application.
  • Printing cumulative statistics - Statistics like direction-wise vehicle counts, total vehicles, and simulation time are printed on the Terminal at the end of the simulation, as shown in the image below.

Stats

Find a step-by-step guide to build this simulation here.


Demo

The video below shows the final output of the simulation.


Prerequisites

Python 3.1+


Installation

  • Step I: Clone the Repository
      $ git clone https://github.com/mihir-m-gandhi/Traffic-Intersection-Simulation-with-Stats
  • Step II: Install the required packages
      # On the terminal, move into Traffic-Intersection-Simulation-with-Stats directory
      $ cd Traffic-Intersection-Simulation-with-Stats
      $ pip install pygame
  • Step III: Run the code
      # To run simulation
      $ python simulation.py

Author

Mihir Gandhi - mihir-m-gandhi


License

This project is licensed under the MIT - see the LICENSE file for details.