def mutate(self, iteration): self.iteration = iteration mainNeighborhood = _Neighborhood(neighborhoodWidth=self.matrix.columns, topCoordinate=0, leftCoordinate=0) #currentEntropy = self._getNeighborhoodEntropy(neighborhood = mainNeighborhood) #print " begin mutate, entropy =", currentEntropy evenFinalInstructions = self._recursiveStep( level=0, neighborhood=mainNeighborhood, oddEven="EVEN") image_utils.writeBitArray2DImage( bitArray=self.matrix, filename=str(self.iteration).zfill(5) + "_even.png") oddFinalInstructions = self._recursiveStep( level=0, neighborhood=mainNeighborhood, oddEven="ODD") image_utils.writeBitArray2DImage( bitArray=self.matrix, filename=str(self.iteration).zfill(5) + "_odd.png") finalInstructions = evenFinalInstructions + oddFinalInstructions # print " end mutate, finalInstructions =", finalInstructions self.topLevelInstructions = finalInstructions
import BitArray2D import mutator import os import image_utils os.system("clear") print "Executing Matt's GI Experiment\n" iterationHashes = {} #inputMatrix = image_utils.getBitArray2DFromBitmapFile(filename = "alice_and_dodo.bmp", width = 512) #inputMatrix = BitArray2D.BitArray2D(bitstring = "11111111\n10011011\n11010101\n10011011\n10101011\n10011011\n10001101\n11111111") inputMatrix = mutator.getRandomBitMatrix(width=256) image_utils.writeBitArray2DImage(bitArray=inputMatrix, filename="00000" + "__initial.png") m = mutator.Mutator(matrix=inputMatrix, topLevelInstructions=None) iterationHashes[m.getSha1Hash()] = True for i in xrange(0, 200): m.mutate(iteration=i) print "iteration", i, "complete" newHash = m.getSha1Hash() if newHash in iterationHashes: print "halting, cycle detected on iteration", i break iterationHashes[m.getSha1Hash()] = True
import BitArray2D import mutator import os import image_utils os.system("clear") print "Executing Matt's HTM Experiment\n" for i in xrange(0, 10000): inputMatrix = mutator.getRandomBitMatrix(width=256) image_utils.writeBitArray2DImage(bitArray=inputMatrix, filename="img_" + str(i).zfill(5) + ".png") print "iteration", i, "complete"