Traffic Light Controller Game

Train adaptive signals, manage unpredictable traffic, compare control strategies, and discover how reinforcement learning can keep busy intersections moving safely and efficiently every day.

Current result

Simulation ready

Paused Phase: North–South Controller: Q-learning
Score0
Waiting0.0 s
Queue0
Cleared0
Reward0.0
Emissions0.0

Live intersection simulation

Green movement Waiting traffic E = emergency P = pedestrian request Keyboard: Space pause, 1–6 phases

Game and training controls


Manual signal decisions


Learning parameters

Reward designer

Simulation options

Traffic arrival rates and custom scenario

Plotly performance dashboard

Analytics explorer

Controller comparison

ControllerRewardWaitingQueueClearedGridlocks
Trained agent
Fixed timing
Random controller

Achievements

Results, reports, and policy tools

Latest episode report

Run an episode to create a detailed report.

Event log

How the learning game works

How to play

  1. Select a traffic scenario and controller.
  2. Adjust learning, signal, and reward settings.
  3. Start training and watch queue behaviour.
  4. Test the learned policy without exploration.
  5. Compare it against fixed and random controllers.

Learning concepts

State combines queue levels and the active phase. Action changes or preserves a safe signal phase. Reward values throughput while penalising congestion.

Exploration tests alternatives. Exploitation uses learned values. The discount factor controls how strongly future traffic outcomes matter.


Example scenario

DirectionArrival rateTypical queueRecommended response
North–SouthHigh12–20 vehiclesLonger green with switch protection
East–WestMedium6–10 vehiclesRegular service to maintain fairness
PedestriansLowOccasional requestServe before excessive waiting develops

Frequently asked questions

What is the agent learning?

It learns which safe signal phase best matches different queue conditions.

Why can rewards become negative?

Waiting, queues, emissions, gridlock, and excessive switching create penalties.

What does exploration change?

Exploration makes the agent try uncertain actions instead of always using its current favourite.

How is gridlock detected?

The game flags gridlock when queues become very large across several directions.

Can I control signals manually?

Yes. Select Manual controller and use the phase buttons or number keys.

Are dangerous signal combinations possible?

No. The simulation uses mutually exclusive phases and an all-red transition.

Can a learned policy be saved?

Yes. Policies can be stored locally, exported, and imported as JSON.

How should I compare controllers?

Use identical traffic rates and compare waiting, queues, reward, throughput, and gridlock incidents.

Does this simulate real traffic engineering?

It is an educational approximation, not a certified traffic-control or road-safety system.

Related Calculators

Maze Learning AgentGrid World ExplorerRobot Navigation ChallengeTreasure Hunt AgentMulti-Armed Bandit GameCart Balancing ChallengeEnergy Management AgentWarehouse Robot GameAdaptive Game Opponent

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.