Car¶
The agent in the model.
The public methods in the car are:
-
class
car.
Car
(starting_position, starting_velocity, braking_rate=25, acceleration_rate=10, max_velocity=60, desired_velocity=40, length=4, stop_space=8, safe_dist=100)[source]¶ Definition of the Car class. Here Car can take several arguments during initialization.
Parameters: - starting_position (float) – Starting position of the car
- starting_velocity (float) – Starting velocity of the car
- braking_rate (float) – Rate of retardation (braking rate) of the car
- acceleration_rate (float) – Rate of acceleration of the car
- max_velocity (float) – Maximum velocity that the car can reach up to
- desired_velocity (float) – The velocity of the car that it tries to achieve in normal case
- length (float) – Length of a car
- stop_space (float) – Space that the car must have between the car in the front before colliding
- save_dist (float) – A safe distance the car wants to have with the car in front
-
position_history
¶ History of all position that this car has traveled
Type: list
-
return_position_array
()[source]¶ Give history of the array for plotting.
Returns: Return an array of positions for each time point in the simulation.
-
update_position
(position_of_next_car)[source]¶ Get the new position of the car after a single time step, based on the position of the car in front.
Update the position history of the car.
Parameters: position_of_next_car – distance to the next car including Returns: The position of the car after the next time step