'Display the whole board, optionally computing one generation'

def display(self, update_board=True):

    (M, N) = (self.X, self.Y)
    if (not update_board):
        for i in range(0, M):
            for j in range(0, N):
                if ((i, j) in self.state):
                    self.scr.addch((j + 1), (i + 1), self.char)
                else:
                    self.scr.addch((j + 1), (i + 1), '    ')
        self.scr.refresh()
        return
    d = {}
    self.boring = 1
    for i in range(0, M):
        L = range(max(0, (i - 1)), min(M, (i + 2)))
        for j in range(0, N):
            s = 0
            live = ((i, j) in self.state)
            for k in range(max(0, (j - 1)), min(N, (j + 2))):
                for l in L:
                    if ((l, k) in self.state):
                        s += 1
            s -= live
            if (s == 3):
                d[(i, j)] = 1
                if curses.has_colors():
                    self.scr.attrset(curses.color_pair(random.randrange(1, 7)))
                self.scr.addch((j + 1), (i + 1), self.char)
                self.scr.attrset(0)
                if (not live):
                    self.boring = 0
            elif ((s == 2) and live):
                d[(i, j)] = 1
            elif live:
                self.scr.addch((j + 1), (i + 1), '    ')
                self.boring = 0
    self.state = d
    self.scr.refresh()
