traffic simulator


info

This is a microscopic traffic simulator that focuses on roadbuilding. I made this for my gradwork at DAE in 6 weeks with the choice to focus on AI. To be able to make this project possible in 6 weeks i didn’t do the lane changing so this simulator only has 2-way and 1-way roads.

Besides the roadbuilding and the simulating i wanted the simulator to give visual feedback of the traffic flow. Because flow was the hardest option to implement i chose to use density.


process

The coding itself was roughly done in 3 weeks starting wit a simple implementation to test the acceleration model. In this stage the roads where made out of squares scaling and rotating according to its endpoints.

When i was sure that the acceleration model was implemented correctly i started upgrading the roads with bezier curves and added the crossroads. Because i thought that i was losing to much time with trying to find an existing implementation for them i made an own implementation. I ended up with the crossroads calculating the distance where every corner connects to the road next to it. For the orientation i added basic weight calculation for the different situations.

After that i noticed that the deceleration was wrong if there was no leading vehicle. Besides this i spent time improving the code to make the crossroads behave better and get the code for image generation in a state that allows multiple lane generation. A the end i added an A* version we saw during gameplay programming and added the flow measurement. To make the program look better i added images and UI.

Design a site like this with WordPress.com
Get started