Question
IN PYTHON Some details for your simulation: -The basic simulation scenario remains the same. All cars are travelling in the same direction at the same
IN PYTHON
Some details for your simulation:
-The basic simulation scenario remains the same. All cars are travelling in the same direction at the same starting speed; there is a gap of gaplength between each pair of cars; the latter cars only begin braking after the car in front of them brakes (and after the reaction time has elapsed); etc.
-The last car (car3) will now start at position 0; car2 will start at position gaplength and car1 will start at position 2*gaplength.
-You will need to test for different collisions. However, note that while car2 can crash into car1 and car3 can crash into car2, car3 can never crash into car1 (because cars are not allowed to pass one another).
-Note that multiple crashes are possible. In fact, in the sample run I provide below, car2 crashes into car1, car3 crashes into car2, and car2 crashes into car1 again! So, don't stop looking for crashes after a single one happens.
-Reaction times for both car2 cand car3 are random (different random selections for each), but drawn from the same distribution, with the same minimum and maximums. (Only a single min and max parameter are required for the simulation, which are used for both cars.)
The signature of my runsim method is:
def runsim(self, gaplength, startingspeed, brakingrate, car1_start_braking_time, minreactiontime, maxreactiontime, timeinterval) An example of the output when I run it with the following arguments: sim.runsim(10, 28, 12, 2, .5, 1.25, .1) follows.
Below is the output:
Text output: Crash: Car 2 into Car 1! Time of impact: 3.700 Net impact speed: 7.200 Crash: Car 3 into Car 2! Time of impact: 4.100 Net impact speed: 11.520 Crash: Car 2 into Car 1! Time of impact: 4.200 Net impact speed: 5.472
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started