Just an update
parent
10a976fc70
commit
3439e4d403
@ -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
|
||||
}
|
||||
]
|
||||
@ -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
|
||||
@ -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"
|
||||
@ -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__':
|
||||
|
||||
|
||||
Loading…
Reference in New Issue