def simular(n, v, x, y, h): start = time.time() g = s.simu(n=n, v=v, phi=2.3, probas=y, frec=x, h=h) stop = time.time() print(stop - start) plt.plot(v, g, '.') plt.show() return g
orderManager = OrderManager() order_idx = 4 + nb_warehouse*2 nb_orders = int(parser.get_line(order_idx)[0]) for i in range(nb_orders): coords = parser.get_line(order_idx + 1 + i*3) x = coords[1] y = coords[0] products_needed = parser.get_line(order_idx + 3 + i*3) #print("x {0} / y {1} / pro_len {2}".format(x, y, len(products_needed))) orderManager.add_order(i, x, y, products_needed) return warehouseManager, orderManager, droneManager if __name__ == "__main__": file = sys.argv[1] if len(sys.argv) > 1 else 'busy_day' if not file.endswith('.in'): file_name = file + '.in' else: file_name = file input_fn = 'input2016-{0}'.format(file_name) input = os.path.join(INPUT_FILE_DIR, input_fn) p = Parser(input) p.parse() warehouseManager, orderManager, droneManager = create_model(p) simu(droneManager, orderManager, warehouseManager) output_file = 'output2016-{0}.out'.format(file) nb_lines = droneManager.write_output(output_file) print("{0} lines has been printed to {1}".format(nb_lines, output_file))
direction = 'right' elif pos[0] - target[0] > 0: direction = 'left' elif pos[1] - target[1] < 0: direction = 'up' elif pos[1] - target[1] > 0: direction = 'down' self.move(direction) else: self.move(random.choice(['up', 'down', 'left', 'right'])) # Initialize the simulator S = simu.simu(walls = [[13, 25, 30, 25], [10, 15, 25, 15], [11, 5, 11, 16], [24, 5, 24, 16]]) # Add some agents of class my_agent to the bottom of the window starting # from origo.. for i in xrange(20): S.add_agent(my_agent('stupid_agent' + str(i), (255, 255, 0)), (i, 0)) # Run the simulation S.run()