Almost functionnal
This commit is contained in:
parent
0fefade86b
commit
c56e442d29
17
main.py
17
main.py
|
@ -5,8 +5,6 @@ import sys
|
|||
|
||||
print("#hashcode2016")
|
||||
|
||||
import read
|
||||
|
||||
X = 0 # Nb rows
|
||||
Y = 0 # Nb columns
|
||||
D = 0 # Nb drones
|
||||
|
@ -100,6 +98,8 @@ for d in range(D):
|
|||
Di.append(dict((p, 0) for p in range(P)))
|
||||
Dd.append(0)
|
||||
|
||||
Out = [] # Drones commands
|
||||
|
||||
# Debug
|
||||
|
||||
assert(len(Dp) == len(Di) == len(Dd) == D)
|
||||
|
@ -165,10 +165,14 @@ def deliver(d, c, p, q):
|
|||
def wait(d, w=1):
|
||||
assert(d in Da)
|
||||
Dd[d] += w
|
||||
Da.remove(d)
|
||||
print("Drone", d, "waits", w, "turn" + ('s' if w >= 2 else ''), "→", Dd[d])
|
||||
Out.append(str(d) + ' W ' + str(w))
|
||||
|
||||
|
||||
# Control
|
||||
def newTurn():
|
||||
global t
|
||||
t += 1
|
||||
print("--- Turn", t)
|
||||
for d in Da:
|
||||
|
@ -176,16 +180,17 @@ def newTurn():
|
|||
assert(len(Da) == 0)
|
||||
for d in range(D):
|
||||
if Dd[d] <= t:
|
||||
Da.push(d)
|
||||
print("Drones", ", ".join(Da), "(", len(Da), ")", "are avaible")
|
||||
Da.append(d)
|
||||
print("Drones", ", ".join([str(d) for d in Da]), "(", len(Da), ")", "are avaible")
|
||||
|
||||
def end():
|
||||
print("--- End!")
|
||||
|
||||
Out = '' # Drones commands
|
||||
# IA
|
||||
newTurn()
|
||||
newTurn()
|
||||
|
||||
# Output
|
||||
f = open(sys.argv[1] + 'o', 'w')
|
||||
f.write(len(Out)/10 + '\n' + Out)
|
||||
f.write(str(len(Out)) + '\n' + '\n'.join(Out))
|
||||
f.close()
|
||||
|
|
Reference in a new issue