/Basic-Traffic-Intersection-Simulation

A simulation developed from scratch using Pygame to simulate a 4-way traffic intersection having traffic lights with timer.

Primary LanguagePythonMIT LicenseMIT

Simulation output

Basic Traffic Intersection Simulation

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.


Description

  • It contains a 4-way traffic intersection with traffic signals controlling the flow of traffic in each direction.
  • Each signal has a timer on top of it which shows the time remaining for the signal to switch from green to yellow, yellow to red, or red to green.
  • Vehicles such as cars, bikes, buses, and trucks are generated, and their movement is controlled according to the signals and the vehicles around them.
  • This simulation can be further used for data analysis or to visualize AI or ML applications.

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/Basic-Traffic-Intersection-Simulation
  • Step II: Install the required packages
      # On the terminal, move into Basic-Traffic-Intersection-Simulation directory
      $ cd Basic-Traffic-Intersection-Simulation
      $ 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.