66FIND_PASSENGER_INTERVAL = 4
77TRIP_DURATION = 10
88
9- Event = collections .namedtuple ('Event' , 'time actor description ' )
9+ Event = collections .namedtuple ('Event' , 'time actor action ' )
1010
1111
1212def compute_delay (interval ):
@@ -33,7 +33,7 @@ def __init__(self, actors):
3333 self .time = 0
3434
3535 def schedule_events (self , end_time ):
36- for index , actor in enumerate ( list (self .actors ) ):
36+ for actor in list (self .actors ):
3737 try :
3838 future_event = next (actor )
3939 except StopIteration :
@@ -83,33 +83,33 @@ def main(args):
8383Sample run:
8484
8585$ clear; python3 taxi_sim.py seed=5 110
86- taxi: 0 Event(time=4, actor=0, description ='passenger picked up')
87- taxi: 1 Event(time=6, actor=1, description ='passenger picked up')
88- taxi: 2 Event(time=7, actor=2, description ='passenger picked up')
89- taxi: 1 Event(time=20, actor=1, description ='passenger dropped off')
90- taxi: 1 Event(time=23, actor=1, description ='passenger picked up')
91- taxi: 0 Event(time=33, actor=0, description ='passenger dropped off')
92- taxi: 2 Event(time=33, actor=2, description ='passenger dropped off')
93- taxi: 0 Event(time=34, actor=0, description ='passenger picked up')
94- taxi: 0 Event(time=45, actor=0, description ='passenger dropped off')
95- taxi: 2 Event(time=45, actor=2, description ='passenger picked up')
96- taxi: 0 Event(time=46, actor=0, description ='going home')
97- taxi: 1 Event(time=47, actor=1, description ='passenger dropped off')
98- taxi: 2 Event(time=47, actor=2, description ='passenger dropped off')
99- taxi: 2 Event(time=49, actor=2, description ='passenger picked up')
100- taxi: 1 Event(time=50, actor=1, description ='passenger picked up')
101- taxi: 1 Event(time=58, actor=1, description ='passenger dropped off')
102- taxi: 2 Event(time=58, actor=2, description ='passenger dropped off')
103- taxi: 1 Event(time=59, actor=1, description ='passenger picked up')
104- taxi: 2 Event(time=59, actor=2, description ='passenger picked up')
105- taxi: 1 Event(time=63, actor=1, description ='passenger dropped off')
106- taxi: 1 Event(time=64, actor=1, description ='going home')
107- taxi: 2 Event(time=84, actor=2, description ='passenger dropped off')
108- taxi: 2 Event(time=90, actor=2, description ='passenger picked up')
109- taxi: 2 Event(time=92, actor=2, description ='passenger dropped off')
110- taxi: 2 Event(time=99, actor=2, description ='passenger picked up')
111- taxi: 2 Event(time=101, actor=2, description ='passenger dropped off')
112- taxi: 2 Event(time=102, actor=2, description ='going home')
86+ taxi: 0 Event(time=4, actor=0, action ='passenger picked up')
87+ taxi: 1 Event(time=6, actor=1, action ='passenger picked up')
88+ taxi: 2 Event(time=7, actor=2, action ='passenger picked up')
89+ taxi: 1 Event(time=20, actor=1, action ='passenger dropped off')
90+ taxi: 1 Event(time=23, actor=1, action ='passenger picked up')
91+ taxi: 0 Event(time=33, actor=0, action ='passenger dropped off')
92+ taxi: 2 Event(time=33, actor=2, action ='passenger dropped off')
93+ taxi: 0 Event(time=34, actor=0, action ='passenger picked up')
94+ taxi: 0 Event(time=45, actor=0, action ='passenger dropped off')
95+ taxi: 2 Event(time=45, actor=2, action ='passenger picked up')
96+ taxi: 0 Event(time=46, actor=0, action ='going home')
97+ taxi: 1 Event(time=47, actor=1, action ='passenger dropped off')
98+ taxi: 2 Event(time=47, actor=2, action ='passenger dropped off')
99+ taxi: 2 Event(time=49, actor=2, action ='passenger picked up')
100+ taxi: 1 Event(time=50, actor=1, action ='passenger picked up')
101+ taxi: 1 Event(time=58, actor=1, action ='passenger dropped off')
102+ taxi: 2 Event(time=58, actor=2, action ='passenger dropped off')
103+ taxi: 1 Event(time=59, actor=1, action ='passenger picked up')
104+ taxi: 2 Event(time=59, actor=2, action ='passenger picked up')
105+ taxi: 1 Event(time=63, actor=1, action ='passenger dropped off')
106+ taxi: 1 Event(time=64, actor=1, action ='going home')
107+ taxi: 2 Event(time=84, actor=2, action ='passenger dropped off')
108+ taxi: 2 Event(time=90, actor=2, action ='passenger picked up')
109+ taxi: 2 Event(time=92, actor=2, action ='passenger dropped off')
110+ taxi: 2 Event(time=99, actor=2, action ='passenger picked up')
111+ taxi: 2 Event(time=101, actor=2, action ='passenger dropped off')
112+ taxi: 2 Event(time=102, actor=2, action ='going home')
113113*** end of events ***
114114
115115"""
0 commit comments