def run_examples(): """ Run several examples """ print "iterative_factorial(4) is", iterative_factorial(4) print "merge([1, 3, 5, 8], [2, 4, 10]) is", merge([1, 3, 5, 8], [2, 4, 10]) print "recursive_factorial(4) is", recursive_factorial(4) print "merge_sort([4, 2, 1, 4, 6, 7, 2, 1]) is", merge_sort([4, 2, 1, 4, 6, 7, 2, 1]) # run gui to visualize wildfire poc_wildfire_gui.run_gui(WildFire(30, 40))
def run_examples(): """ Run several examples """ print "iterative_factorial(4) is", iterative_factorial(4) print "merge([1, 3, 5, 8], [2, 4, 10]) is", merge([1, 3, 5, 8], [2, 4, 10]) print "recursive_factorial(4) is", recursive_factorial(4) print "merge_sort([4, 2, 1, 4, 6, 7, 2, 1]) is", merge_sort( [4, 2, 1, 4, 6, 7, 2, 1]) # run gui to visualize wildfire poc_wildfire_gui.run_gui(WildFire(30, 40))
Return the size of the boundary of the fire """ return len(self._fire_boundary) def fire_boundary(self): """ Generator for the boundary of the fire """ for cell in self._fire_boundary: yield cell # alternative syntax #return (cell for cell in self._fire_boundary) def update_boundary(self): """ Function that spreads the wild fire using one step of BFS Updates both the cells and the fire_boundary """ cell = self._fire_boundary.dequeue() neighbors = self.four_neighbors(cell[0], cell[1]) #neighbors = self.eight_neighbors(cell[0], cell[1]) for neighbor in neighbors: if self.is_empty(neighbor[0], neighbor[1]): self.set_full(neighbor[0], neighbor[1]) self._fire_boundary.enqueue(neighbor) # run gui to visualize wildfire poc_wildfire_gui.run_gui(WildFire(30, 40))