Ejemplo n.º 1
0
 def setUp(self):
     self.board = Board(columns=3, rows=3, n_shapes=10, immovable_shape=-1)
     board = np.array([
         [-1, -1, -1],
         [-1, 0, -1],
         [-1, -1, 0]
     ])
     self.board.set_board(board)
     self.searcher = MatchesSearcher(3, 2)
Ejemplo n.º 2
0
    def setUp(self):
        self.board_3x3_zeros = Board(3, 3, 3)
        self.board_3x3_zeros.set_board(
            np.array([[0, 0, 0], [0, 0, 1], [1, 2, 2]]))

        self.board_3x3_seq = Board(3, 3, 9)
        self.board_3x3_seq.set_board(
            np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]))

        self.board_4x4_big_angle = Board(columns=4, rows=4, n_shapes=6)
        self.board_4x4_big_angle.set_board(
            np.array([[0, 1, 2, 3], [0, 0, 5, 5], [0, 1, 3, 1], [0, 0, 0, 1]]))
        self.searcher_three = MatchesSearcher(3, 2)
Ejemplo n.º 3
0
class TestMatchesSearcher(unittest.TestCase):
    def setUp(self):
        self.board_3x3_zeros = Board(3, 3, 3)
        self.board_3x3_zeros.set_board(
            np.array([[0, 0, 0], [0, 0, 1], [1, 2, 2]]))

        self.board_3x3_seq = Board(3, 3, 9)
        self.board_3x3_seq.set_board(
            np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]))

        self.board_4x4_big_angle = Board(columns=4, rows=4, n_shapes=6)
        self.board_4x4_big_angle.set_board(
            np.array([[0, 1, 2, 3], [0, 0, 5, 5], [0, 1, 3, 1], [0, 0, 0, 1]]))
        self.searcher_three = MatchesSearcher(3, 2)

    @staticmethod
    def __to_coord(args):
        return sorted([i.get_coord() for i in args])

    def test_scan_board(self):
        zeros_answer = self.searcher_three.scan_board_for_matches(
            self.board_3x3_zeros)
        zeros_true = {Cell(0, 0, 0), Cell(0, 0, 1), Cell(0, 0, 2)}

        seq_answer = self.searcher_three.scan_board_for_matches(
            self.board_3x3_seq)
        seq_true = set()

        angle_answer = self.searcher_three.scan_board_for_matches(
            self.board_4x4_big_angle)
        angle_true = {
            Cell(0, 0, 0),
            Cell(0, 1, 0),
            Cell(0, 2, 0),
            Cell(0, 3, 0),
            Cell(0, 3, 1),
            Cell(0, 3, 2)
        }

        with self.subTest(object='zeros'):
            self.assertEqual(zeros_true, zeros_answer)

        with self.subTest(object='sequential'):
            self.assertEqual(seq_true, seq_answer)

        with self.subTest(object='angle'):
            self.assertEqual(angle_true, angle_answer)
Ejemplo n.º 4
0
class TestSearcherImmove(TestSearcher):
    def setUp(self):
        self.board = Board(columns=3, rows=3, n_shapes=10, immovable_shape=-1)
        board = np.array([[-1, -1, -1], [-1, 0, -1], [-1, -1, 0]])
        self.board.set_board(board)
        self.searcher = MatchesSearcher(3, 2)

    def test_points_generator(self):
        answer = {i for i in self.searcher.points_generator(self.board)}
        true = {Point(1, 1), Point(2, 2)}
        self.assertEqual(true, answer)