Question: Create a simulation in Python. Network of cars going in a square (4*4) so 12 possible segment locations. Coded as points on a graph i.e.

Create a simulation in Python.

Network of cars going in a square (4*4) so 12 possible segment "locations". Coded as points on a graph i.e. segment 0= (0,0), segment 1= (1,0) etc.

Write a method which runs for every simulated the following three:

1.creating cars: in every unoccupied segment, set the state to occupied with default probability= 0.1 (Represents new cars joining the road).

2.death of cars.: in every occupied segment set the state to unoccupied with default probability =0.1 (Represents cars leaving the network)

3.normal traffic: every occupied road segment can move on to the next segment provided it is free

Create a class to hold the state of the car so about what segment the cars are on (i.e. store the data).

An additional method should plot the square network with road segments that are occupied by a car in red and those that are empty in green.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!