Fixed typo in enum name. Unexplored edge listing/saving should work now.

This commit is contained in:
d3rped 2018-03-26 17:38:41 +02:00
parent 58553e38d0
commit fc3a9465cc
3 changed files with 12 additions and 10 deletions

View file

@ -121,12 +121,12 @@ class Communication:
if(edges == [] and self._status is Mode.EXPLORE): if(edges == [] and self._status is Mode.EXPLORE):
if(self.planet.unexedge == []): if(self.planet.unexedge == []):
self.encode_message(Command.COMPLETE, None) self.encode_message(Command.COMPLETE, None)
self._status = Mode.Complete self._status = Mode.COMPLETE
self.process_messages() self.process_messages()
else: else:
self.navto = next(filter(lambda x: x is not None, map(lambda edge: self.planet.shortest_path(self.planet.getcurnode(), edge), self.planet.unexedge))) self.navto = next(filter(lambda x: x is not None, map(lambda edge: self.planet.shortest_path(self.planet.getcurnode(), edge), self.planet.unexedge)))
self._status = Mode.GOTOSTATION self._status = Mode.GOTOSTATION
else: elif(edges != []):
self.navto = [(self.planet.getcurnode(), edges[0])] self.navto = [(self.planet.getcurnode(), edges[0])]
def getdir(self): def getdir(self):

View file

@ -110,7 +110,10 @@ class Move:
def getstats(self): def getstats(self):
stats = list(self._odometry.coordinates_get()) stats = list(self._odometry.coordinates_get())
stats.append(self._sensor.bumperwaspressed) if(self._sensor.bumperwaspressed)
stats.append(-1)
else:
stats.append(1)
return stats return stats
def turnto(self, direction): def turnto(self, direction):

View file

@ -82,18 +82,17 @@ class Planet:
return self._curdir return self._curdir
def checkedges(self, testnode): def checkedges(self, testnode):
validedges = []
if(self._curnode not in self._planetmap): if(self._curnode not in self._planetmap):
self._planetmap[self._curnode] = {} self._planetmap[self._curnode] = {}
for edges in testnode: for edges in testnode:
if(edges in self._planetmap[self._curnode]): if(edges not in self._planetmap[self._curnode]):
testnode.remove(edges) validedges.append(edges)
if(testnode != [] and self._curnode not in self.unexedge): if(validedges != [] and self._curnode not in self.unexedge):
self.unexedge.append(self._curnode) self.unexedge.append(self._curnode)
if(len(testnode) <= 1 and self._curnode in self.unexedge): if(len(validedges) <= 1 and self._curnode in self.unexedge):
self.unexedge.remove(self._curnode) self.unexedge.remove(self._curnode)
print("MAP:", self._planetmap[self._curnode]) return validedges
print("NODES:", testnode)
return testnode
''' '''
Returns a shortest path between two nodes. Returns a shortest path between two nodes.