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
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