-
Notifications
You must be signed in to change notification settings - Fork 0
/
turfu.py
75 lines (66 loc) · 2.43 KB
/
turfu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from carte import *
from productType import *
from warehouse import *
from delivery import *
from drone import *
from droneManager import *
class Parser:
def __init__(self, fileName):
self.f = open(fileName)
self.lines = self.f.readlines()
self.parseFirstSection();
self.parseSecondSection();
self.f.close()
def parseFirstSection(self):
line = self.lines[0].split()
rows = int(line[0])
cols = int(line[1])
# Creation de la carte
self.carte = Carte(rows, cols)
Drone.number = int(line[2])
T = int(line[3])
Drone.weight = int(line[4])
def parseSecondSection(self):
line = self.lines[1].split()
ProductType.number = int(line[0])
productWeightList = self.lines[2].split()
productTypeList = []
for i in range(ProductType.number):
productTypeList.append(ProductType(i, productWeightList[i]))
self.convertSeqToInt(productWeightList)
Warehouse.number = int(self.lines[3])
warehouseIndexLine = 2;
warehouseList = []
for i in range(Warehouse.number):
warehouseIndexLine += 2
position = self.lines[warehouseIndexLine].split()
self.convertSeqToInt(position)
productList = self.lines[warehouseIndexLine+1].split()
self.convertSeqToInt(productList)
warehouseList.append(Warehouse(position, productList))
orderIndexLine = warehouseIndexLine + 2
Delivery.number = int(self.lines[orderIndexLine])
orderIndexLine = orderIndexLine - 2
deliveryList = []
for i in range(Delivery.number):
orderIndexLine += 3
deliveryPosition = self.lines[orderIndexLine].split()
self.convertSeqToInt(deliveryPosition)
numberOfProducts = int(self.lines[orderIndexLine+1])
productTypeList = self.lines[orderIndexLine+2].split()
self.convertSeqToInt(productTypeList)
deliveryList.append(Delivery(deliveryPosition, productTypeList))
for i in range(Warehouse.number):
self.carte.setMaisonOn(warehouseList[i])
for i in range(Delivery.number):
self.carte.setMaisonOn(deliveryList[i])
self.droneManager = DroneManager(self.carte, Drone.number, warehouseList, deliveryList, productList)
def convertSeqToInt(self, L):
for i in range(len(L)):
L[i] = int(L[i]);
def getDroneManager(self):
return self.droneManager
if __name__ == "__main__":
parser = Parser("mother_of_all_warehouses.in");
droneManager = parser.getDroneManager()
droneManager.process()