Пример #1
0
    def click(self, click_coordinates: ndarray,
              parent_coordinates: ndarray) -> (int, bool, ndarray, ndarray):
        if self.visible:
            if MatrixUtils.includes_point(
                    click_coordinates,
                    self.relative_coordinates + parent_coordinates, self.width,
                    self.height):
                self.__clicked = not self.__clicked
                if self.__reward_given:
                    reward = 0
                else:
                    self.__reward_given = True
                    reward = self.__reward
                self.__on_click_listener(self)
                return reward, True, self._select_matrix(
                ), self.relative_coordinates

        return 0, False, None, None
Пример #2
0
    def click(self,
              click_coordinates: ndarray,
              parent_coordinates: ndarray = None
              ) -> (int, bool, ndarray, ndarray):
        click_on_window = False
        if self.visible:
            if MatrixUtils.includes_point(click_coordinates,
                                          self.relative_coordinates,
                                          self.width, self.height):
                click_on_window = True
                for child in self.children:
                    reward, click_on_child, matrix, coords = child.click(
                        click_coordinates, self.relative_coordinates)
                    if click_on_child:
                        MatrixUtils.blit_image_inplace(self.__current_matrix,
                                                       matrix, coords[0],
                                                       coords[1])
                        return reward, click_on_window, matrix, coords + self.relative_coordinates

        return 0, click_on_window, None, None
Пример #3
0
 def test_includes_point_click_outside(self):
     click = np.array([-2, 8])
     self.assertFalse(MatrixUtils.includes_point(click,
                                                 self.rectangle_origin,
                                                 self.rectangle_width,
                                                 self.rectangle_height))
Пример #4
0
 def test_includes_point_click_border(self):
     click = np.array([3, 6])
     self.assertTrue(MatrixUtils.includes_point(click,
                                                self.rectangle_origin,
                                                self.rectangle_width,
                                                self.rectangle_height))