Started working on mode handling
This commit is contained in:
parent
29849c2dd1
commit
3112046256
3 changed files with 16 additions and 20 deletions
|
@ -76,7 +76,6 @@ class Mode(str, Enum):
|
|||
EXPLORE = "explore"
|
||||
GOTOSTATION = "gotostation"
|
||||
TARGET = "target"
|
||||
TARGET2 = "target2"
|
||||
COMPLETE = "complete"
|
||||
|
||||
|
||||
|
@ -104,7 +103,12 @@ class Communication:
|
|||
def status(self):
|
||||
return self._status
|
||||
|
||||
def update(self):
|
||||
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
|
||||
|
|
22
src/main.py
22
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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue