Demo entry 6359971

1

   

Submitted by huaslin on Apr 30, 2017 at 16:29
Language: C++. Code size: 1.0 kB.

 def update_passenger(self):
        # print "update the passengerlist"
        for name in range(0, passenger_num):
            if name in self.passenger_list:
                self.passenger_list[name].waiting_time += 1
                if self.passenger_list[name].state != "waiting":
                    del self.passenger_list[name]
                    self.new_passenger(name) # 创建乘客
                else:
                    if self.passenger_list[name].waiting_time >= passenger_max_waiting_time:
                        # 如果乘客等待时间超过阈值,就会放弃打车需求
                        del self.passenger_list[name]
                    self.new_passenger(name) # 创建乘客
            else:
                self.new_passenger(name)

    def Tick(self):
        self.update_passenger() # 更新乘客信息
        # for pa in self.passenger_list:
        #     self.passenger_list[pa].find_car(self.car_list)
        for car in self.car_list: # 更新汽车的监控范围
            self.car_list[car].find_passenger(self.passenger_list)

        self.time.tick()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).