Inspiration

Traffic congestion and road accidents affect people every day, especially in growing cities where infrastructure struggles to keep up with demand. We were inspired by how inefficient fixed-timing traffic lights can be, particularly when one direction is overloaded while others remain empty. This inefficiency wastes time, increases emissions, and raises accident risk.

We also wanted to better understand how different real-world factors—such as traffic density, weather, time of day, and driver behavior—contribute to accident risk. By building an interactive simulation, our goal was to make smart traffic systems easier to understand, visualize, and experiment with, rather than keeping them as hidden or abstract technologies.

What it does

Our project is an interactive Smart City Traffic Intelligence Simulator that models adaptive traffic lights and accident risk at an urban intersection.

The application:

Simulates real-time vehicle movement from four directions

Dynamically adjusts traffic light timing based on traffic load

Allows users to toggle between smart mode and manual control

Predicts accident risk using user-selected environmental and behavioral factors

Visualizes risk through heatmaps and a city-wide risk map

Tracks traffic statistics and historical risk predictions

Users can directly see how adaptive traffic control improves traffic flow and how increased congestion or risky conditions raise accident risk.

How we built it

We built the project entirely in Java, using Java Swing and AWT for the user interface and Java2D for custom graphics and animations.

Key components include:

A real-time vehicle simulation with braking, queuing, and collision avoidance

A traffic light state machine with GREEN, YELLOW, and ALL_RED phases

Adaptive signal logic that selects the next green direction based on vehicle counts

A rule-based accident risk predictor combining traffic, weather, time of day, phone use, and road conditions

Multiple visualization panels, including an intersection view, heatmap, city map, statistics dashboard, and history log

The simulation runs using event-driven timers to separate traffic logic updates from animation rendering.

Challenges we ran into

One of the main challenges was synchronizing real-time animation with traffic logic while keeping the simulation smooth and responsive. Ensuring vehicles stopped correctly at red lights, avoided collisions, and resumed movement naturally required careful tuning.

Designing adaptive traffic logic that felt realistic without becoming overly complex was another challenge. We also needed to balance visual clarity with performance, especially when rendering multiple animated elements and panels simultaneously.

Accomplishments that we're proud of

Building a fully interactive traffic simulation rather than static visuals

Successfully implementing adaptive traffic light timing based on real-time demand

Creating clear visualizations that make traffic flow and accident risk easy to understand

Integrating traffic control, risk prediction, analytics, and visualization into one cohesive application

Designing a clean and intuitive UI that is both educational and engaging

What we learned

Through this project, we learned how small changes in traffic signal timing can have a large impact on congestion and flow. We also gained experience designing event-driven simulations, managing system state, and visualizing complex data in a way that is accessible to users.

Most importantly, we learned that transparency and visualization are essential when explaining smart infrastructure systems to the public.

What's next for DevPostHackathon: Code Spring - SmartCityTrafficApp

Future improvements include expanding the simulation to multiple connected intersections, adding pedestrian flow and crosswalk logic, and incorporating emergency vehicle prioritization. We also plan to explore machine learning–based accident risk prediction and the use of real-world traffic data to make the simulation more realistic and scalable.

Built With

Share this project:

Updates