← All projects

Project / Data structures

3D Traffic Simulator

A modular C++20 traffic-flow simulator that models congestion, queues, adaptive signals, and live routing across configurable road-network scenarios.

C++20DijkstraGraphsJSON

Shortcut City scenario in the traffic flow optimization system

Overview

The simulator treats an urban road network as a directed graph: intersections are vertices, roads are edges, and vehicles move through the network in discrete simulation steps. It was created to explore how congestion, queueing, and signal decisions interact without the cost or risk of real-world deployment.

System design

The backend separates road-network storage, vehicle state, routing, traffic flow, metrics, JSON export, and simulation orchestration. The default test environment is a 6×6 grid of 36 intersections and 120 directed roads, with source nodes on the left edge and destinations on the right.

Adaptive traffic logic

Each vehicle follows a Dijkstra-based shortest path whose edge costs update with road occupancy and queues. At intersections, explicit queues hold vehicles until a green signal and downstream capacity permit discharge; the controller selects the incoming road with the greatest queue. This enables dynamic re-routing as traffic conditions change.

Results

Runtime metrics include congestion, throughput, objective score, and average travel time, with state snapshots exported as JSON. In the supplied performance log, the system reached regular arrivals after about 11 steps and stabilized around 0.12–0.15 average congestion, with throughput near 0.50–0.53 vehicles per step.

Image gallery

Video demonstration