Here is a data driven simulation engine for driverless cars. VISTA is a photorealistic simulator that can simulate not only live video but LIDAR data and event cameras. It is open source, so you can study the code. This simulator can be used to model complex driving situations.
VISTA can realistically simulate several sensors used for autonomous driving. Thanks to this, you can safely train self-driving cars in dangerous and unusual situations. Multiple vehicles can be added to train a self driving system how to interact with other cars.