-
At least you have to give some rules. Traffic light on and off rules, restrictions. There is a long interval in between.
-
1。Vehicles (including bicycles, motorcycles, and electric vehicles) cannot go straight or turn left when encountering a red light, but they can turn right (regardless of the intersection, turning right is not restricted by traffic lights).
2。When the light is green, the car can go straight or turn left and right (pay special attention to the directional arrows above the traffic light).
3。If the turn light is green, you can drive in the direction of the directional arrow on the traffic light.
4。When the turn light is red, you cannot drive in the direction of the direction arrow indicated on the traffic light.
At a red light, you are not allowed to make a left turn. If it's an international signal, it will show a green light to turn left and you can make a left turn. It is possible to make a right turn at a red light. However, there are a few places where you have to press the right turn signal.
Regulations for the implementation of the Road Traffic Safety Law.
Article 38.
Motor vehicle signal lights and non-motor vehicle signal lights indicate:
1) When the green light is on, vehicles are allowed to pass, but the turning vehicles shall not obstruct the passage of vehicles and pedestrians who are allowed to go straight;
2) When the yellow light is on, vehicles that have crossed the stop line can continue to pass;
3) When the red light is on, vehicles are not allowed to pass.
At intersections where non-motor vehicle signal lights and pedestrian crossing signal lights are not installed, non-motor vehicles and pedestrians shall pass according to the indication of motor vehicle signal lights.
When the red light is on, vehicles turning right can pass without obstructing the passage of vehicles and pedestrians who have been released.
Article 39.
Pedestrian crossing signal lights indicate:
1) When the green light is on, pedestrians are allowed to cross the crosswalk;
2) When the red light is on, pedestrians are prohibited from entering the crosswalk, but those who have already entered the crosswalk can continue to pass or wait at the center line of the road.
Article 40. Lane signal lights indicate:
1) When the green arrow light is on, the vehicles in this lane are allowed to pass in the indicated direction;
2) When the red fork light or arrow light is on, the vehicle in this lane is prohibited.
-
Ask for a clear question, and then contact me.
-
It shouldn't be difficult, but the main thing to do is to use the date() class timing.
-
Landlord, let me know if you know how to compile, I need this program too! I've been worried lately!!
-
What does it mean?,Something like a traffic light stop and turn it on.,Timer and then set the time timer should be.。。。
-
What is the meaning? Is it with a red LED and a green LED? Or a traffic light?
-
There are four side lanes at the intersection, each of which is parked waiting for vehicles to go to the other three side lanes, and only one side lane is allowed to travel in each time segment.
The overall framework of the program can be designed in an event-driven way, that is, the main loop of the program is executed every time it is executed, and it is necessary to calculate how many cars have been added to the four branch roads during this time, and how many cars have left the intersection, and it should be noted that each random generation of vehicles should at least include which branch road it appears on which branch road it wants to drive to, etc., or conversely, several vehicles on a branch road in this time fragment appear on a specific branch road.
It's not clear how far you want to simulate, is the amount of time the vehicle crosses the intersection negligible? Is the length of the vehicle queue also considered? You wouldn't say you want to use a graphical interface to visualize it, right?
If your model is simple enough that an intersection is reduced to two intersecting straight lines, then you only need a simple set of objects (such as 12 integer variables) to represent the state! Of course, you can also need several variables for statistical historical data.
However, the real world is complex enough, just take a simple example: there is a long queue on a side road, and the traffic light indicates that the current side road is passable, and when the cars in front of you have driven through the intersection, and finally it is your turn, the red light is on! To complicate matters further, the control of traffic lights may not be rotated at intervals to avoid this.
You should be well aware that the vehicle does not move at a uniform speed.
Also remind you of the "random appearance of vehicles", don't think that there is only one way to generate random numbers that are evenly distributed! Some formulas can be used to calculate the Poisson distribution or something.
Remember that this is a very interesting algorithm design topic, don't be poisoned by the OOP ideology, think of something like that at every turn, we should be concerned about framework design and process control. It's ridiculous to understand it as a geometry problem!
The program can be designed to be more complex, that is, to use multiple threads to simulate multiple cars, and events to simulate traffic lights, and if you want, the program can operate in a time-driven way, closer to the real world.
-
There are several classes.
Scenario. Vehicle.
Light. Rules.
It's up to you how you play.
-
It's actually a function of a surface in 3D space.
If it is a multi-fork intersection, (including the intersection) of the traffic light state control, it is actually a four-color problem
-
If you are a book, you can have a basic level of programming, and you just need to understand the language thoroughly. Because anyway, I haven't heard of a book that writes Mini Programs.
Reversing at a traffic light will be a violation and 3 points will be deducted. >>>More
Actually, the key is to consider.
The principle of who is released first. >>>More
No, you will take three photos when you run a traffic light**, take a photo after crossing the line, take a photo when crossing the road, take a picture when crossing the opposite zebra crossing, if you stop in the middle of the road, it is not a red light, and no points will be deducted!
Don't pick up the red envelopes on the side of the road, the old people in the countryside tell you these 3 reasons, and they are right.
There is always a certain process of human maturity, and it is normal to take detours and lose yourself in this process, so there is no need for you to blame yourself as you do now. You recognize your mistakes and are trying to make up for them, which shows that you recognize your own responsibilities. As for what you are perplexing about right now, it may be temporary failure and economic trouble. >>>More