Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšฆ Traffic Simulation ๐Ÿš—

Welcome to the Traffic Simulation project! ๐ŸŒŸ This simulation models a bustling intersection with two roads crossing each other, each featuring one lane in each direction. The goal? Keep vehicles moving smoothly and avoid collisions at all costs!

๐ŸŒ Environment and Rules

๐Ÿ›ฃ๏ธ Roads

                        North
                    |  โ†“  |  โ†‘  |
                    |  โ†“  |  โ†‘  |
                    |     |     |
                    |     |     |
                    |     |     |
                    |     |     |
     _______________|     |     |_______________
     โ† โ†                                     โ† โ†
East ---------------             --------------- West
     โ†’ โ†’                                     โ†’ โ†’
     _______________             _______________
                    |     |     |
                    |     |     |
                    |     |     |
                    |     |     |
                    |     |     |
                    |  โ†“  |  โ†‘  |
                    |  โ†“  |  โ†‘  |
                        South
  • The simulation features two roads forming a crossroads.
  • Each road has one lane in each direction.
  • Vehicles choose their path by turning left, right, or going straight through the intersection.

๐Ÿšฅ Traffic Lights

  • Traffic lights control traffic flow at each lane's entrance to the intersection.
  • Lights cycle between red and green.
  • Design your own algorithm to minimize congestion (max 8 vehicles) and prevent collisions.

๐Ÿš— Vehicles

  • Vehicles follow specific rules:
    • Each vehicle is color-coded based on its intended route.
    • Fixed velocity and safe following distance are maintained.
    • Vehicles stop at red lights and proceed on green.
    • Routes cannot be changed mid-simulation.
    • No special priority is given to emergency vehicles.

โŒจ๏ธ Commands

  • Use these keyboard commands to interact with the simulation:

    • Arrow Keys:
      • โ†‘ (Up): Spawn a vehicle heading south.
      • โ†“ (Down): Spawn a vehicle heading north.
      • โ†’ (Right): Spawn a vehicle heading west.
      • โ† (Left): Spawn a vehicle heading east.
    • r: Spawn a vehicle in a random direction.
    • Esc (Escape): End the simulation.
  • Vehicles spawn with adequate spacing to prevent collisions.

๐Ÿ Running the Simulation

  • Start the simulation and observe traffic dynamics at the intersection.
  • Use arrow keys to introduce vehicles and witness their interactions.
  • Manage traffic lights to optimize vehicle flow.
  • Press Esc to gracefully conclude the simulation.

Author


Enjoy managing your virtual intersection and keeping traffic flowing smoothly! ๐Ÿšฆ๐Ÿš—

About

๐ŸšฆTraffic Simulation project! ๐Ÿš— This simulation models a bustling intersection with two roads crossing each other, each featuring one lane in each direction. The goal? Keep vehicles moving smoothly and avoid collisions at all costs!

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages