/Traffic-Intersection-Simulation-with-Turns

A simulation developed from scratch using Pygame to simulate the movement of vehicles across a traffic intersection having traffic lights with a timer. Additional features such as turning vehicles and random green signal time added to existing basic simulation to take it closer to real-life scenarios.

Primary LanguagePythonMIT LicenseMIT

Simulation output

Traffic Intersection Simulation with Turns

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. Additional features added to existing basic simulation to take it closer to real-life scenarios and use it effectively in Data Analysis tasks or AI applications.


Features added:

  • Vehicle Turning Functionality - Unlike the previous simulation where all the vehicles went straight through the intersection, some of the vehicles will be turning left, some right, and some will go straight in the modified simulation.
  • Vehicle Type Controller - This feature lets us choose which vehicle types among car, bus, truck and bike we want in our simulation.
  • Random Green Signal Timer - If enabled, this feature sets the green signal time equal to a random number generated within a given range.

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