diff --git a/main.py b/main.py index f50d836..d6121f1 100644 --- a/main.py +++ b/main.py @@ -198,6 +198,18 @@ def end(): print("--- End!") # 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(): N = [] # client, product @@ -207,6 +219,7 @@ def listNeeds(): N.append((c, p)) return N + while t < 10: N = listNeeds() newTurn()