Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbwreath_traffic_partial #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions car.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""Car class

Responsibilities
-car length
-speed
-distance between other cars
-starting position



"""

# creating a car and its functions
class Car(object):
##car will continue to accelerate (up to 120k/h) as long as it has room to do so
def __init__(self, size, speed):
self.size = (5 meters)
self.starting_speed = (0, 0)
#self.max_speed = (120kilometers/hr)

def move(self):
self.move(self.speed[0], self.speed[1])
#self.accelerate( 2m/s unless they are within 10 meters of lead car)


def set_speed(self, x, y):
self.speed = x, y
#random slow down of 2m/s
car1 = Car()
car1.set_speed(3,30)




# def update_car_and_check_spacing(self, x_move, y_move):
# def constrain(min, max, actual):
# if actual < min:
# return min, True
# elif actual > max:
# return max, True
# else:
# return actual, False



# moving car withing the set parameters
for x in range():
#self.sleep(sleep car if it gets within 10 meters of lead car)
time.sleep(0.025)
car1.move()
car2.move()
15 changes: 15 additions & 0 deletions road.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Road class

Responsibilities
-single lane continuous (circle shape)
-1 kilometer in length
-holds 30 cars( 5 meters in length) @ 1 kilometer apart from each other
-


"""

class Road():
def __init__(self):
self.size = (1 kilometer)
#self.shape =(circle)
47 changes: 47 additions & 0 deletions traffic_simulation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class Traffic_simulation():

def __init__(self, car, road):
self.car == car
self.road == road




# def update_car_and_check_spacing(self, x_move, y_move):
# def constrain(min, max, actual):
# if actual < min:
# return min, True
# elif actual > max:
# return max, True
# else:
# return actual, False

class Car(object):
##car will continue to accelerate (up to 120k/h) as long as it has room to do so



def __init__(self, size, speed):
self.car_length = 5 meters#
self.size = (car_length)
self.starting_speed = (0, 0)
#self.max_speed = (120kilometers/hr)

def move(self):
self.move(self.speed[0], self.speed[1])
#self.accelerate( 2m/s unless they are within 10 meters of lead car)


def set_speed(self, x, y):
self.speed = x, y
#random slow down of 2m/s
car1 = Car()
car1.set_speed(3,30)


# moving car withing the set parameters
for x in range():
#self.sleep(sleep car if it gets within 10 meters of lead car)
time.sleep(0.025)
car1.move()
car2.move()