diff --git a/src/communication.py b/src/communication.py index f227ac4..b3ffbd9 100644 --- a/src/communication.py +++ b/src/communication.py @@ -76,7 +76,6 @@ class Mode(str, Enum): EXPLORE = "explore" GOTOSTATION = "gotostation" TARGET = "target" - TARGET2 = "target2" COMPLETE = "complete" @@ -104,8 +103,13 @@ class Communication: def status(self): return self._status - def update(self): - pass + def update(self, edges): # TODO: FINISH + if(edges is None and self._status is Mode.EXPLORE): + self._status = Mode.GOTOSTATION + elif(edges is None): + pass + else: + pass # THIS FUNCTIONS SIGNATURE MUST NOT BE CHANGED """ Handles the callback if any message arrived """ diff --git a/src/main.py b/src/main.py index d951198..273b1e6 100644 --- a/src/main.py +++ b/src/main.py @@ -23,30 +23,18 @@ def run(): while(communication.planetname is None): communication.process_messages() - print("received Planet Name") - while(communication.status() is not Mode.COMPLETE): - while(communication.status() is Mode.GOTOSTATION): # should be triggered if current station has no unexplored edges + while(communication.status() is Mode.GOTOSTATION or communication.status() is Mode.TARGET): # should be triggered if current station has no unexplored edges for instructions in communication.navto: for instructions in communication.navto: + communication.update(None) move.turnto(instructions[1]) move.traversetonextstation(True) - communication.update() - while(communication.status() is Mode.TARGET): # should be triggered when communication gets TARGET signal from server - for instructions in communication.navto: - for instructions in communication.navto: - move.turnto(instructions[1]) - move.traversetonextstation(True) - communication.update() - - communication(move.getstationedges()) # TODO: Register in map + communication.update(move.getstationedges()) # TODO: Register in map move.turnto(communication.navto[0][1]) # TODO: add control mechanism to communication class - move.traversetonextstation(False) # TODO: let same control mechanism decide if station is known, also traversetonextstation needs a return value - - communication.update() - - + if(communication.check(move.traversetonextstation(False)) is False): # TODO: let same control mechanism decide if station is known, also traversetonextstation needs a return value + move.setcurdir(communication.getdir()) # DO NOT EDIT diff --git a/src/planet.py b/src/planet.py index 28e563e..24c0ce0 100644 --- a/src/planet.py +++ b/src/planet.py @@ -52,6 +52,7 @@ class Planet: self._planetmap = {} self._unexedge = [] self._curnode = None + self._curdir = Direction.NORTH self.target = None # Adds a bidirectional path defined between the start and end coordinates to the map and assigns the weight to it. @@ -74,6 +75,9 @@ class Planet: def getcurnode(self): return self._curnode + def getcurdir(self): + return self._curdir + def addtounexedge(self, node_edge_list): self._unexedge = self._unexedge + node_edge_list