Added an example to explanations in sensor.py and corrected data type of planetmap in planet.py.

This commit is contained in:
d3rped 2018-03-19 05:14:58 +01:00
parent aca3c3b70f
commit 284edb9e0a
2 changed files with 14 additions and 3 deletions

View file

@ -23,7 +23,14 @@ Weight = int
never 0 never 0
""" """
'''
https://www.python.org/dev/peps/pep-0289/
Node checking:
((0,0),Direction.NORTH) in planetmap[0]
Simplify this for node search:
next(x for (x, y), direction in planetmap[0])
next(y for x, y in planetmap[0] if x == (0, 0))
'''
class Planet: class Planet:
""" """
Contains the representation of the map and provides certain functions to manipulate it according to the specifications Contains the representation of the map and provides certain functions to manipulate it according to the specifications
@ -31,7 +38,7 @@ class Planet:
def __init__(self): def __init__(self):
""" Initializes the data structure """ """ Initializes the data structure """
self.planetmap = {((0, 0), Direction.NORTH):((0, 1), Direction.SOUTH), "weight":1} self.planetmap = [{((0, 0), Direction.NORTH):((0, 1), Direction.SOUTH), "weight":1}]
self.target = None self.target = None
def add_path(self, start: Tuple[Tuple[int, int], Direction], target: Tuple[Tuple[int, int], Direction], weight: int): def add_path(self, start: Tuple[Tuple[int, int], Direction], target: Tuple[Tuple[int, int], Direction], weight: int):
@ -41,6 +48,7 @@ class Planet:
example: example:
add_path(((0, 3), Direction.NORTH), ((0, 3), Direction.WEST), 1) add_path(((0, 3), Direction.NORTH), ((0, 3), Direction.WEST), 1)
""" """
self.planetmap.append({start:target, "weight":weight})
def get_paths(self) -> Dict[Tuple[int, int], Dict[Direction, Tuple[Tuple[int, int], Direction, Weight]]]: def get_paths(self) -> Dict[Tuple[int, int], Dict[Direction, Tuple[Tuple[int, int], Direction, Weight]]]:

View file

@ -7,7 +7,10 @@ add enum for color definitions (type should be tupel of int's).
later onwards compare the idividual readouts like this to determine the color: later onwards compare the idividual readouts like this to determine the color:
RED = (>90, <40, <25) RED = (>90, <40, <25)
BLUE = (<25, >75, >90) BLUE = (<25, >75, >90)
still needs to be tested and implemented
Example:
color = (100, 30, 20)
(color[0] > 90 and (color[1], color[2]) < (40, 25))
''' '''