Beispiel #1
0
 def trySatisfy(self, person, needValue, now):
     workplace = self.workplaces[person]
     if workplace.isOpen(now):
         return schedule.ScheduleItem(
             workplace, now.now(),
             now.now() + random.uniform(2 * time.HOUR, 4 * time.HOUR), self)
     else:
         return None
Beispiel #2
0
 def trySatisfy(self, person, needValue, now):
     distmap = self.grid.getDistanceMap()
     nearparks = distmap.getNearPlaces(person.currentPosition.x,
                                       person.currentPosition.y,
                                       place_characteristics.SubType.PARK)
     for (pos, _, __) in nearparks:
         x, y = pos
         if self.grid.get(x, y).isOpen(now):
             return schedule.ScheduleItem(
                 self.grid.get(x, y), now.now(),
                 now.now() + random.uniform(time.HOUR, 2 * time.HOUR), self)
     return None
Beispiel #3
0
    def trySatisfy(self, person, needValue, now):
        if person in self.gatherings and self.gatherings[
                person].stop < now.now() - 30 * time.MINUTE:
            return self.gatherings[person]

        startTime = now.now()
        duration = random.uniform(time.HOUR, 3 * time.HOUR)
        endTime = startTime + duration

        possiblePlaces = [self.sleep.homes[person]
                          ] + [p for p in self.massEvents if p.isOpen(now)]
        date = schedule.ScheduleItem(random.choice(possiblePlaces), startTime,
                                     endTime, self)

        for p in person.friends:
            self.gatherings[p] = date

        return date
Beispiel #4
0
 def trySatisfy(self, person, needValue, now):
     return schedule.ScheduleItem(
         self.homes[person], now.now(),
         now.now() + random.uniform(2 * time.HOUR, 4 * time.HOUR), self)