After wasting 45 minutes in a traffic jam in Kathmandu, I decided to test whether a flow-dependent model is better than the fixed-time model that the traffic cops probably apply. The simulation has some directional problems. However, both simulations use the same directional strategy and Flow-based model is much quicker at allowing people to move. The proper implementation of this will require cameras all over the streets and programs that use Convolutional Neural Networks to detect cars. Finding it infeasible especially in Nepal, I have given up on this project. However, enjoy this nice video of simulation here: https://vimeo.com/239816149
PyGame
Run this in terminal:
export time_start=$(date +%s)
python traffic_simulation.py 0 $time_start & python traffic_simulation.py 1 $time_start