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))
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))
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))
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))
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))
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))
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))