Nearest warehouse

This commit is contained in:
Geoffrey Frogeye 2016-02-11 21:40:06 +01:00
parent 042f668374
commit df1f75c876

13
main.py
View file

@ -198,6 +198,18 @@ def end():
print("--- End!") print("--- End!")
# IA # IA
def nearestW(p, pos):
minDist = math.inf
selW = None
for w in range(W):
if Wi[w][p] > 0:
dist = distance(Wp[w], pos)
if dist < minDist:
minDist = dist
selW = w
return selW
def listNeeds(): def listNeeds():
N = [] N = []
# client, product # client, product
@ -207,6 +219,7 @@ def listNeeds():
N.append((c, p)) N.append((c, p))
return N return N
while t < 10: while t < 10:
N = listNeeds() N = listNeeds()
newTurn() newTurn()