diff --git a/michael/icfprequests.py b/michael/icfprequests.py index 31a177a..fc69349 100644 --- a/michael/icfprequests.py +++ b/michael/icfprequests.py @@ -1,6 +1,5 @@ import requests import os.path -from argparse import Namespace from typing import List @@ -35,31 +34,31 @@ class Connections: class LibRequests: - config ={} - def __init__(self): self.config = LibConfig() - def select(self, problem, id=config.id): + def select(self, problem): selectJson = { - "id": id, + "id": self.config.id, "problemName": problem } response = requests.post(self.config.selectUrl, json=selectJson) + if not response.ok: + print(response.text) return response.json()["problemName"] - def explore(self, plans: List[str], id=config.id): + def explore(self, plans: List[str]): exploreJson = { - "id": id, + "id": self.config.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 ): + def guess(self, rooms: List[str], startingroom, connections): guessJson = { - "id": id, + "id": self.config.id, "map":{ "rooms": rooms, "startingRoom": startingroom, diff --git a/michael/libraryexplorer.py b/michael/libraryexplorer.py index 90a0f85..77b2856 100644 --- a/michael/libraryexplorer.py +++ b/michael/libraryexplorer.py @@ -1,46 +1,199 @@ +from icfprequests import LibRequests +import json +import os.path +import sys +import random -class Room +class ExploreError(Exception): + pass + +class LibraryMap: + + def __init__(self, problemName:str, no_of_rooms:int, startRoom): + self.no_of_rooms = no_of_rooms + self.problemName = problemName + self.rooms = [ startRoom ] + self.startRoom = startRoom + self.candidateRooms = [] + + def addRoom(self,room): + if len(self.rooms)