def drawBackground(self): for row in range(self.config.layout.height): for col in range(self.config.layout.width): index = row * self.config.layout.width + col WINDOW_HOME.setProperty(PROPERTY_INACTIVE % index, self.config.layout.matrix[row][col]) # Start with a state of uniform False self.state = createTruthMatrix(self.config.layout.height, self.config.layout.width)
def step(self, time): # Ask the solver for the time log('Solving for the current time (%s)' % str(time)) solution = self.solver.resolveTime(time) solutionUTF8 = [uni.encode('utf-8') for uni in solution] log('Solution: ' + str(solutionUTF8)) truthMatrix = createTruthMatrix(self.layout.height, self.layout.width) success = self.highlight(self.layout.matrix, truthMatrix, solution) if not success: log('Unable to highlight solution. Reattempting with no spaces between words') truthMatrix = createTruthMatrix(self.layout.height, self.layout.width) success = self.highlight(self.layout.matrix, truthMatrix, solution, False) if success: log('Success') else: log('Failed to highlight solution again. Drawing best attempt') # Draw the result self.window.drawMatrix(truthMatrix)
def cleanup(self): '''Clear window properties''' truthMatrix = createTruthMatrix(self.layout.height, self.layout.width) self.window.drawMatrix(truthMatrix) pass