예제 #1
0
    def test_square_within_beam_distance(self):
        # arrange
        s = SpaceMap([1101, 100, -1, 4, 0])

        m = [
            '#.......................................',
            '.#......................................',
            '..##....................................',
            '...###..................................',
            '....###.................................',
            '.....####...............................',
            '......#####.............................',
            '......######............................',
            '.......#######..........................',
            '........########........................',
            '.........#########......................',
            '..........#########.....................',
            '...........##########...................',
            '...........############.................',
            '............############................',
            '.............#############..............',
            '..............##############............',
            '...............###############..........',
            '................###############.........',
            '................#################.......',
            '.................########OOOOOOOOOO.....',
            '..................#######OOOOOOOOOO#....',
            '...................######OOOOOOOOOO###..',
            '....................#####OOOOOOOOOO#####',
            '.....................####OOOOOOOOOO#####',
            '.....................####OOOOOOOOOO#####',
            '......................###OOOOOOOOOO#####',
            '.......................##OOOOOOOOOO#####',
            '........................#OOOOOOOOOO#####',
            '.........................OOOOOOOOOO#####',
            '..........................##############',
            '..........................##############',
            '...........................#############',
            '............................############',
            '.............................###########'
        ]
        testPoints = [(25, 20), (20, 19), (26, 20), (26, 22)]
        testResult = [True, False, False, True]
        result = []

        # act
        points = s.LoadMap(m)
        for p in testPoints:
            x, y = p
            result.append(s.SquareWithinBeam(x, y, 10))

        # assert
        self.assertEquals(result, testResult)
예제 #2
0
    def test_print_map(self):
        # arrange
        s = SpaceMap([1101, 100, -1, 4, 0])
        m = [
            '#.........', '.#........', '..##......', '...###....',
            '....###...', '.....#O##.', '......####', '......####',
            '.......###', '........##'
        ]

        # act
        points = s.LoadMap(m)
        lines = s.PrintSpaceMap()

        # assert
        self.assertEqual(lines, 10)
예제 #3
0
    def test_find_square_distance(self):
        # arrange
        s = SpaceMap([1101, 100, -1, 4, 0])

        m = [
            '#.......................................',
            '.#......................................',
            '..##....................................',
            '...###..................................',
            '....###.................................',
            '.....####...............................',
            '......#####.............................',
            '......######............................',
            '.......#######..........................',
            '........########........................',
            '.........#########......................',
            '..........#########.....................',
            '...........##########...................',
            '...........############.................',
            '............############................',
            '.............#############..............',
            '..............##############............',
            '...............###############..........',
            '................###############.........',
            '................#################.......',
            '.................########OOOOOOOOOO.....',
            '..................#######OOOOOOOOOO#....',
            '...................######OOOOOOOOOO###..',
            '....................#####OOOOOOOOOO#####',
            '.....................####OOOOOOOOOO#####',
            '.....................####OOOOOOOOOO#####',
            '......................###OOOOOOOOOO#####',
            '.......................##OOOOOOOOOO#####',
            '........................#OOOOOOOOOO#####',
            '.........................OOOOOOOOOO#####',
            '..........................##############',
            '..........................##############',
            '...........................#############',
            '............................############',
            '.............................###########'
        ]

        # act
        points = s.LoadMap(m)
        result = s.FindSquareDistance()

        # assert
        self.assertEqual(result, 250020)
예제 #4
0
    def test_load_map(self):
        # arrange
        s = SpaceMap([1101, 100, -1, 4, 0])
        m = [
            '#.........', '.#........', '..##......', '...###....',
            '....###...', '.....####.', '......####', '......####',
            '.......###', '........##'
        ]

        # act
        points = s.LoadMap(m)
        print(points)
        result = s.GetAffectedCells()

        # assert
        self.assertEqual(result, 27)