class Grid: def __init__(self, width, height, default=0): self.width = width self.height = height self.clear(default) def clear(self, value): self.grid = [value for i in range(self.width*self.height)]; def isValid(self, x, y): return x>=0 and y>=0 and x