def run_swarm(n): boids = [] for count in range(0,n): b_x_pos = random.randint(0,WIDTH) b_y_pos = random.randint(0,HEIGHT) b_x_vel = random.randint(-400,400) b_y_vel = random.randint(-400,400) boid = [b_x_pos, b_y_pos, b_x_vel, b_y_vel, random_color()] boids = boids + [boid] # Call the function run_display which we imported from the # file/module boids_display.py. run_display takes a list of boids, # the name of a function which describes how each boids position # and speed should be updated as time passes, and the width and # the height of the display window. run_display(boids, update_boids, WIDTH, HEIGHT)
def run_swarm(): # Create two creatures (boids). Place them at a random position on # the screen, give them a random velocity, and a random color. b1_x_pos = random.randint(0,WIDTH) b1_y_pos = random.randint(0,HEIGHT) b1_x_vel = random.randint(-400,400) b1_y_vel = random.randint(-400,400) boid1 = [b1_x_pos, b1_y_pos, b1_x_vel, b1_y_vel, random_color()] b2_x_pos = random.randint(0,WIDTH) b2_y_pos = random.randint(0,HEIGHT) b2_x_vel = random.randint(0,400) b2_y_vel = random.randint(0,400) boid2 = [b2_x_pos, b2_y_pos, b2_x_vel, b2_y_vel, random_color()] boids = [boid1, boid2] # Call the function run_display which we imported from the # file/module boids_display.py. run_display takes a list of boids, # the name of a function which describes how each boids position # and speed should be updated as time passes, and the width and # the height of the display window. run_display(boids, update_boids, WIDTH, HEIGHT)