示例#1
0
    def test_knight_capture(self):
        test_board = ([[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0, 0, 0, 0], [0, 101, 0, 0, 0, 0, 0, 0],
                       [0, 0, 101, 0, 0, 0, 0, 0], [320, 0, 0, 0, 0, 0, 0, 0]])
        test_pos = (7, 0)

        actual_list = []
        MOVES.generate_knight(test_pos, test_board, actual_list)
        expected_list = [[(7, 0), (5, 1)], [(7, 0), (6, 2)]]

        assert len(expected_list) is len(actual_list)

        for move in expected_list:
            assert move in actual_list
示例#2
0
    def test_knight_simple(self):
        test_board = ([[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0],
                       [0, 0, 0, 320, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0],
                       [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]])
        test_pos = (4, 3)

        actual_list = []
        MOVES.generate_knight(test_pos, test_board, actual_list)
        expected_list = [[(4, 3), (6, 2)], [(4, 3), (6, 4)], [(4, 3), (2, 2)],
                         [(4, 3), (2, 4)], [(4, 3), (3, 1)], [(4, 3), (3, 5)],
                         [(4, 3), (5, 1)], [(4, 3), (5, 5)]]

        assert len(expected_list) is len(actual_list)

        for move in expected_list:
            assert move in actual_list