In a future with the roads populated by driverless cars, existing intersections will be obsolete as traffic will be able to flow much more easily. However, not every city will be able to immediately redesign and reconstruct each of their intersections to make traffic more efficient. By each car communicating with the others in real time, Green Light will be able to optimize traffic flow in existing intersections by dynamically changing the speed of each car.
We saw a video on Reddit of a similar concept that looked amazing, but was sadly just special effects. We thought it would be cool if this was how intersections worked in real life. With the advent of self-driving cards on the horizon, this could very well be a possibility in the not-so-far future, and may even be a viable solution to help reduce traffic.
How we built it
We first started by drawing out and modelling intersections and trying to think of the best algorithm to resolve collisions. We ended up assigning cars to 'rails', functions that take a scalar representing distance and return the Cartesian coordinates of the car's location, and then building an intersection out of these rails. Meanwhile, one team member worked on a pygame GUI front-end in parallel. Eventually we decided on a breadth first, lookahead search across four different methods of resolving each collision, and, after working out all of the bugs, ended up with an awesome looking simulation.
Challenges we ran into
It quickly became apparent that the algorithm for avoiding car collisions would be extremely hard to create. We quickly finished the other components, such as a friendly GUI for playing with the algorithms and the models, but the algorithms took up the vast majority of the effort, along with the heavy math needed to keep track of car's position, velocity and acceleration in parallel.
Accomplishments that we're proud of
After almost giving up a couple times we're really happy that our algorithm works. It still has a long way to go in terms of speed and efficiency, but in its current state it works and it looks really cool, which is the most important thing. The finished effect is entrancing and we could probably stare at it all day. Imagine having every intersection work like this!
What we learned
We learned different methods for resolving collisions, and that we should consider our search method more closely (after being stuck for a day using a depth-first search that looped infinitely). We also developed abstract methods of representing a variety of intersections which could be useful for future projects.
What's next for Green Light
The next steps for Green Light are distributing the collision resolution code in order to transition to a truly serverless experience. We also want to improve the collision boxes on the cars so it can detect collisions or non-collisions more effectively.