示例#1
0
    def test_kiva_creation(self):
        '''
        '''
        # Init Kiva
        kiva = Kiva(self.kiva_id, self.position, self.facing_direction,
                    self.carrying_pod, self.successfully_dropped,
                    self.motor_lifetime)

        # Assertions
        self.assertEqual(kiva.id, self.kiva_id)
        self.assertEqual(kiva.position, self.position)
        self.assertEqual(kiva.facing_direction, self.facing_direction)
        self.assertEqual(kiva.carrying_pod, self.carrying_pod)
        self.assertEqual(kiva.successfully_dropped, self.successfully_dropped)
        self.assertEqual(kiva.motor_lifetime, self.motor_lifetime)
    def test_turn_right_facing_right(self):
        '''
        '''
        # Init Kiva
        kiva = Kiva(self.kiva_id, self.position, FacingDirection.LEFT,
                    self.carrying_pod, self.successfully_dropped,
                    self.motor_lifetime)

        # Init KivaController
        terrain = TerrainMap()
        kiva_controller = KivaController(kiva, terrain)

        # Turn right
        kiva_controller.update(Commands.TURN_RIGHT)

        # Assertions
        self.assertEqual(kiva.id, self.kiva_id)
        self.assertEqual(kiva.position, self.position)
        self.assertEqual(kiva.facing_direction, FacingDirection.UP)
        self.assertEqual(kiva.carrying_pod, self.carrying_pod)
        self.assertEqual(kiva.successfully_dropped, self.successfully_dropped)
        self.assertEqual(kiva.motor_lifetime, self.motor_lifetime + int(1e3))
    def test_move_forward_facing_right(self):
        '''
        '''
        # Init Kiva
        kiva = Kiva(self.kiva_id, (1, 1), FacingDirection.RIGHT,
                    self.carrying_pod, self.successfully_dropped,
                    self.motor_lifetime)

        # Init KivaController
        terrain = TerrainMap()
        kiva_controller = KivaController(kiva, terrain)

        # Move
        kiva_controller.update(Commands.FORWARD)

        # Assertions
        self.assertEqual(kiva.id, self.kiva_id)
        self.assertEqual(kiva.position, (2, 1))
        self.assertEqual(kiva.facing_direction, FacingDirection.RIGHT)
        self.assertEqual(kiva.carrying_pod, self.carrying_pod)
        self.assertEqual(kiva.successfully_dropped, self.successfully_dropped)
        self.assertEqual(kiva.motor_lifetime, self.motor_lifetime + int(1e3))
示例#4
0
    print("┃       ┃       |                  |       ┃        ┃")
    print("┃       ┃       |------------------|       ┃        ┃")
    print("┃       ┃                                  ┃        ┃")
    print("┃       ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛        ┃")
    print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫")
    print("┃ Enter the Kiva Commands:                          ┃")
    print("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫")
    print("┃ R F F F F T F F L F R F F L F F F F R F D         ┃")
    print("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛")
    print()
    print("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓")
    print("┃ Init Kiva Robot                                   ┃")
    print("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛")
    initial_position = (7, 7)
    initial_direction_facing = FacingDirection.UP
    kiva = Kiva("K01W01", initial_position, initial_direction_facing)

    # Kiva State
    kiva.get_info()

    # Init KivaController
    terrain = TerrainMap()
    kiva_controller = KivaController(kiva, terrain)

    # Taking Pod
    print("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓")
    print("┃ Taking POD                                        ┃")
    print("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛")
    kiva_controller.update(Commands.TURN_RIGHT)
    kiva_controller.update(Commands.FORWARD)
    kiva_controller.update(Commands.FORWARD)