Merge stuff

This commit is contained in:
Geoffrey Frogeye 2016-02-11 20:38:29 +01:00
parent 8a58caa99e
commit 0fefade86b
2 changed files with 16 additions and 24 deletions

34
main.py
View file

@ -18,26 +18,26 @@ C = 0 # Nb customers
t = -1 # Turn
Dp = []; # Positions of drones
Dp = [] # Positions of drones
# (x, y)
Di = []; # Items of drones
Di = [] # Items of drones
# {product number: qt}
Dd = []; # Turn avaibility of drone
Dd = [] # Turn avaibility of drone
# int
Da = []; # Avaibles drones
Da = [] # Avaibles drones
# int
Pw = []; # Weight of products
Pw = [] # Weight of products
# int
Wp = []; # Positions of warehouses
Wp = [] # Positions of warehouses
# (x, y)
Wi = []; # Items of warehouses
Wi = [] # Items of warehouses
# {product number: qt}
Cp = []; # Positions of customers
Cp = [] # Positions of customers
# (x, y)
Ci = []; # Needs of customers
Ci = [] # Needs of customers
# {product number: qt}
# Reading raw data
@ -99,7 +99,6 @@ for d in range(D):
Dp.append(Wp[0])
Di.append(dict((p, 0) for p in range(P)))
Dd.append(0)
Out = '' # Drones commands
# Debug
@ -139,7 +138,7 @@ def load(d, w, p, q):
Di[d][p] += +q
assert(Wp[w][p] >= 0)
assert(weight(d) <= M)
assert(Dd[d] <= T);
assert(Dd[d] <= T)
print("Drone", d, "loads", q, "of", p, "from warehouse", w, "", Dd[d])
def unload(d, w, p, q):
@ -149,7 +148,7 @@ def unload(d, w, p, q):
Dd[d] += distance(Dp[d], Wp[w])
Wi[w][p] += +q
Di[d][p] += -q
assert(Dd[d] <= T);
assert(Dd[d] <= T)
print("Drone", d, "unloads", q, "of", p, "from warehouse", w, "", Dd[d])
def deliver(d, c, p, q):
@ -160,7 +159,7 @@ def deliver(d, c, p, q):
Ci[w][p] += +q
Di[d][p] += -q
Dd[d] += 1
assert(Dd[d] <= T);
assert(Dd[d] <= T)
print("Drone", d, "delivers", q, "of", p, "to client", w, "", Dd[d])
def wait(d, w=1):
@ -183,11 +182,10 @@ def newTurn():
def end():
print("--- End!")
Out = '' # Drones commands
# IA
#Out file
f = open(sys.argv[1] + '_out', 'w')
# Output
f = open(sys.argv[1] + 'o', 'w')
f.write(len(Out)/10 + '\n' + Out)
f.close()
f.close()

6
out.py
View file

@ -1,6 +0,0 @@
#Out file
def CreateOutFile():
f = open(sys.argv[1], 'w')
f.write(len(Out)/10 + '\n' + Out)
f.close()