Lines Matching +full:fill +full:- +full:range
2 # life.py -- A curses-based version of Conway's Game of Life.
7 # R : Fill the board randomly
31 display(update_board) -- If update_board is true, compute the
34 erase() -- clear the entire board
35 makeRandom() -- fill the board randomly
36 set(y,x) -- set the given cell to Live; doesn't refresh the screen
37 toggle(y,x) -- change the given cell from live to dead, or vice
44 scr -- curses screen object to use for display
45 char -- character used to render live cells (default: '*')
50 self.X, self.Y = X-2, Y-2-1
55 border_line = '+'+(self.X*'-')+'+'
58 for y in range(0, self.Y):
66 raise ValueError, "Coordinates out of range %i,%i"% (y,x)
72 raise ValueError, "Coordinates out of range %i,%i"% (y,x)
90 for i in range(0, M):
91 for j in range(0, N):
101 for i in range(0, M):
102 L = range( max(0, i-1), min(M, i+2) )
103 for j in range(0, N):
106 for k in range( max(0, j-1), min(N, j+2) ):
110 s -= live
125 "Fill the board with a random pattern"
127 for i in range(0, self.X):
128 for j in range(0, self.Y):
146 'E)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uit')
152 menu_y = (stdscr_y-3)-1
156 subwin = stdscr.subwin(stdscr_y-3, stdscr_x, 0, 0)
176 # Activate nodelay mode; getch() will return -1
181 if c != -1:
202 elif c == curses.KEY_UP and ypos>0: ypos -= 1
203 elif c == curses.KEY_DOWN and ypos<board.Y-1: ypos += 1
204 elif c == curses.KEY_LEFT and xpos>0: xpos -= 1
205 elif c == curses.KEY_RIGHT and xpos<board.X-1: xpos += 1