� ��^c@s5dZddlZddlZddlZdZdZdZdZedZeedd edd Z dZ dZ dZ d�Z d�Zd�Zdefd��YZdejfd��YZdefd��YZdefd��YZdefd��YZd�Zedkr1e�ej�ndS( s� turtle-example-suite: tdemo_nim.py Play nim against the computer. The player who takes the last stick is the winner. Implements the model-view-controller design pattern. i����Ni�i�iii ii ii?i�i�cCstjtt�S(N(trandomtrandintt MINSTICKSt MAXSTICKS(((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt randomrowscCsy|d|dA|dA}|dkr0t|�SxBtd�D]4}|||A}|||kr=||f}|Sq=WdS(Niiii(t randommovetrange(tstatetxoredtztstmove((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt computerzug!s   cCsot|�}x6trDtjdd�}|||dkkrPqqWtj|dk||d�}||fS(Niii(tmaxtTrueRR(RtmR trand((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR+s   tNimModelcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs ||_dS(N(tgame(tselfR((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt__init__6scCsr|jjtjtjgkr"dSt�t�t�g|_d|_d|_ |jj j �tj |j_dS(Ni( RRtNimtCREATEDtOVERRtstickstplayertNonetwinnertviewtsetuptRUNNING(R((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR9s  cCs�|j|}||j|<|jjj||||j�|j�rstj|j_|j|_ |jjj �nI|jdkr�d|_t |j�\}}|j ||�d|_ndS(Nii( RRRt notify_moveRt game_overRRRRt notify_overR R (Rtrowtcolt maxspalte((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR Bs     cCs|jdddgkS(Ni(R(R((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR PscCs+|j||krdS|j||�dS(N(RR (RR"R#((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyRSs(t__name__t __module__RRR R R(((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR5s    tStickcBs#eZd�Zd�Zd�ZRS(cCs�tjj|dt�||_||_||_|j||�\}}|jd�|j t dt d�|j d�|j �|j||�|jd�|j�dS(Ntvisibletsquareg$@g4@itwhite(tturtletTurtleRtFalseR"R#Rtcoordstshapet shapesizetHUNITtWUNITtspeedtputgototcolort showturtle(RR"R#Rtxty((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyRZs       cCskt|d�\}}dd|d|t}dd|t}|tdtdtd|tdfS(Niii i(tdivmodR2R1t SCREENWIDTHt SCREENHEIGHT(RR"R#tpackett remainderR8R9((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR.hscCs9|jjtjkrdS|jjj|j|j�dS(N(RRRRt controllerRR"R#(RR8R9((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pytmakemovens(R%R&RR.R@(((s-/usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR'Ys  tNimViewcBsAeZd�Zdd�Zd�Zd�Zd�Zd�ZRS(cCs�||_|j|_|j|_|jjd�|jjt�|jjd�tjdt�|_ |j j �|j j d�i|_ xJt d�D]<}x3t t�D]%}t|||�|j ||f s0      $E