Event-driven simulation of traffic flow through a 4-way intersection that is managed by a traffic light
This project will involve implementation of an event-driven simulation of traffic flow through a 4-way intersection that is managed by a traffic light. The simulation includes cars arriving at the intersection traveling in all four directions, as well as the light changing state throughout the simulation. After the simulation is complete, there is an output with very minimal statistics about the traffic flow.
- Use of Friend Functions / Classes
- Use of C++ "string" Type, pointers, and overloaded operators
- Use of makefile and multiple source code files
- Implementation of first-in-first-out queue and last-in-first-out stack classes
Project is created with:
- Visual Studio Code version 1.76.2
- C++98
To run this project:
$ cd ../traffic_simulation
$ make
$ g++ -std=c++98 -Wall traffic.o IntersectionSimulationClass.o EventClass.o random.o CarClass.o -o traffic_simulation.exe
$ valgrind --leak-check=full ./traffic_simulation.exe
Traffic simulation gif retrieved from: https://github.com/scmilburn/traffic_simulator/blob/master/traffic.gif