Beispiel #1
0
def get_orientation_char(orientation):
    direction_to_char = {
        Direction.NORTH: "↑",
        Direction.SOUTH: "↓",
        Direction.WEST: "←",
        Direction.EAST: "→",
        Direction.STAY: "*",
    }
    direction = Direction.get_direction_from_number(orientation)
    return direction_to_char[direction]
Beispiel #2
0
    def test_direction_number_conversion(self):
        all_directions = Direction.ALL_DIRECTIONS
        all_numbers = []

        for direction in Direction.ALL_DIRECTIONS:
            number = Direction.get_number_from_direction(direction)
            direction_again = Direction.get_direction_from_number(number)
            self.assertEqual(direction, direction_again)
            all_numbers.append(number)

        # Check that all directions are distinct
        num_directions = len(all_directions)
        self.assertEqual(len(set(all_directions)), num_directions)
        # Check that the numbers are 0, 1, ... num_directions - 1
        self.assertEqual(set(all_numbers), set(range(num_directions)))