Do you remember the [`road_intersection`](https://public.01-edu.org/subjects/road_intersection/) raid done in the Rust Piscine? Well, you
Do you remember the [`road_intersection`](https://public.01-edu.org/subjects/road_intersection/) raid done in the Rust Piscine? Well, you
will have to create another traffic control strategy and its simulation, but this time without traffic lights and with a smart intersection management strategy.
will have to create another traffic control strategy and its simulation. However, this time it will have to be done without traffic lights and with a smart intersection management strategy.
Most of the time intersections might lead to serious traffic jams on multiple roads, which wastes time and money of drivers and
Most of the time overused intersections might lead to serious traffic jams on multiple roads, which wastes drivers'time and money, and also causes unnecessary air pollution. Additionaly in the U.S. according to a study from the National Highway Traffic Safery administration, it is reported that about 96% of the intersection-related crashes had critical reasons
also causes unnecessary air pollutions. It is also reported that about 96% of the intersection-related crashes had critical reasons
to be the drivers fault, such as inadequate surveillance, false assumption of other actions, and turns with obstructed view.
to be the drivers fault, such as inadequate surveillance, false assumption of other actions, and turns with obstructed view.
[Autonomous vehicles](https://en.wikipedia.org/wiki/Self-driving_car) (AVs) is a promising solution to traffic accidents. An optimistic prediction is that AVs will be publicly available in the next decade, and thus traffic problems related to autonomous vehicles are also being extensively investigated.
[Autonomous vehicles](https://en.wikipedia.org/wiki/Self-driving_car) (AVs) is a promising solution to traffic accidents. An optimistic prediction is that AVs will be publicly available in the next decade, and thus traffic issues related to autonomous vehicles are also being extensively investigated.
Current intersection management strategies, such as the traditional traffic light and other more advanced methods are designed exclusively
Current intersection management strategies, such as the traditional traffic light and other more advanced methods are designed exclusively
for human drivers. With the rapid development of AVs, new traffic strategies must be taken into account.\
for human drivers. With the rapid development of AVs, new traffic strategies must be taken into account.\
This is where you come in. You will have to create this new traffic strategy algorithm so that AVs can pass an intersection without any
This is where you come in. You will have to create this new traffic strategy algorithm, so that AVs can pass an intersection without any
collisions and with a minimum traffic congestion.
collisions and with a minimum of traffic congestion.
The simplicity of this intersection is that each lane has only one outgoing direction, that is, the route of the vehicle in the
The simplicity of this intersection is that each lane has only one outgoing direction, that is, the route of the vehicle in the
intersection area can be only represented by the corresponding lane.
intersection area can only be represented by the corresponding lane.
---
---
@ -66,16 +65,17 @@ intersection area can be only represented by the corresponding lane.
```
```
As stated above you will be considering that all vehicles are autonomous (AVs) also known as self-driving cars.
As stated above you will be considering that all vehicles are autonomous (AVs) also known as self-driving cars.
You will have to implement the physics for this type of vehicles, by taking into account the following rules :
You will have to implement the physics for this type of vehicles by taking into account the following rules :
1. AVs driving on a lane with a **given route** must follow the direction of
1. AVs driving on a lane with a **given route** must follow the direction of
that route, its not possible for the AVs to change lanes or route.
that route, its not possible for the AVs to change lanes or route.
2. An AVs must have at least 3 different velocities, therefore the **smart intersection system** can control the velocity of the vehicle.\
2. An AVs must have at least 3 different velocities, therefore the **smart intersection system** can control the velocity of the vehicle.\
This way controlling the current velocity/time/distance (depending on the algorithm you implement) of the AVs.
This will be the way of controlling the current velocity/time/distance (depending on the algorithm you implement) of the AVs.
3. Each AVs must have a safety distance from other AVs, if it is driving with a high velocity and encounters another vehicle.\
3. Each AVs must respect a safety distance from other AVs.\
It must detect that vehicle and keep a safe distance from it, it should not collide!
If it is driving with a high velocity and encounters another vehicle, it must detect that vehicle and keep a safe distance from it. It should not collide!
You are free to decide what is the safety distance but it must a strictly positive value.
4. Other vehicles such as emergency vehicles are not considered in this project.
4. Other vehicles such as emergency vehicles are not considered in this project.
@ -83,7 +83,7 @@ You will have to implement the physics for this type of vehicles, by taking into
- `time`, this will be the time that the AVs takes to leave the intersection
- `time`, this will be the time that the AVs takes to leave the intersection
- `distance`, this will be the distance that the AVs takes to leave the intersection
- `distance`, this will be the distance that the AVs takes to leave the intersection
- `velocity`
- `velocity`, this will be the speed of the AVs at current time
---
---
@ -97,7 +97,7 @@ Animation is required for this project, you will have to find some assets for th
Animation is not just rendering an image into the canvas. By using assets you get to decide your "world coordinate system"
Animation is not just rendering an image into the canvas. By using assets you get to decide your "world coordinate system"
for the rendered image and therefore creating your own animation. But this is not enough, basically you must animate while moving.
for the rendered image and therefore you create your own animation. But this is not enough, basically you must animate while moving.
A simple example of movement animation is imagining a vehicle with a route of `r`. This means that the vehicle arrives at the
A simple example of movement animation is imagining a vehicle with a route of `r`. This means that the vehicle arrives at the
intersection and turns right. If we render just an image of the vehicle facing down and it arrives to the point of turning, the rendered image
intersection and turns right. If we render just an image of the vehicle facing down and it arrives to the point of turning, the rendered image
@ -118,7 +118,7 @@ You will have to implement several commands so that the simulation can be well t
- `Arrow Right`, generate vehicles from west to east.
- `Arrow Right`, generate vehicles from west to east.
- `Arrow Left`, generate vehicles from east to west.
- `Arrow Left`, generate vehicles from east to west.
2. It must also be possible to use the key `R` to continually generate radom vehicles (using the game loop).
2. It must also be possible to use the key `R` to continually generate random vehicles (using the game loop).
3. The `Esc` key must finish the simulation and generate a window with all statistics (you can see more about the statistics on its section).
3. The `Esc` key must finish the simulation and generate a window with all statistics (you can see more about the statistics on its section).
@ -128,18 +128,18 @@ You will have to implement several commands so that the simulation can be well t
#### **Statistics**
#### **Statistics**
Your program must be able to generate statistics, like state above this must be displayed in a window right after the user tries to exit the simulation.
Your program must be able to generate statistics, as stated above, this must be displayed in a window right after the user tries to exit the simulation.
The statistics must include:
The statistics must include:
- Max number of vehicles that passed the intersection
- Max number of vehicles that passed the intersection
- Collisions if there was any
- Collisions if there was any
- Max velocity of all vehicles
- Max velocity of all vehicles (Display the fastest speed achieved)
- Min velocity of all vehicles
- Min velocity of all vehicles (Dislay the slowest speed reached)
- Max time that took the vehicles to pass the intersection (for all vehicles the one that took more)
- Max time that took the vehicles to pass the intersection (for all vehicles, display the one that took more time)
- The time starts to count whenever the vehicle is detected by the **smart intersection algorithm** until the end of the intersection, when the vehicle is removed from the canvas.
- The time starts to count whenever the vehicle is detected by the **smart intersection algorithm** until the end of the intersection, which is when the vehicle is removed from the canvas.
- Min time that took the vehicles to pass the intersection (for all vehicles the one that took less)
- Min time that took the vehicles to pass the intersection (for all vehicles, display the one that took less time)
- Close calls, this is when both vehicles pass each other with a violation o the safe distance.
- Close calls, this is when both vehicles pass each other with a violation of the safe distance.
###### If so is there any image/asset that represents this intersection?
###### If so, is there any image/asset that represents this intersection?
##### Try and run the application, then generate a vehicle at your choice.
##### Try and run the application, then generate a vehicle of your choice.
###### Is there any animation for the vehicle?
###### Is there any animation for the vehicle?
##### Try and run the application, then generate a vehicle that turns right.
##### Try and run the application, then generate a vehicle that turns right.
###### Did the vehicle animate when turning right?
###### Did the vehicle animated accordingly when turning right?
##### Try and run the application, then generate a vehicle by pressing the `"Arrow Up"` key.
##### Try and run the application, then generate a vehicle by pressing the `"Arrow Up"` key.
###### Was a vehicle generated from the cardinal south?
###### Was a vehicle generated from the cardinal South?
##### Try pressing the `"Arrow Down"` key.
##### Try pressing the `"Arrow Down"` key.
@ -24,43 +24,43 @@
##### Try pressing the `"Arrow Right"` key.
##### Try pressing the `"Arrow Right"` key.
###### Was a vehicle generated from the cardinal west?
###### Was a vehicle generated from the cardinal West?
##### Try pressing the `"Arrow left"` key.
##### Try pressing the `"Arrow left"` key.
###### Was a vehicle generated from the cardinal east?
###### Was a vehicle generated from the cardinal East?
##### Try pressing the `"R"` key.
##### Try pressing the `"R"` key.
###### Are vehicles generated randomly(random lane and route)?
###### Are vehicles generated randomly(random lane and route)?
##### Try to generate tree vehicles in the same lane (do this to all lanes).
##### Try to generate tree vehicles in the same lane (do this for all lanes).
###### Did all vehicles passed the intersection without any collision?
###### Did all vehicles pass the intersection without any collision?
##### Try to generate four vehicles at the same time, one using the `"Right"` key and the other using the `"Left"` key (to this until there is a collision route).
##### Try to generate four vehicles at the same time, one using the `"Right"` key and the others using the `"Left"` key (repeat this operation until there is a collision route).
###### Did all vehicles passed the intersection without any collision?
###### Did all vehicles pass the intersection without any collision?
##### Try to generate four vehicles at the same time, one using the `"Up"` key and the other using the `"Left"` key (to this until there is a collision route).
##### Try to generate four vehicles at the same time, one using the `"Up"` key and the other using the `"Left"` key (repeat this operation until there is a collision route).
###### Did all vehicles passed the intersection without any collision?
###### Did all vehicles pass the intersection without any collision?
##### Try to generate four vehicles at the same time, one using the `"Up"` key and the other using the `"Right"` key (to this until there is a collision route).
##### Try to generate four vehicles at the same time, one using the `"Up"` key and the other using the `"Right"` key (repeat this operation until there is a collision route).
###### Did all vehicles passed the intersection without any collision?
###### Did all vehicles pass the intersection without any collision?
##### Try to generate four vehicles at the same time, one using the `"Down"` key and the other using the `"Left"` key (to this until there is a collision route).
##### Try to generate four vehicles at the same time, one using the `"Down"` key and the other using the `"Left"` key (repeat this operation until there is a collision route).
###### Did all vehicles passed the intersection without any collision?
###### Did all vehicles pass the intersection without any collision?
##### Try to generate four vehicles at the same time, one using the `"Down"` key and the other using the `"Right"` key (to this until there is a collision route).
##### Try to generate four vehicles at the same time, one using the `"Down"` key and the other using the `"Right"` key (repeat this operation until there is a collision route).
###### Did all vehicles passed the intersection without any collision?
###### Did all vehicles pass the intersection without any collision?
##### Try to generate five vehicles using the `"Up"` key, at the same time generate two vehicles using the key `"Right"`.
##### Try to generate five vehicles using the `"Up"` key, at the same time generate two vehicles using the key `"Right"`.
###### Did all vehicles passed the intersection without any collision?
###### Did all vehicles pass the intersection without any collision?
##### Try to generate three vehicles that are supposed to collide (vehicles in the collision lane) fo this at least 3 times.
##### Try to generate three vehicles that are supposed to collide (vehicles in the collision lane) fo this at least 3 times.
@ -68,46 +68,48 @@
##### Try to generate vehicles randomly using the `"R"` key. Then wait for at least 1 min.
##### Try to generate vehicles randomly using the `"R"` key. Then wait for at least 1 min.
###### Did all vehicles passed the intersection without any collision?
###### Did all vehicles pass the intersection without any collision?
###### Was there a low traffic congestion while running the application? (ex: high traffic congestion can be 8 or more vehicles in the same lane without proceeding)?
###### Did the traffic congestion remained low while running the application? (ex: high traffic congestion can be 8 or more vehicles stuck in the same lane)?
##### Try to generate four vehicles using the `"UP"` key to generate two and the `"Right"` key to generate the other two. Then when the vehicles finish passing the intersection, exit the application by using the `"Esc"` key.
##### Try to generate four vehicles using the `"UP"` key to generate two and the `"Right"` key to generate the other two. Then when the vehicles finish passing the intersection, exit the application by using the `"Esc"` key.
###### Did the application displayed a window with statistics of the simulation?
###### Did the application display a window with statistics of the simulation?
###### And if so did it display the "Max number of vehicles that passed the intersection" as 4?
###### And if so, did it display the "Max number of vehicles that passed the intersection" as 4?
###### Did it also displayed the "Collisions" as 0?
###### Did it also display the "Collisions" as 0?
###### Did it also displayed the "Max velocity" and the "Min velocity"?
###### Did it also display the "Max velocity" and the "Min velocity"?
###### Did it also displayed the "Max time that took the vehicle to pass the intersection"?
###### Did it also display the "Max time that took the vehicle to pass the intersection"?
###### Did it also displayed the "Min time that took the vehicle to pass the intersection"?
###### Did it also display the "Min time that took the vehicle to pass the intersection"?
###### Did it also displayed the "Close calls", if there were any?
###### Did it also display the "Close calls", if there were any?
##### Try to generate on vehicle and see how much time the vehicle takes to leave the intersection, then exit the application and compare the time statistics.
##### Try to generate one vehicle and see how much time the vehicle takes to leave the intersection, then exit the application and compare the time statistics.
###### Is the max time equal to the min time?
###### Is the max time equal to the min time?
###### And if so is the time correct compared from the time you counted?
###### And if so, is the time correct compared from the time you counted?
#### General
#### General
###### Is it not possible to spam the creation of vehicles(by pressing the arrow keys to many times)?
###### Is the spam of creation of vehicles prevented (limitation of pressing the arrow keys too many times)?
###### Are vehicles assigned to their own route, and if so do they obey that route? (you can use the lanes to see if its obeyed)
###### Are vehicles assigned to their own route, and if so do they respect that route? (you can use the lanes to see if they are respected)
###### Are vehicles kept in a safe distance(do not collide when ever one stops or reduces their velocity)?
###### Is there a logical safe distance set up for the vehicles(a strictly positive and reasonable distance)?
###### Do vehicles present at least 3 different velocities?
###### Are vehicles kept in a safe distance(do not collide whenever one stops or reduces their velocity)?
###### Do vehicles have at least 3 different velocities?
#### Bonus
#### Bonus
###### +Does the application present more statistics beside the ones stated in the subject?
###### +Does the application present more statistics besides the ones stated in the subject?
###### +Did the student create their own assets?
###### +Did the student create their own assets?
###### +Is this algorithm a good implementation for real life situations?
###### +In your opinion, is this algorithm implementable for real life situations?