changes for temp render

This commit is contained in:
Niclas3006
2026-05-10 05:02:33 +02:00
parent 545f7bf454
commit fbfc2c7ed3
4 changed files with 61 additions and 21 deletions
+37 -12
View File
@@ -1,3 +1,4 @@
from argparse import ArgumentError
from math import log, ceil
from operator import itemgetter
from classes import *
@@ -87,9 +88,9 @@ class MST():
tour = []
for edge in tree:# go throug all edges and recursively walk down all that lead to new places, on return add back edge
if edge[0] == start and edge[1] not in visited:
if edge[0].get_location() == start.get_location() and edge[1].get_location() not in visited:
tour.append(edge)
visited.append(start) # visited only needs to be carried in for a node downwards but not upwards, since this is a MST
visited.append(start.get_location()) # visited only needs to be carried in for a node downwards but not upwards, since this is a MST
data = self._dfs_recursive(tree,edge[1],visited)
tour+= data # add subtree
tour.append((edge[1],edge[0],edge[2])) #append reversed edge
@@ -111,22 +112,46 @@ class MST():
return walk
class AlgorithmA(SolvingAlgorithm):
def __init__(self, space:MetricSpace, gMngr: GarageManager):
super().__init__(space, gMngr)
gar_set = set(gMngr.garages)
self.mst = MST(gar_set,space.distancefunction,space,True)
def getGarageForCar(self, car: Point):
def getGarageForCar(self, car: Car):
garagedata= self.garageManager.get_garage_at_location(car.get_location())
garagefound = garagedata[0]
garage: Garage = garagedata[1]
if(not garagefound):
raise ArgumentError("No garage found INSIDE of ALGO A")
if(not self.garageManager.is_full(garage)):
car.set_walk(0)
garage.cars_parked.append(car)
return garage
carParked = False
while not carParked:
walk = self.mst.get_dfs_eulerwalk(car,car.get_walk()) # implicite, position of car determines where it arrived!
if len(walk) <1: continue
if car.get_walk() >32:
raise ArgumentError("walk got over power 32, this is likely an error and an infinite loop")
currentGarage = self.garageManager.get_garage_at_location(car.get_location())
for x in walk:
currentGarage = self.garageManager.get_garage_at_location(
x[1].get_location()) # second argument of edge
##TODO Finish implementation, garage full case and proper start
if not self.garageManager.is_full(currentGarage):
garage.cars_parked.append(car)
return garage
car.add_to_walk(1)
return super().getGarageForCar(car)