Coder Social home page Coder Social logo

traffic_simulator's Introduction

Traffic Simulator

Overview

This project is a traffic simulator that aims to simulate the flow of traffic at an intersection. The simulation involves multiple cars moving in different lanes towards the intersection. The goal is to coordinate the movement of cars through the intersection without collisions, implementing traffic rules and prioritizing certain lanes.

Features

  • Each car is represented as a separate entity, and their movement is simulated using multiprocessing.
  • Rules of priority are implemented to control the passage of cars through the intersection.
  • The intersection is managed to coordinate the movement of cars and avoid collisions.
  • Time of arrival, waiting, and departure at the intersection are modeled.
  • The status of cars, movements at the intersection, and any potential race conditions are logged and displayed.

Project Components

  • Cars:

    • Each car is a separate entity moving towards the intersection.
    • Threads or processes represent individual cars.
  • Intersection

    • The main entity responsible for managing and coordinating the passage of cars.
    • Implements a semaphore algorithm to control the flow of traffic.
  • Semaphore Algorithm

    • Controls the passage of cars through the intersection.
    • Adjusts the green light duration based on the number of cars in the queue.
    • Supports dynamic priority based on certain conditions.
  • Monitoring and Reports

    • Displays the status of cars, movements at the intersection, and potential race conditions.

How to Run

  1. Clone the repository to your local machine.

  2. Ensure you have Python installed.

  3. Run the main program using the command: python traffic_simulator.py.

  4. Follow the on-screen prompts to start the simulation, view credits, or exit the program.

Credits

traffic_simulator's People

Contributors

rendrick27 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.