def person(self, railcar, yy, railcar_waypoints): columns = self.columns compactness = self.compactness for ii in range(0, columns): xx = self.rail_x + (ii - (float(columns) - 1.0) / 2.0) * (Person.average_radius * 2.0 * compactness) p = Person(interval=interval) p.behaviors = [Containment(), Separation(), FollowWaypoints(), InterpenetrationConstraint()] p.steering_mind = queue_steering_mind p.position = vec3(xx, yy) p.waypoints = railcar_waypoints[0:] if self.mode == 'straight': if p.waypoints[0].y - self.waypoint_high.y > 3: p.waypoints.append(self.waypoint_high) if self.waypoint_low.y - p.waypoints[0].y > 3: p.waypoints.append(self.waypoint_low) elif self.mode == 'doorway': if p.waypoints[0].y > self.platform_center_y: p.waypoints.append(self.waypoint_high) if p.waypoints[0].y <= self.platform_center_y: p.waypoints.append(self.waypoint_low) p.waypoints.append(vec3(p.waypoints[-1])) p.waypoints[-1].x -= 7.0 elif self.mode == 'stair': p.waypoints.append(self.waypoint_low) p.waypoints.append(vec3(self.waypoint_low)) p.waypoints[-1].x -= self.doorway_width * 0.75 p.waypoints.append(self.waypoint_prt_door) p.waypoints.append(vec3(self.waypoint_prt_door)) p.waypoints[-1].x -= 1.0 p.manager = self.prt_station.person_at_station railcar.departing.append(p)
def generate(self, interval, waypoints): people = [] rate = 0.5 #while True: for k in range(10): start = uniform(0, 5) p = Person(interval=interval) #p.destination= vec3(12.5,uniform(2,20)) p.behaviors = [Containment(), Separation(), Queuing(), FollowWaypoints(), InterpenetrationConstraint()] #p.behaviors = [FollowWaypoints(),InterpenetrationConstraint()] #p.behaviors = [Seek(),InterpenetrationConstraint()] p.steering_mind = queue_steering_mind p.position = vec3(start, 0.0) p.waypoints = waypoints[0:] activate(p, p.move(), 0.0) people.append(p) count = 0 for p in people: if p.position[1] > 25: self.cancel(p) p.world.remove_boid(p) people.remove(p) if p.position[1] < 7: count += 1 if count > 30: rate = 1.5 elif count < 20: rate = 0.5 yield hold, self, rate
def random_people(cx, cy, waypoints, cluster_size, interval, people): def random_position(): range = cluster_size * (pi * Person.average_radius**2 + 0.2) offset = range / 2 return uniform(0.0, range) - offset for ii in range(0, cluster_size): p = Person(interval) p.behaviors = [Containment(), Separation(), Queuing(), FollowWaypoints()] p.steering_mind = queue_steering_mind try_again = True while try_again: px, py = cx + random_position(), cy + random_position() if py > (21.0 - Person.radius): continue try_again = False for person in people: jx, jy, unused_z = person.position if sqrt((jx-px)**2 + (jy-py)**2) < Person.average_radius*2.5: try_again = True p.position = vec3(px, py) p.waypoints = waypoints[0:] activate(p, p.move(), 0.0) people.append(p) return people