Example #1
0
 def test_location_null(self):
     # Create the cube without location tracker.
     cube = Cube(cube_input=self.cube_input, cube_side_length=2)
     try:
         cube.get_tracked_location()
         raise AssertionError("Error message did not raise.")
     except ValueError as error:
         assert str(error) == "No Tracked Location"
Example #2
0
    def _get_location_after_key(key: Key, cube: Cube) -> int:
        """Perform a move on the cube and find the tracked bit.

        :param key: Indicate the movement on the cube.
        :param cube: The cube object.
        :return: The new location of the tracked bit.
        """
        cube.shift(key=key)
        cube.shift_cubie_content()
        return cube.get_tracked_location()
Example #3
0
    def _check_effective_key(self, key: Key) -> bool:
        """Check if the given key moves the tracked item.

        :param key: The possible key that moves the location.
        :return: If the key actually moves the item. (Not Equal = True)
        """
        # Make a new copy of the cube.
        temp_cube = Cube(cube_input="_" * self._cube_size,
                         cube_side_length=self._side_length,
                         track_location=self._track_item_location)
        # Perform the desired shift.
        temp_cube.shift(key=key)
        # Return True if the location is changed.
        return temp_cube.get_tracked_location() != self._track_item_location
Example #4
0
    def _get_location(self, key: Key) -> int:
        """Get location of the tracked item after performing a effective key.

        :param key: One known effective effective key.
        :return: New location of the tracked item.
        """
        # Make a new copy of the cube.
        temp_cube = Cube(cube_input="_" * self._cube_size,
                         cube_side_length=self._side_length,
                         track_location=self._track_item_location)
        # Perform the desired shift and shift the content.
        temp_cube.shift(key=key)
        temp_cube.shift_cubie_content()

        # Return the new location of the tracked item.
        return temp_cube.get_tracked_location()