コード例 #1
0
def spawn_pedestrian():
    name = random.choice(names)
    age = random.randint(18,70)
    start_node = random.sample(pedestrian_graph.G._sources, 1)[0]
    end_node = random.sample(pedestrian_graph.G._sinks, 1)[0]
    init_state = start_node + (0,0)
    if age > 50:
        pedestrian_type = '2'
    else:
        pedestrian_type = random.choice(['1','2','3','4','5','6'])
    the_pedestrian = pedestrian.Pedestrian(init_state=init_state, pedestrian_type=pedestrian_type, name=name, age=age)
    return name, start_node, end_node, the_pedestrian
コード例 #2
0
wait_top_left_vertical = (355, 590 - offset_wait)
wait_top_left_horizontal = (355 + offset_wait, 590)

wait_bottom_left = (355, 170)
wait_bottom_left_vertical = (355, 170 + offset_wait)
wait_bottom_left_horizontal = (355 + offset_wait, 170)

wait_top_right = (705, 590)
wait_top_right_vertical = (705, 590 - offset_wait)
wait_top_right_horizontal = (705 - offset_wait, 590)

wait_bottom_right = (705, 170)
wait_bottom_right_vertical = (705, 170 + offset_wait)
wait_bottom_right_horizontal = (705 - offset_wait, 170)

pedestrian_1 = pedestrian.Pedestrian(init_state=[705, 590, -np.pi / 2, 0],
                                     pedestrian_type='1')
pedestrian_1.prim_queue.enqueue(((wait_top_right, wait_top_right, 15), 0))
pedestrian_1.prim_queue.enqueue(((wait_top_right, wait_top_left, 15), 0))
pedestrian_1.prim_queue.enqueue(((wait_top_left, wait_bottom_left, 15), 0))
pedestrian_1.prim_queue.enqueue(((wait_bottom_left, bottom_left, 10), 0))

pedestrian_2 = pedestrian.Pedestrian(
    init_state=[right_bottom[0], right_bottom[1], np.pi / 2, 0],
    pedestrian_type='2')
pedestrian_2.prim_queue.enqueue(((right_bottom, wait_bottom_right, 10), 0))
pedestrian_2.prim_queue.enqueue(((wait_bottom_right, bottom_right, 10), 0))

pedestrian_3 = pedestrian.Pedestrian(
    init_state=[left_bottom[0], left_bottom[1], np.pi / 2, 0],
    pedestrian_type='3')
pedestrian_3.prim_queue.enqueue(((left_bottom, wait_bottom_left, 10), 0))