File: //proc/2/cwd/usr/lib/python2.4/Demo/curses/life.pyc
mò
‚=5Dc @ s d k Z d k Z d k Z d k Z d f d „ ƒ YZ d „ Z d „ Z d „ Z e d j o© yf e i ƒ Z
e i ƒ e i ƒ e
i
d ƒ e e
ƒ e
i
d ƒ e i ƒ e i ƒ e i ƒ Wqe
i
d ƒ e i ƒ e i ƒ e i ƒ e i ƒ qXn d S( Nt LifeBoardc B sP t Z d Z e d ƒ d „ Z d „ Z d „ Z d „ Z d d „ Z d „ Z RS( s Encapsulates a Life board
Attributes:
X,Y : horizontal and vertical size of the board
state : dictionary mapping (x,y) to 0 or 1
Methods:
display(update_board) -- If update_board is true, compute the
next generation. Then display the state
of the board and refresh the screen.
erase() -- clear the entire board
makeRandom() -- fill the board randomly
set(y,x) -- set the given cell to Live; doesn't refresh the screen
toggle(y,x) -- change the given cell from live to dead, or vice
versa, and refresh the screen display
t *c C s
h | _ | | _ | i i ƒ \ } } | d | d d | _ | _ | | _ | i i ƒ d | i d d } | i i d d | ƒ | i i | i d d | ƒ xU t
d | i ƒ D]A } | i i d | d d ƒ | i i d | | i d d ƒ q· W| i i ƒ d S( s¤ Create a new LifeBoard instance.
scr -- curses screen object to use for display
char -- character used to render live cells (default: '*')
i i t +t -i t |N(
t selft statet scrt getmaxyxt Yt Xt chart cleart border_linet addstrt ranget yt refresh( R R R R R
R R
( ( t&