Пример #1
0
    def testMediumBoard(self):
        board = boardIO.loadCompressedBoard(TEST_DIR + "mediumRulesTest")
        validBoard1 = boardIO.loadCompressedBoard(TEST_DIR +
                                                  "mediumRulesTestResult1")
        validBoard21 = boardIO.loadCompressedBoard(TEST_DIR +
                                                   "mediumRulesTestResult21")

        gol = GoL(initBoard=board)
        gol.step()
        nextBoard = gol.board
        self.assertTrue(boardIO.checkEquals(nextBoard, validBoard1))
        gol.step(20)
        nextBoard = gol.board
        self.assertTrue(boardIO.checkEquals(nextBoard, validBoard21))
Пример #2
0
    def testCompressedRandomMedium(self):
        filename = TEST_DIR + "medium"

        originalBoard = boardIO.createRandomBoard(*BoardIOTest.MEDIUM_SIZE)
        boardIO.saveCompressedBoard(originalBoard, filename)
        loadedBoard = boardIO.loadCompressedBoard(filename)
        self.assertTrue(boardIO.checkEquals(originalBoard, loadedBoard))
Пример #3
0
    def testCompressedRandomSmall(self):
        filename = TEST_DIR + "small.boardC"

        originalBoard = boardIO.createRandomBoard(*BoardIOTest.SMALL_SIZE)
        boardIO.saveCompressedBoard(originalBoard, filename)
        loadedBoard = boardIO.loadCompressedBoard(filename)
        self.assertTrue(boardIO.checkEquals(originalBoard, loadedBoard))
Пример #4
0
    def testStatic(self):
        board = [
            [1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
            [1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
            [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 1, 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],
        ]

        gol = GoL(initBoard=board)
        gol.step(100)
        nextBoard = gol.board

        self.assertTrue(boardIO.checkEquals(nextBoard, board))
Пример #5
0
    def testEmptyBoard(self):
        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],
        ]

        boardTest = boardIO.emptyBoard(len(board), len(board[0]))
        self.assertTrue(boardIO.checkEquals(board, boardTest))
Пример #6
0
    def test2Oszillator2(self):
        board = [
            [1, 1, 0, 0, 0],
            [1, 0, 0, 0, 0],
            [0, 0, 0, 1, 0],
            [0, 0, 1, 1, 0],
            [0, 0, 0, 0, 0],
        ]

        gol = GoL(initBoard=board)
        gol.step(2)
        nextBoard = gol.board

        self.assertTrue(boardIO.checkEquals(nextBoard, board))
Пример #7
0
    def testSmallBoard(self):
        board = [
            [1, 1, 0, 1, 0],
            [1, 0, 1, 0, 1],
            [0, 0, 1, 0, 1],
            [1, 1, 0, 1, 0],
            [1, 0, 0, 0, 0],
        ]

        nextBoardValidated = [[1, 1, 1, 1, 0], [1, 0, 1, 0,
                                                1], [1, 0, 1, 0, 1],
                              [1, 1, 1, 1, 0], [1, 1, 0, 0, 0]]
        gol = GoL(initBoard=board)
        gol.step()
        nextBoard = gol.board
        self.assertTrue(boardIO.checkEquals(nextBoard, nextBoardValidated))