From 284edb9e0a51811d841e6c5ab3f3f0cf3b95e273 Mon Sep 17 00:00:00 2001 From: d3rped Date: Mon, 19 Mar 2018 05:14:58 +0100 Subject: [PATCH] Added an example to explanations in sensor.py and corrected data type of planetmap in planet.py. --- src/planet.py | 12 ++++++++++-- src/sensor.py | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/planet.py b/src/planet.py index f724d50..a97985c 100644 --- a/src/planet.py +++ b/src/planet.py @@ -23,7 +23,14 @@ Weight = int 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: """ 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): """ 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 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: 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]]]: diff --git a/src/sensor.py b/src/sensor.py index db9d081..6a06310 100644 --- a/src/sensor.py +++ b/src/sensor.py @@ -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: RED = (>90, <40, <25) 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)) '''