diff --git a/toyrobot/robot.py b/toyrobot/robot.py index a768da8..a139d1b 100644 --- a/toyrobot/robot.py +++ b/toyrobot/robot.py @@ -1,7 +1,11 @@ class Robot: """ Class representing a single "Toy Robot". Robots instances have knowledge - of their position, direction, and movement limits. + of their position, direction, and movement limits (i.e. "board" size). + + Note: Direction is specified via compass points (north, west, etc). As per + the original problem description, the coordinates (0, 0) represent the + SOUTHWEST corner of the board. Attributes: DEFAULT_MAX_X (int): The default maximum allowable horizontal @@ -11,6 +15,9 @@ class Robot: DIRECTIONS (dict): A dictionary (str: int) of direction names (e.g. NORTH, EAST etc) and their numerical encoding. Only the keys are intended for use externally as a list of valid directions. + VALID_COMMANDS (list): A list of valid commands that can be interpreted + by the robot. The PLACE command requires at least two additional + parameters. See the complete problem description for more details. """ DEFAULT_MAX_X = 5 @@ -328,5 +335,5 @@ class Robot: return "{},{},{}".format( self._position_x, self._position_y, - {v: k for k, v in Robot.DIRECTIONS.items()}[self._direction], + self.get_direction() ) diff --git a/trexamples.py b/trexamples.py index c60ec0e..b3196b5 100644 --- a/trexamples.py +++ b/trexamples.py @@ -11,19 +11,19 @@ def feed_file(filename: str, robot: toyrobot.Robot): def main(): print('a)') - feed_file('example_a.txt', toyrobot.Robot(6, 6)) + feed_file('example_a.txt', toyrobot.Robot()) print() print('b)') - feed_file('example_b.txt', toyrobot.Robot(6, 6)) + feed_file('example_b.txt', toyrobot.Robot()) print() print('c)') - feed_file('example_c.txt', toyrobot.Robot(6, 6)) + feed_file('example_c.txt', toyrobot.Robot()) print() print('d)') - feed_file('example_d.txt', toyrobot.Robot(6, 6)) + feed_file('example_d.txt', toyrobot.Robot()) print() if __name__ == "__main__":