A comprehensive web-based traffic flow simulation built with Python (Flask backend) and JavaScript (frontend visualization).It features Zimbabwe-style traffic light systems, advanced collision detection, predictive safety measures, and real-time parameter adjustment for sensitivity analysis.
# Traffic Flow Simulation - Python-based Computational Model
A comprehensive web-based traffic flow simulation built with Python (Flask backend) and JavaScript (frontend visualization). Features Zimbabwe-style traffic light systems, advanced collision detection, predictive safety measures, and real-time parameter adjustment for sensitivity analysis.
## Features
### π Road Configurations
- **Two-Way Road**: Opposing traffic lanes with strict lane discipline
- **Crossroad**: 4-way intersection with Zimbabwe-standard traffic light control
### π― Advanced Safety Systems
- **Collision Detection**: Real-time bounding box collision detection
- **Crush Prediction**: Cars calculate time-to-collision and brake preemptively
- **Safe Following Distance**: Automatic 2-second rule + minimum gap maintenance
- **Emergency Braking**: Multi-level braking system based on threat level
- **Adaptive Cruise Control**: Cars match speed of vehicle ahead when in comfort zone
### π¦ Zimbabwe-Style Traffic Light System
- **RED**: Mandatory stop - no exceptions
- **AMBER**: Stop if safe to do so (calculates stopping distance vs distance to line)
- **GREEN**: Proceed normally
- **All-Red Phase**: Both directions red for 1 second during transition (intersection clearance)
- **Proper Sequencing**: Green β Amber β Red β All-Red β Other direction Green
### π Adjustable Parameters
1. **Number of Cars** (5-50): Control traffic density
2. **Max Speed** (1-10): Set speed limit
3. **Acceleration** (0.1-1.0): How quickly cars speed up
4. **Deceleration** (0.1-2.0): Braking strength
5. **Minimum Gap** (10-100px): Base safe following distance
6. **Reaction Time** (0.1-2.0s): Driver response time for 2-second rule
7. **Green Light Duration** (2-10s): How long green phase lasts
8. **Amber Duration** (1-5s): Warning time before red
### π¨ Visual Features
- **Safety Zones**: Green highlighted zones showing safe following distance
- **Brake Lights**: Red lights activate when car is stopped or slowing
- **Hea β¦