MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //proc/2/cwd/usr/local/ssl/lib/python2.4/Demo/curses/life.pyo
mò
‚=5Dc@sdkZdkZdkZdkZdfd„ƒYZd„Zd„Zd„Zedjo©yfei	ƒZ
eiƒeiƒe
i
dƒee
ƒe
i
dƒeiƒeiƒeiƒWqe
i
dƒeiƒeiƒeiƒeiƒqXndS(	Nt	LifeBoardcBsPtZdZedƒd„Zd„Zd„Zd„Zdd„Zd„Z	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
h|_||_|iiƒ\}}|d|dd|_|_||_|iiƒd|idd}|ii	dd|ƒ|ii	|idd|ƒxUt
d|iƒD]A}|ii	d|ddƒ|ii	d||iddƒq·W|iiƒdS(s¤Create a new LifeBoard instance.

        scr -- curses screen object to use for display
        char -- character used to render live cells (default: '*')
        iit+t-it|N(
tselftstatetscrtgetmaxyxtYtXtchartcleartborder_linetaddstrtrangetytrefresh(RRRRR
R	R
((t&/usr/lib/python2.4/Demo/curses/life.pyt__init__)s	
%cCsh|djp-|i|jp|djp|i|jotd||f‚nd|i||f<dS(sSet a cell to the live stateisCoordinates out of range %i,%iiN(txRR
RR	t
ValueErrorR(RRR((Rtset>s:cCsá|djp-|i|jp|djp|i|jotd||f‚n|ii||fƒo2|i||f=|ii	|d|ddƒn5d|i||f<|ii	|d|d|i
ƒ|iiƒdS(s+Toggle a cell's state between live and deadisCoordinates out of range %i,%iit N(RRR
RR	RRthas_keyRtaddchRR(RRR((RttoggleDs:"!cCsh|_|iddƒdS(s3Clear the entire board and update the board displaytupdate_boardiN(RRtdisplay(R((RterasePs	icCs‰|i|i}}|p¥xtd|ƒD]|}xstd|ƒD]b}|i	i
||fƒo%|ii|d|d|i
ƒq@|ii|d|ddƒq@Wq*W|iiƒdSnh}d|_xžtd|ƒD]}ttd|dƒt||dƒƒ}x[td|ƒD]J}d}	|i	i
||fƒ}xittd|dƒt||dƒƒD]>}
x5|D]-}|i	i
||
fƒo|	d}	qxqxWqkW|	|}	|	djoId|||f<|ii|d|d|i
ƒ|p
d|_qgq|	djo|od|||f<q|o+|ii|d|ddƒd|_qqWqÞW||_	|iiƒdS(s<Display the whole board, optionally computing one generationiiRNii(RR
R	tMtNRRtitjRRRRRRtdtboringtmaxtmintLtstlivetktl(RRR(R"R R!RR&RR'R)R*((RRUsN%&
)*

!	cCsnh|_x^td|iƒD]J}xAtd|iƒD]-}tiƒdjo|i||ƒq5q5WqWdS(s$Fill the board with a random patternif0.5N(	RRRR
R R	R!trandomR(RR R!((Rt
makeRandomzs	(
t__name__t
__module__t__doc__tordRRRRRR,(((RRs			%cCs<|i|dƒ|iƒ|i|ddƒ|iƒdS(s&Clear the space where the menu residesiiN(tstdscrtmovetmenu_ytclrtoeol(R1R3((Rt
erase_menu‚scCs;t||ƒ|i|ddƒ|i|dddƒdS(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(R5R1R3R(R1R3((Rtdisplay_menu‡s
c	Cs|iƒ|iƒ\}}|dd}t||ƒ|i|d|ddƒ}t|dt	dƒƒ}|iddƒ|id|i
d}}xq|id|d|ƒ|iƒ}d|jo
djnopt|ƒ}|d	jo|i||ƒq|d
jo¿t||ƒ|i|ddƒ|iƒ|idƒxg|iƒ}|d
joPn|idddƒ|iƒ|iƒ|idddƒ|iƒqOW|idƒt||ƒq|djo|iƒq|djoPq|djo|iƒ|iddƒq|djo|iƒqq™|tijo|djo|d}q™|tijo"||i
djo|d}q™|tijo|djo|d}q™|tijo"||idjo|d}q™q™WdS(NiiiRRRiis 
tCcis6 Hit any key to stop continuously updating the screen.iÿÿÿÿt/RtEetQqtRrtSs( R1RRtstdscr_ytstdscr_xR3R6tsubwinRR0tboardRR
R	txpostyposR2tgetchtctchrRR5RRtnodelayRR,tcursestKEY_UPtKEY_DOWNtKEY_LEFTt	KEY_RIGHT(	R1RARDRBR>R=R@R3R?((Rtmainsd








"





$$t__main__ii(R+tstringt	tracebackRGRR5R6RLR-tinitscrR1tnoechotcbreaktkeypadtechotnocbreaktendwint	print_exc(	R6RORNRGR+R5R1RLR((Rt?s&	k			8