← Back to all projects← 返回所有项目
EECE 2140 · Computing Fundamentals for Engineers工程师计算基础

Smart Traffic Intersection Simulator智能交通路口模拟器

Software & Algorithms软件与算法 · Spring 20262026 年春
C++OOP / CompositionState Machinesstd::dequeDiscrete-Event SimGit / GitHub

Overview项目概述

A discrete-time C++ simulation of a two-way signalized intersection, built to study congestion and how emergency vehicles can clear traffic. An object-oriented engine of seven classes models vehicle kinematics, traffic-light state machines, lane queues, and an adaptive emergency-vehicle override — rendering a live terminal animation and an end-of-run statistics report.一个用 C++ 编写的离散时间双向信号灯路口模拟器,用于研究交通拥堵以及紧急车辆如何疏导交通。由七个类组成的面向对象引擎对车辆运动学、交通灯状态机、车道队列以及紧急车辆优先放行机制进行建模,并实时渲染终端动画和运行结束后的统计报告。

The Problem问题背景

Congestion and accidents at intersections are increasingly common, and it is neither safe nor practical to experiment on real roads. We built a simulator as a safe sandbox to observe intersection dynamics and test tricky scenarios — in particular, how an emergency vehicle can be given priority to pass through heavy traffic without delay.路口的拥堵和事故日益频繁,而在真实道路上做实验既不安全也不现实。我们因此构建了一个模拟器作为安全的“沙盒”,用以观察路口动态并测试各种棘手场景——尤其是如何让紧急车辆获得优先权、在繁忙车流中畅通无阻。

How It Works工作原理

A central clock drives the whole simulation forward in discrete time steps ("ticks"):一个中央时钟以离散的时间步(“tick”)推动整个模拟:

Object-Oriented Design面向对象设计

The engine is organised into seven single-responsibility classes built around composition:引擎由七个职责单一的类组成,并围绕“组合”关系构建:

Collaboration & Results协作与成果

Built by a three-person team using an iterative process — requirements, then pseudocode, then implementation — all version-controlled in a shared GitHub repository with descriptive commits. A sample 100-tick run processed 30 vehicles and 4 emergency vehicles with a peak queue length of 5. Planned extensions include an SFML 2-D graphical interface, a four-way intersection with turn lanes, and crosswalk logic.由三人团队采用迭代流程完成——先确定需求,再编写伪代码,最后实现——全程在共享的 GitHub 仓库中进行版本管理并附带清晰的提交说明。一次 100-tick 的示例运行处理了 30 辆车和 4 辆紧急车辆,峰值队列长度为 5。后续计划包括基于 SFML 的二维图形界面、带转向车道的四向路口,以及人行横道逻辑。

Gallery图库

Click any image to enlarge.点击任意图片可放大。

×❮
❯