File "life.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/lib64/python2.7/Demo/curses/life.pyc
File size: 6.63 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit


Afc@sddlZddlZddlZddlZdd	dYZdZdZdZdZe	dkrej
endS(
iNt	LifeBoardcBsPeZdZeddZdZdZdZedZ	dZ
RS(sEncapsulates 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*cCs
i|_||_|jj\}}|d|dd|_|_||_|jjd|jdd}|jjdd||jj|jdd|xUtd|jD]A}|jjd|dd|jjd||jddqW|jj	dS(sCreate a new LifeBoard instance.

        scr -- curses screen object to use for display
        char -- character used to render live cells (default: '*')
        iit+t-it|N(
tstatetscrtgetmaxyxtXtYtchartcleartaddstrtrangetrefresh(tselfRR
R	Rtborder_linety((s(/usr/lib64/python2.7/Demo/curses/life.pyt__init__)s			
%cCsc|dks6|j|ks6|dks6|j|krLtd||fnd|j||f<dS(sSet a cell to the live stateisCoordinates out of range %i,%iiN(RR	t
ValueErrorR(RRtx((s(/usr/lib64/python2.7/Demo/curses/life.pytset?s6cCs|dks6|j|ks6|dks6|j|krLtd||fn|jj||fr|j||f=|jj|d|ddn4d|j||f<|jj|d|d|j|jjdS(s+Toggle a cell's state between live and deadisCoordinates out of range %i,%iit N(	RR	RRthas_keyRtaddchR
R(RRR((s(/usr/lib64/python2.7/Demo/curses/life.pyttoggleEs6!!cCsi|_|jdtdS(s3Clear the entire board and update the board displaytupdate_boardN(RtdisplaytFalse(R((s(/usr/lib64/python2.7/Demo/curses/life.pyteraseQs	cCsw|j|j}}|sxtd|D]z}xqtd|D]`}|jj||fr|jj|d|d|jq?|jj|d|ddq?Wq)W|jjdSi}d|_	xtd|D]}tt
d|dt||d}xPtd|D]?}d}|jj||f}	xgtt
d|dt||dD]<}
x3|D]+}|jj||
frq|d7}qqqqWqdW||	8}|dkrd|||f<|jj|d|d|j|	sUd|_	qUq|dkr%|	r%d|||f<q|	r|jj|d|ddd|_	qqWqW||_|jjdS(s<Display the whole board, optionally computing one generationiiRNii(RR	R
RRRRR
Rtboringtmaxtmin(RRtMtNtitjtdtLtstlivetktl((s(/usr/lib64/python2.7/Demo/curses/life.pyRVsB$&
	)0

!	cCsli|_x\td|jD]H}x?td|jD]+}tjdkr5|j||q5q5WqWdS(s$Fill the board with a random patternig?N(RR
RR	trandomR(RR#R$((s(/usr/lib64/python2.7/Demo/curses/life.pyt
makeRandom|s
	(t__name__t
__module__t__doc__tordRRRRtTrueRR,(((s(/usr/lib64/python2.7/Demo/curses/life.pyRs			&cCs<|j|d|j|j|dd|jdS(s&Clear the space where the menu residesiiN(tmovetclrtoeol(tstdscrtmenu_y((s(/usr/lib64/python2.7/Demo/curses/life.pyt
erase_menus
cCs;t|||j|dd|j|ddddS(s/Display the menu of possible keystroke commandsisAUse the cursor keys to move, and space or Enter to toggle a cell.isBE)rase the board, R)andom fill, S)tep once or C)ontinuously, Q)uitN(R6R(R4R5((s(/usr/lib64/python2.7/Demo/curses/life.pytdisplay_menus

c	Cs|j|j\}}|dd}t|||j|d|dd}t|dtd}|jdt|jd|j	d}}xR|j
d|d||j}d|kodknr9t|}|d	kr|j
||q|d
krt|||j|dd|j|jdxd|j}|d
krfPn|jddd|j|j|jddd|jqJW|jdt||q|dkr|jq|dkrPq|dkr|j|jdtq|dkr|jqq|tjkra|dkra|d8}q|tjkr||j	dkr|d7}q|tjkr|dkr|d8}q|tjkr||jdkr|d7}qqWdS(NiiiR
RRiis 
tCcis6 Hit any key to stop continuously updating the screen.it/RtEetQqtRrtSs(RRR7tsubwinRR0RRRR	R2tgetchtchrRR6RRtnodelayRR,tcursestKEY_UPtKEY_DOWNtKEY_LEFTt	KEY_RIGHT(	R4tstdscr_ytstdscr_xR5R>tboardtxpostypostc((s(/usr/lib64/python2.7/Demo/curses/life.pytkeyloopsd











"

"
cCst|dS(N(RM(R4((s(/usr/lib64/python2.7/Demo/curses/life.pytmainst__main__((R+tstringt	tracebackRBRR6R7RMRNR-twrapper(((s(/usr/lib64/python2.7/Demo/curses/life.pyt<module>s$n			?