def main(mode='path'): interval = 0.1 the_world = world(width=25, height=25, scale=25) initialize() xx = 12.5 door_width = 3.0 corner_size = 1 waypoints = [vec3(xx, 4.0), vec3(xx, 5.0), vec3(xx, 6.0), vec3(xx, 40.0)] tk = the_world.tk canvas, x_, y_ = tk.canvas, tk.x_, tk.y_ canvas.create_rectangle(x_(-1), y_(-1), x_(100), y_(100), fill='blue') # stairs are added here so the graphics appear below the walls if mode == 'stairs': steps = 12 step_length = 0.28 zone = Stairs(lower_left=vec3(xx - door_width / 2, 7), upper_right=vec3(xx + door_width / 2, 7 + steps * step_length)) the_world.add_zone(zone) zone.draw() wall1 = ( (-100, 5.0), (12.5 - door_width / 2 - corner_size, 5.0), (12.5 - door_width / 2, 5.0 + corner_size), (12.5 - door_width / 2, 100) ) wall2 = ( (12.5 + door_width / 2, 100), (12.5 + door_width / 2, 5.0 + corner_size), (12.5 + door_width / 2 + corner_size, 5.0), (100, 5.0) ) wall3 = ( (12,10),(13,10),(13,11),(12,11) ) for wall in ( wall1 , wall2 ,wall3 ): points = [] for point in wall: points.append(x_(point[0])) points.append(y_(point[1])) canvas.create_polygon(points, fill='red', outline='black') for ii in range(0, len(wall)-1): the_world.add_wall(wall[ii], wall[ii+1]) pg = PersonGenerator() activate(pg, pg.generate(interval, waypoints), 0.0) u = Updater(interval) activate(u, u.execute(), 0.0) SimPy.Simulation.simulate(until=100)
def main(testing='two_clumps', cluster_size=20): interval = 0.1 world(width=25, height=25, scale=25) initialize() xx = 12.5 people = [] p = Person(interval) p.behaviors = [Arrive(), Separation()] p.position = vec3(xx, 4.0) p.destination = vec3(xx, 21.0) people.append(p) activate(p, p.move(), 0.0) if testing == 'solo': pass if testing == 'immovable object': p = Person(interval) p.behaviors = [Arrive(), Separation()] p.position = vec3(xx - 0.08, 14.0) p.destination = vec3(xx - 0.08, 14.0) people.append(p) p.update() world().update_boid(p) # DON'T activate(p, p.move(), 0.0) if testing in ('clump', 'two clumps'): random_people(xx, 21.0, xx, 4.0, cluster_size, interval, people) if testing == 'two clumps': random_people(xx, 4.0, xx, 21.0, cluster_size, interval, people) u = Updater(interval) activate(u, u.execute(), 0.0) simulate(until=240)
def main(cluster_size=20): interval = 0.1 the_world = world(width=25, height=25, scale=25) initialize() xx = 12.5 p = Person(interval) p.behaviors = [Wander(), Separation(), Containment()] p.position = vec3(12.5, 12.5) p.destination = vec3(-100, 100) activate(p, p.move(), 0.0) people = [p] tk = the_world.tk canvas, x_, y_ = tk.canvas, tk.x_, tk.y_ canvas.create_rectangle(x_(-1), y_(-1), x_(100), y_(100), fill='moccasin') for wall in ( ( (-100, 14.5), (10.5, 14.5), (10.5, 100) ), ( (10.5, -100), (10.5, 8.5), (8.5, 10.5), (-100, 10.5) ), ( (14.5, 100), (14.5, 14.5), ( 100, 14.5) ), ( ( 100, 10.5), (16.5, 10.5), (14.5, 8.5), (14.5, -100) ), ): points = [] for point in wall: points.append(x_(point[0])) points.append(y_(point[1])) canvas.create_polygon(points, fill='gray', outline='black') for ii in range(0, len(wall)-1): the_world.add_wall(wall[ii], wall[ii+1]) restarter = Restarter(people) activate(restarter, restarter.execute(), 0.0) u = Updater(interval) activate(u, u.execute(), 0.0) simulate(until=10000)
def main(cluster_size=30): interval = 0.1 the_world = world(width=25, height=25, scale=25) initialize() xx = 12.5 door_width = 4 corner_size = 1 people = [] waypoints = [vec3(xx, 21.0), vec3(xx, 22.0), vec3(xx, 23.0), vec3(xx, 40.0)] people = random_people(xx, 4.0, waypoints, cluster_size, interval, people) tk = the_world.tk canvas, x_, y_ = tk.canvas, tk.x_, tk.y_ canvas.create_rectangle(x_(-1), y_(-1), x_(100), y_(100), fill='moccasin') for wall in ( ( (-100, 21.0), (12.5 - door_width / 2 - corner_size, 21.0), (12.5 - door_width / 2, 21.0 + corner_size), (12.5 - door_width / 2, 100) ), ( (12.5 + door_width / 2, 100), (12.5 + door_width / 2, 21.0 + corner_size), (12.5 + door_width / 2 + corner_size, 21.0), (100, 21.0) ), ): points = [] for point in wall: points.append(x_(point[0])) points.append(y_(point[1])) canvas.create_polygon(points, fill='gray', outline='black') for ii in range(0, len(wall)-1): the_world.add_wall(wall[ii], wall[ii+1]) restarter = Restarter(people, waypoints) activate(restarter, restarter.execute(), 0.0) u = Updater(interval) activate(u, u.execute(), 0.0) simulate(until=10000)
rsm = RailStationManager() rsm.destination_x = 30.0 activate(rsm, rsm.check(), 0.0) pg = PersonGenerator(psm1, psm2, rsm) activate(pg, pg.generate(), 0.0) s1 = Straight((70.0, -30.0), (70.0, 5.0)) s1.next, last_left, last_right, length = station((70.0, 5.0), PRT.max_speed, "right", 3, psm1) last_left.next = last_right.next = s2 = Straight((70.0, 5.0 + length), (70.0, 125.0)) psm1.mainline = last_left s2.next, last_left, last_right, length = station((70.0, 125.0), PRT.max_speed, "right", 3, psm2) last_left.next = last_right.next = s7 = Straight((70.0, 125.0 + length), (70.0, 10000.0)) psm2.mainline = last_left prt_draw(s1, 70.0, -31.0) pg.destination1 = vec3(s1.next.destinations[0].x + 2.2, s1.next.destinations[0].y) pg.destination2 = vec3(s2.next.destinations[0].x + 2.2, s2.next.destinations[0].y) rg = RailcarGenerator(rsm) activate(rg, rg.generate(), 0.0) tg = PRTGenerator() activate(tg, tg.generate(s1, interval), 0.0) u = Updater(interval) activate(u, u.execute(), 0.0) simulate(until=1000) # simulate(until=400)
def main(mode='straight'): the_world = world() initialize() rx, ry = 35., 0. berths = 9 psm1 = PRTStationManager(berths) activate(psm1, psm1.check(), 0.0) door_width = 4.0 stair_width = door_width s1 = Straight((20., -30.), (20., 35.0)) s1.next, last_left, last_right, length = station((20.0, 35.0), PRT.max_speed, 'right', berths, psm1) last_left.next = last_right.next = c1 = Straight((20., 35. + length), (20., 10000.)) #last_left.next = last_right.next = c1 = Curve(0, pi/2, (-10., 35.0 + length), 30.) #c1.next = Straight((-10., 35.0 + length + 30.), (-10000., 35.0 + length + 30.)) psm1.mainline = last_left prt_draw(s1, 20.0, -31.0) pc = PRTChecker() activate(pc, pc.check(c1.members), 0.0) pp_ul, pp_lr = prt_platform = s1.next.platform prt_platform_center = (pp_ul.y + pp_lr.y) / 2 psm1.platform = prt_platform if mode in ('straight', 'doorway'): rail_stop_center = prt_platform_center elif mode == 'stair': platform_height = 6 step_height = 0.19 step_length = 0.28 steps = platform_height / step_height stair_length = steps * step_length rail_stop_center = prt_platform_center - stair_length - door_width #rail_draw(rx, ry, prt_platform_center_y) rail_draw(rx, ry, rail_stop_center) rail_headway = 450 rg = RailcarGenerator(mode, rail_stop_center, door_width, s1.next, rx, rail_headway) activate(rg, rg.generate(), 20.0 + 30) # prt platform walls, clockwise from top left the_world.add_wall( (pp_lr.x, pp_ul.y), (pp_ul.x, pp_ul.y), # top right and left (pp_ul.x, pp_lr.y), (pp_lr.x, pp_lr.y) ) # bottom left and right railside_x = rx - Railcar.width / 2 r1_top = rg.rail_destination[0] + Railcar.length / 2 r2_top = rg.rail_destination[1] + Railcar.length / 2 r1_doors = [] r2_doors = [] for door in Railcar.doors: r1_doors.append( ((railside_x, r1_top - door + 1), (railside_x, r1_top - door - 1)) ) r2_doors.append( ((railside_x, r2_top - door + 1), (railside_x, r2_top - door - 1)) ) railside_x = rx - Railcar.width / 2 # rail platform walls the_world.add_wall( (rx - 5, ry + 155), (railside_x, ry + 155), # top left and right r1_doors[0][0] ) # first car, top door the_world.add_wall( r1_doors[0][1], r1_doors[1][0] ) the_world.add_wall( r1_doors[1][1], r1_doors[2][0] ) the_world.add_wall( r1_doors[2][1], r1_doors[3][0] ) the_world.add_wall( r1_doors[3][1], r2_doors[0][0] ) the_world.add_wall( r2_doors[0][1], r2_doors[1][0] ) the_world.add_wall( r2_doors[1][1], r2_doors[2][0] ) the_world.add_wall( r2_doors[2][1], r2_doors[3][0] ) the_world.add_wall( r2_doors[3][1], # second car, bottom door (railside_x, ry + 45), (rx - 5, ry + 45)) # bottom right and left tk = the_world.tk canvas, x_, y_, s_ = tk.canvas, tk.x_, tk.y_, tk.s_ if mode == 'straight': the_world.add_wall( (rx - 5, pp_ul.y + 4), # prt/rail door top (rx - 5, ry + 155) ) # top right the_world.add_wall( (rx - 5, ry + 45), # bottom left (rx - 5, pp_lr.y - 4) ) # prt/rail door bottom rg.waypoint_high = vec3(rx - 4, pp_ul.y + 3) rg.waypoint_low = vec3(rx - 4, pp_lr.y - 3) # between rail and prt platforms the_world.add_wall((pp_lr.x, pp_ul.y), (rx - 5, pp_ul.y + 4)) the_world.add_wall((rx - 5, pp_lr.y - 4), (pp_lr.x, pp_lr.y)) canvas.create_polygon( ((x_(pp_lr.x), y_(pp_ul.y)), (x_(rx - 5), y_(pp_ul.y + 4)), (x_(rx - 5), y_(pp_lr.y - 4)), (x_(pp_lr.x), y_(pp_lr.y))), fill='#ccc', outline='#ccc') elif mode == 'doorway': the_world.add_wall( (pp_lr.x, pp_ul.y), (pp_lr.x, prt_platform_center + door_width / 2), (rx - 5, prt_platform_center + door_width / 2), (rx - 5, ry + 155) ) the_world.add_wall( (rx - 5, ry + 45), (rx - 5, prt_platform_center - door_width / 2), (pp_lr.x, prt_platform_center - door_width / 2), (pp_lr.x, pp_lr.y) ) rg.waypoint_high = vec3(rx - 4, prt_platform_center + door_width / 3) rg.waypoint_low = vec3(rx - 4, prt_platform_center - door_width / 3) canvas.create_polygon( ((x_(pp_lr.x), y_(prt_platform_center + door_width / 2)), (x_(rx - 5), y_(prt_platform_center + door_width / 2)), (x_(rx - 5), y_(prt_platform_center - door_width / 2)), (x_(pp_lr.x), y_(prt_platform_center - door_width / 2))), fill='#ccc', outline='#ccc') elif mode == 'stair': epd = extra_platform_depth = 3 wall1 = ( (pp_lr.x, pp_ul.y), (pp_lr.x + epd, prt_platform_center + door_width / 2), (pp_lr.x + epd + stair_width, prt_platform_center + door_width / 2), (pp_lr.x + epd + stair_width, prt_platform_center - door_width / 2), (rx - 5, prt_platform_center - door_width / 2 - stair_length), (rx - 5, ry + 155) ) wall2 = ( (rx - 5, ry + 45), (rx - 5, prt_platform_center - door_width / 2 - stair_length - door_width), (rx - 5 - door_width, prt_platform_center - door_width / 2 - stair_length - door_width), (rx - 5 - door_width, prt_platform_center - door_width / 2 - stair_length), (pp_lr.x + epd, prt_platform_center - door_width / 2), (pp_lr.x, pp_lr.y) ) the_world.add_wall( *wall1 ) the_world.add_wall( *wall2 ) rg.waypoint_low = vec3(rx - 4, prt_platform_center - stair_length - door_width) rg.waypoint_prt_door = vec3(pp_lr.x + door_width / 2, prt_platform_center) points = [] for point in wall1 + wall2: points.append(x_(point[0])) points.append(y_(point[1])) canvas.create_polygon(points, fill='gray') tg = PRTGenerator() # 50% empty to simulate sending extras to the transit station activate(tg, tg.generate(s1, interval, percent_empty=0.50), 0.0) clock = Clock() # "0" time taken from when Railcar called station_manager.doors_open activate(clock, clock.execute(), 43.684 + 30) u = Updater(interval) activate(u, u.execute(), 0.0) simulate(until=2000)
def main(mode='straight'): the_world = world() initialize() tk = the_world.tk canvas, x_, y_, s_ = tk.canvas, tk.x_, tk.y_, tk.s_ ### ### PRT ### berths = 6 psm1 = PRTStationManager(berths) psm2 = PRTStationManager(berths) activate(psm1, psm1.check(), 0.0) activate(psm2, psm2.check(), 0.0) s1 = Straight((20., -30.), (20., -5.0)) s1.next, last_left, last_right, length \ = station((20.0, -5.0), PRT.max_speed, 'right', berths, psm1) last_left.next = last_right.next = s2 \ = Straight((20., -5. + length), (20., -5. + length + 5.)) psm1.mainline = last_left s2.next, last_left, last_right, length \ = station((20.0, -5.0 + length + 5), PRT.max_speed, 'right', berths, psm2) last_left.next = last_right.next \ = Straight((20.0, 500.), (20., 10000.)) psm2.mainline = last_left prt_draw(s1, 20.0, -31.0) pc = PRTChecker() activate(pc, pc.check(s2.members), 0.0) p1_ul, p1_lr = prt_platform = s1.next.platform prt_platform_center = (p1_ul.y + p1_lr.y) / 2 psm1.platform = prt_platform p2_ul, p2_lr = s2.next.platform canvas.create_polygon( ((x_(p1_lr.x), y_(p1_ul.y)), (x_(p1_lr.x + 15), y_(p1_ul.y + 4)), (x_(p1_lr.x + 15), y_(p1_lr.y - 4)), (x_(p1_lr.x), y_(p1_lr.y))), fill='#ccc', outline='#ccc') canvas.create_polygon( ((x_(p2_lr.x), y_(p2_ul.y)), (x_(p2_lr.x + 15), y_(p2_ul.y + 4)), (x_(p2_lr.x + 15), y_(p2_lr.y - 4)), (x_(p2_lr.x), y_(p2_lr.y))), fill='#ccc', outline='#ccc') tg = PRTGenerator() # 75% empty to simulate sending extras to the stadium activate(tg, tg.generate(s1, interval, percent_empty=0.75), 0.0) ### ### Rail ### rx, ry = 80., 0. rsm = RailStationManager() activate(rsm, rsm.check(), 0.0) rail_stop_center = 100 rail_draw(rx, ry, rail_stop_center) rg = RailcarGenerator(rx, rsm) rsm.mode = "stadium" activate(rg, rg.generate(), 20.0 + 30) rg.waypoint_high = vec3(rx - 4, p1_ul.y + 3) rg.waypoint_low = vec3(rx - 4, p1_lr.y - 3) canvas.create_polygon( ((x_(rx - 20), y_(rail_stop_center + 20)), (x_(rx - 5), y_(rail_stop_center + Railcar.length)), (x_(rx - 5), y_(rail_stop_center - Railcar.length)), (x_(rx - 20), y_(rail_stop_center - 20))), fill='#ccc', outline='#ccc') ### ### People ### pg = PersonGenerator(rsm, rx - 20, rail_stop_center - Railcar.length + 2, rail_stop_center + Railcar.length - 2, psm1, p1_lr.x + 15, p1_lr.y - 4, p1_ul.y + 4, psm2, p2_lr.x + 15, p2_lr.y - 4, p2_ul.y + 4) activate(pg, pg.generate(), 45.0) ### ### ### u = Updater(interval) activate(u, u.execute(), 0.0) simulate(until=2000)