예제 #1
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))
예제 #2
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))
예제 #3
0
from gol import GoL
from golImage import GoLImageRenderer
from utils import boardIO

if __name__ == '__main__':
    import utils.colormaps as cm

    golTraining = GoLImageRenderer("../data/images/training",
                                   512,
                                   512,
                                   colormap=cm.COLORMAP_WHITE_GREEN,
                                   showGridlines=True)
    for i in range(20):
        # Base settings
        rndThresh = random.random() * 0.4 + 0.2  # range 0.2 - 0.6
        board = boardIO.createRandomBoard(10, 10, rndThresh)
        gol = GoL(board)

        # Marked tiles
        colors = cm.COLORS_MARK3
        n = len(colors)

        allTiles = itertools.product(range(1, gol.width - 1),
                                     range(1, gol.height - 1))
        nTiles = random.sample(list(allTiles), n)
        for color, tile in zip(colors, nTiles):
            golTraining.addHighlight(tile, color, 5)

        # Record images
        golTraining.renderSettings.showNeighbours = False
        gol.name = f"Training{i:02d}_"
예제 #4
0
if __name__ == '__main__':
    vid = GoLVideoRenderer("../data/videos/colorChangingNewColorOnChange2.avi",
                           1920,
                           1080,
                           fps=24,
                           colormap=cm.getColorMapFor("298A08", "ffffff"))

    goalFrames = 10 * 60 * vid.fps
    k = 2  # Resolution * k = Number of cells
    while vid.frameNo < goalFrames:
        vid.renderSettings.colormap = cm.RandomColorProgressionIterator(
            cm.COLORS_DARK, ["ffffff"])
        print(f"Current Frames: {vid.frameNo}. Goal: {goalFrames}")
        rndThresh = random.random() * 0.2 + 0.4  # range 0.4 - 0.6
        print(f"On Cells: ~{rndThresh * 100:.2f}%")
        board = boardIO.createRandomBoard(192 * k,
                                          108 * k,
                                          rndThreshold=rndThresh)
        gol = GoL(board)
        abort = AbortDifHandler(board, extendGenerations=150)
        vid.appendGoL(gol,
                      1000,
                      abortCondition=AbortDifHandler(board),
                      onColorChange=0,
                      offColorChange=0)
        # try:
        #     vid.colormap.invert()
        # except AttributeError:
        #     pass
        # vid.colormap = cm.randomColormap(onColors=cm.COLORS_DARK, offColors=["ffffff"])
예제 #5
0
 def initRandom(self):
     self.board = boardIO.createRandomBoard(self.width, self.height)