JGMEYER / py-traffic-sim

A fun program to simulate vehicle traffic patterns in python
0 stars 1 forks source link

Add collision detection logic #35

Closed JGMEYER closed 4 years ago

JGMEYER commented 4 years ago

Resolves #21.

This only adds the base logic for detecting collisions between vehicles. There's still a good amount of experimentation ahead to determine a good way for having vehicles wait behind other vehicles if they'd otherwise collide.

You can add this snippet to Traffic.step() for some basic collision debugging:

if self.collision_tracker.has_collision(v._id):
    print(f"{v._id} has collision!")