예제 #1
0
properties.write('Particle.affinity = {}\n'.format(Particle.affinity))
properties.write('Particle.aversion = {}\n'.format(Particle.aversion))
properties.write('Particle.interaction_chance = {}\n'.format(
    Particle.interaction_chance))
properties.write('Particle.cramming_chance = {}\n'.format(
    Particle.cramming_chance))
properties.write('Partition.threshold = {}\n'.format(Partition.threshold))
properties.write('particles_per_box = {}\n'.format(particles_per_box))
properties.write('height = {}\n'.format(height))
properties.write('width = {}\n'.format(width))
properties.write('num_of_frames = {}\n'.format(num_of_frames))
properties.close()

### Initial Box
path = os.path.join(partial_path, '{:03d}.png'.format(0))
box.image_out(path)
initialize_time = time.time() - start_time
print('Setup Complete')
print('Saved: {} in {:.3f}s'.format(path, initialize_time))

### Run simulation
for i in range(num_of_frames):

    time1 = time.time()

    box.partition_interaction()
    path = os.path.join(partial_path, '{:03d}.png'.format(i + 1))
    box.image_out(path)

    time2 = time.time()
    print('Saved: {} in {:.3f}s'.format(path, time2 - time1))