From 3439e4d4039b7813f23564c4111c8f4e2e72842b Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 5 Sep 2025 23:15:17 +0200 Subject: [PATCH] Just an update --- Prob.json | 26 ++++++++++++++ icfprequests.py | 29 ---------------- michael/icfprequests.py | 70 ++++++++++++++++++++++++++++++++++++++ michael/libraryexplorer.py | 46 +++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 29 deletions(-) create mode 100644 Prob.json delete mode 100644 icfprequests.py create mode 100644 michael/icfprequests.py create mode 100644 michael/libraryexplorer.py diff --git a/Prob.json b/Prob.json new file mode 100644 index 0000000..a09f776 --- /dev/null +++ b/Prob.json @@ -0,0 +1,26 @@ +[ + { + "problem": "probatio", + "size": 3 + }, + { + "problem": "primus", + "size": 6 + }, + { + "problem": "secundus", + "size": 12 + }, + { + "problem": "tertius", + "size": 18 + }, + { + "problem": "quartus", + "size": 24 + }, + { + "problem": "quintus", + "size": 30 + } +] diff --git a/icfprequests.py b/icfprequests.py deleted file mode 100644 index c950033..0000000 --- a/icfprequests.py +++ /dev/null @@ -1,29 +0,0 @@ -import requests -import json - -endpointUrl = "https://31pwr5t6ij.execute-api.eu-west-2.amazonaws.com/" -selectUrl = endpointUrl + "select" -exploreUrl = endpointUrl + "explore" -guessUrl = endpointUrl + "guess" - -id = "icfp@zeuxis.de DHf1KQyE3vCvMqPaA4LLlw" - -def select( id, problem): - selectJson = { - "id": id, - "problemName": problem - } - response = requests.post(selectUrl, json=selectJson) - return response.json() - -def explore( id, plans): - exploreJson = { - "id": id, - "plans": plans - } - response = requests.post(exploreUrl, json=exploreJson) - return response.json() - - -def guess( id, rooms, startingroom, connections ): - pass \ No newline at end of file diff --git a/michael/icfprequests.py b/michael/icfprequests.py new file mode 100644 index 0000000..31a177a --- /dev/null +++ b/michael/icfprequests.py @@ -0,0 +1,70 @@ +import requests +import os.path +from argparse import Namespace +from typing import List + + +class APIError(Exception): + pass + + +class LibConfig: + endpointUrl = "https://31pwr5t6ij.execute-api.eu-west-2.amazonaws.com/" + selectUrl = endpointUrl + "select" + exploreUrl = endpointUrl + "explore" + guessUrl = endpointUrl + "guess" + + def __init__(self): + config = {} + with open(os.path.join(os.path.dirname(__file__), "..", "config")) as h: + for line in h.readlines(): + parts = line.strip().split("=") + self.__setattr__(parts[0].lower(), parts[1].replace('"', "")) + + +class Connections: + + def __init__(self): + self.connections = [] + + def add_connection(self, from_room, from_door, to_room, to_door): + connection = { "from":{"room": from_room, "door": from_door}, + "to":{"room": to_room, "door": to_door}} + self.connections.append(connection) + + +class LibRequests: + + config ={} + + def __init__(self): + self.config = LibConfig() + + def select(self, problem, id=config.id): + selectJson = { + "id": id, + "problemName": problem + } + response = requests.post(self.config.selectUrl, json=selectJson) + return response.json()["problemName"] + + def explore(self, plans: List[str], id=config.id): + exploreJson = { + "id": id, + "plans": plans + } + response = requests.post(self.config.exploreUrl, json=exploreJson) + return response.json() + + + def guess(self, rooms: List[str], startingroom, connections , id=config.id ): + guessJson = { + "id": id, + "map":{ + "rooms": rooms, + "startingRoom": startingroom, + "connections": connections.connections + } + } + response = requests.post(self.config.guessUrl, json=guessJson) + return response.json()["correct"] == "true" \ No newline at end of file diff --git a/michael/libraryexplorer.py b/michael/libraryexplorer.py new file mode 100644 index 0000000..90a0f85 --- /dev/null +++ b/michael/libraryexplorer.py @@ -0,0 +1,46 @@ + +class Room + + def __init__(self, room_id: str, pathcounter: int): + self.id = room_id + self.pathcount = pathcounter + self.rooms = [None for _ in range(6)] + + def createRoom(self,no: int,id): + self.rooms[no]=Room(id,self.pathcount+1) + + def full_id(self): + if self.id is None: + return None + fullid = self.id + for room in self.rooms: + if room is None: + return None + fullid = fullid + room.id + return fullid + + def rooms_without_id(self): + none_rooms = [] + for doorcounter, room in enumerate(self.rooms): + if room is None: + none_rooms.append(doorcounter) + return none_rooms + + def setRoomId(self,id:str): + if self.id is None & self.pathcount == 0: + self.id =id + else: + print("Id can not be set for initial Path Element!") + + +class LibMapper: + + def __init__(self, no_of_rooms_to_find): + self.no_of_rooms = no_of_rooms_to_find + + def start(self): + + +if __name__ == '__main__': + +