Just another update

main
Michael Meyer-Geerken 2025-09-07 22:39:02 +02:00
parent e53b2cb918
commit c11bbbead7
1 changed files with 27 additions and 16 deletions

@ -46,13 +46,11 @@ class Room:
class RoomPath:
def __init__(self, from_id, from_door, room_id, to_door, to_id ):
self.from_id
self.from_door
self.room_id
self.to_door
self.to_id
self.from_id = from_id
self.from_door = from_door
self.room_id = room_id
self.to_door = to_door
self.to_id = to_id
def getFromId(self):
return self.from_id + str(self.from_door) + self.room_id
@ -61,7 +59,13 @@ class RoomPath:
return self.room_id + str(self.to_door)+ self.to_id
def getFullId(self):
return self.from_id + str(self.from_door) + self.room_id + str(self.to_door)+ self.to_id
return str(self.from_id) + str(self.from_door) + str(self.room_id) + str(self.to_door)+ str(self.to_id)
def __str__(self):
return self.getFullId()
def __repr__(self):
return self.getFullId()
class LibMapper:
@ -87,7 +91,6 @@ class LibMapper:
for x in range(6*self.no_of_rooms-1):
randdir = str(random.randint(0,5))
plan += randdir
# planzero += randdir + "[0]"
return plan
def createAllDoorPlan(self):
@ -124,7 +127,7 @@ class LibMapper:
result = self.requester.explore(plans)
print(result)
result_base = result["results"][0:1]
startRoomId = result_base[0][0]
#startRoomId = result_base[0][0]
print(result_base)
# create inverted plan (every id will be xored with 3 and set as current Room Id)
plan_inverted_base = self.createinvertedPlans(plan_base, result_base)
@ -154,13 +157,21 @@ class LibMapper:
plan_base, inversions = self.splitInvertedPlan(plan_inverted_base)
print(plan_base)
print(inversions)
room_pathes_base = self.createRoomPathes(result_base)
room_pathes_base = self.createBaseRoomPathes(result_base,plan_base)
print(room_pathes_base)
room_pathes_inverted = self.createRoomPathes(result_inverted_base)
print(room_pathes_inverted)
#room_pathes_inverted = self.createRoomPathes(result_inverted_base, plan_base)
#print(room_pathes_inverted)
def createBaseRoomPathes(self, result, plan):
spliced = str(result[0])
roompathes =[]
for i in range(0, len(plan)):
spliced += plan[i] + str(result[i+1])
print(spliced + " : " + str(len(spliced)))
for i in range(0,len(spliced)-4,2):
roompathes.append(RoomPath(spliced[i],spliced[i+1],spliced[i+2],spliced[i+3],spliced[i+4]))
return roompathes
def createRoomPathes(self,result):
pass
def splitInvertedPlan(self, plan_inverted_base):
return plan_inverted_base[3::4], plan_inverted_base[1::4]
@ -180,7 +191,7 @@ class LibMapper:
dump = json.loads(h.read())
except OSError:
pass
return dump[0][0], dump[1][0], dump[2][0]
return dump[0], dump[1], dump[2]
if __name__ == '__main__':