Example #1
0
def do_init():

    # position everyone randomly about the canvas
    (x_min, y_min, x_max, y_max) = agentsim.gui.get_canvas_coords()

    # because we create additional zombies, we want to remove them 
    # from the simulation before we start.  We might as well remove all
    # the persons and start fresh.

    for p in Person.get_all_instances():
       Person.del_instance(p) 

    # create all the new people at the party
    create_persons(init_num_normals, init_num_defenders, init_num_zombies)

    # position them randomly about
    for p in Person.get_all_instances():
        i = 3
        while not position_randomly(p, x_min, x_max, y_min, y_max) and i > 0 :
            i -= 1

        # if after 3 tries we could not position p, then make it leave the party
        if i <= 0:
            print("Could not position {} into random spot".format(p.get_name()))
            p.leave()

    # have all the people arrive at the simulation before we start
    for p in Person.get_all_instances():
        p.arrive()