Inspiration

Most traffic lights still run on fixed timers: the same green for an empty street and a packed one, the same wait for pedestrians, and an ambulance is just another car. We had two earlier projects that fit together: a traffic monitoring system (YOLOv8 + CARLA) , where small recurrent "brains" are improved by evolution. SignalGrid joins them: a neural signal controller that is evolved by simulation, fed by computer vision, and always kept safe by hard rules.

What it does

SignalGrid (FT-01 Smart Traffic Signal Optimisation, team Singlet) is an adaptive signal-control platform with a 3D city you can orbit and manage.

  • 3D simulation: one junction or a 3x3 grid with cars, buses, pedestrians, ambulances and crashes. Switch between Fixed Timer, Adaptive AI, Evolved AI or Manual on the same traffic and watch queues, phases and a live score against a hidden fixed-timer city.
  • Training Lab: real neuroevolution running live in your browser (Web Workers). Watch fitness climb generation by generation and deploy your own champion.
  • Vision Monitor: upload a traffic video, use a camera, or stream a CARLA camera. YOLOv8 detects and tracks vehicles and pedestrians, flags queued cars, and the neural agent turns the lane counts into a recommended green phase.
  • CARLA bridge: the same evolved network drives the real traffic lights of a CARLA junction.
  • Results: Fixed vs Adaptive vs Evolved on 8 scenarios, with identical traffic for every controller.

How we built it

  • Traffic engine (pure JavaScript): IDM car-following, two-lane approaches, 4-phase signals, pedestrian crossings, ambulances, crashes and grid spill-back. The same code runs in the browser and in Node, so benchmarks are reproducible.
  • Agent: a 38-sensor, 28-interneuron, 6-output recurrent rate network with excitatory/inhibitory neurons, inspired by the Fly Dungeon brain (not the real fly connectome). It chooses the phase, whether to hold, and the green duration.
  • Neuroevolution: tournament selection, crossover, sparse Gaussian mutation, adaptive step size. Fitness comes from running the simulator:

$$\text{fitness}=\frac{100}{1+\text{cost}},\quad \text{cost}=\sum_i w_i\,\tilde m_i$$

over waiting time, queue, throughput, pedestrian wait, ambulance delay and signal switching.

  • Safety layer: minimum green, amber, all-red, pedestrian clearance, maximum green and starvation protection wrap every controller. The AI proposes; the safety layer decides. A test checks this at every step of 24 runs.
  • Vision: YOLOv8n plus a Hungarian-assignment tracker and collision heuristic adapted from our earlier project, with an OpenCV fallback and a FastAPI backend.
  • Delivery: static web app (Netlify), Python backend for vision, and a Windows .exe.

Results (simulated, 8 held-out seeds x 8 scenarios)

Metric Fixed Timer Evolved AI
Avg waiting time 61.3 s 50.9 s (-17%)
Pedestrian waiting 23.2 s 14.3 s (-38%)
Ambulance delay 83.3 s 53.3 s (-36%)
Signal efficiency 89% 95%

These are simulator results, not real-world measurements.

Challenges

  • Our first evolved agent was not better than the hand-wired seed. Training on scenarios that matched the benchmark presets, and weighting pedestrians and ambulances properly, fixed that.
  • Honest trade-offs: the AI does not shorten queues and changes phase about 27% more often than the fixed timer.
  • Making the Python (CARLA) version of the network match the JavaScript one exactly: the JS updates neurons in place, in sequence; after matching that, outputs agree to 2e-7.
  • CARLA 0.9.16 aborts if the traffic manager is shut down in the wrong order.

Accomplishments we're proud of

  • A controller that is evolved, measured and safe, and a benchmark anyone can reproduce with node tools/benchmark.mjs.
  • One network driving both our simulator and real CARLA traffic lights, with YOLO running on the CARLA camera in the web UI.
  • Live in-browser evolution at about one generation per second.

What we learned

Reactive control already captures most of the gain; evolution's value was discovering pedestrian and ambulance handling automatically. Fair comparisons need identical traffic, held-out seeds, and reporting the metrics where you lose.

What's next

Multi-agent coordination for green waves, a CARLA-trained detector (the data and training script are written), real camera calibration for lane-level counts, and an emergency-vehicle classifier.

Built with

JavaScript, Three.js, Web Workers, Python, FastAPI, YOLOv8 (Ultralytics), OpenCV, SciPy, NumPy, CARLA 0.9.16, PyInstaller, Netlify.

AI tools disclosure

Built with Claude Code (Anthropic) as a coding assistant under the team's direction. No ChatGPT, GitHub Copilot or Cursor.

Built With

Share this project:

Updates

Submission history