ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     
^c           @   s5  d  Z  d d l Z d d l Z d d l Z d Z d Z d Z d Z e d Z e e d d	 e d d
 Z	 d Z
 d Z d Z d   Z d   Z d   Z d e f d     YZ d e j f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d   Z e d k r1e   e j   n  d S(    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.
iNi  i  i   i   i   i   i   i   i?   i   i   c           C   s   t  j t t  S(   N(   t   randomt   randintt	   MINSTICKSt	   MAXSTICKS(    (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt	   randomrow   s    c         C   sy   |  d |  d A|  d A} | d k r0 t  |   SxB t d  D]4 } |  | | A} | |  | k r= | | f } | Sq= Wd  S(   Ni    i   i   i   (   t
   randommovet   range(   t   statet   xoredt   zt   st   move(    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt   computerzug!   s    
c         C   so   t  |   } x6 t rD t j d d  } |  | | d k k r Pq q Wt j | d k |  | d  } | | f S(   Ni    i   i   (   t   maxt   TrueR    R   (   R   t   mR	   t   rand(    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR   +   s    	 t   NimModelc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s   | |  _  d  S(   N(   t   game(   t   selfR   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt   __init__6   s    c         C   sr   |  j  j t j t j g k r" d  St   t   t   g |  _ d |  _ d  |  _	 |  j  j
 j   t j |  j  _ d  S(   Ni    (   R   R   t   Nimt   CREATEDt   OVERR   t   stickst   playert   Nonet   winnert   viewt   setupt   RUNNING(   R   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR   9   s    		c         C   s   |  j  | } | |  j  | <|  j j j | | | |  j  |  j   rs t j |  j _ |  j |  _	 |  j j j
   nI |  j d k r d |  _ t |  j   \ } } |  j | |  d |  _ n  d  S(   Ni    i   (   R   R   R   t   notify_moveR   t	   game_overR   R   R   R   t   notify_overR   R   (   R   t   rowt   colt	   maxspalte(    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR   B   s    	c         C   s   |  j  d d d g k S(   Ni    (   R   (   R   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR    P   s    c         C   s+   |  j  | | k r d  S|  j | |  d  S(   N(   R   R   (   R   R"   R#   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR   S   s    (   t   __name__t
   __module__R   R   R   R    R   (    (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR   5   s
   					t   Stickc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   t  j j |  d t | |  _ | |  _ | |  _ |  j | |  \ } } |  j d  |  j	 t
 d t d  |  j d  |  j   |  j | |  |  j d  |  j   d  S(   Nt   visiblet   squareg      $@g      4@i    t   white(   t   turtlet   TurtleR   t   FalseR"   R#   R   t   coordst   shapet	   shapesizet   HUNITt   WUNITt   speedt   put   gotot   colort
   showturtle(   R   R"   R#   R   t   xt   y(    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR   Z   s    			
c         C   sk   t  | d  \ } } d d | d | t } d d | t } | t d t d t d | t d f S(   Ni   i   i   i   (   t   divmodR2   R1   t   SCREENWIDTHt   SCREENHEIGHT(   R   R"   R#   t   packett	   remainderR8   R9   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR.   h   s    c         C   s9   |  j  j t j k r d  S|  j  j j |  j |  j  d  S(   N(   R   R   R   R   t
   controllerR   R"   R#   (   R   R8   R9   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt   makemoven   s    (   R%   R&   R   R.   R@   (    (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR'   Y   s   		t   NimViewc           B   sA   e  Z d    Z d d  Z d   Z d   Z d   Z d   Z RS(   c         C   s   | |  _  | j |  _ | j |  _ |  j j d  |  j j t  |  j j d  t j d t  |  _	 |  j	 j
   |  j	 j d  i  |  _ xJ t d  D]< } x3 t t  D]% } t | | |  |  j | | f <q Wq W|  j d  |  j j t  d  S(   Ni   i   R(   i    i   s   ... a moment please ...(   i   i   i   (   R   t   screent   modelt	   colormodet   tracerR-   t   bgcolorR+   R,   t   writerR4   R3   R   R   R   R'   t   displayR   (   R   R   R"   R#   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR   u   s    		'c         C   s   |  j  j t  |  j j   | d  k	 rt |  j j d t d d  |  j j d  |  j j	 | d d d d n  |  j j d t d d  |  j j d  |  j j	 | d d d d |  j  j t
  d  S(   Ni    i   i0   t   redt   alignt   centert   fontt   Courieri   t   boldi   t   blacki   (   RM   i   RN   (   RM   i   RN   (   RB   RE   R-   RG   t   clearR   R5   R<   t   pencolort   writeR   (   R   t   msg1t   msg2(    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyRH      s    c         C   s   |  j  j t  xO t d  D]A } x8 t |  j j |  D]  } |  j | | f j t  q: Wq WxR t d  D]D } x; t |  j j | t  D]  } |  j | | f j d  q Wqo W|  j	 d  |  j  j t
  d  S(   Ni   R*   s*   Your turn! Click leftmost stick to remove.(   RB   RE   R-   R   RC   R   R6   t   SCOLORR   RH   R   (   R   R"   R#   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR      s    " "c         C   s   | d k rI t  } x t | |  D]  } |  j | | f j |  q" Wn |  j d  t j d  |  j d  t } xI t | d | d d  D]- } t j d  |  j | | f j |  q W|  j d  d  S(	   Ni    s    ... thinking ...         g      ?s    ... thinking ... aaah ...i   ig?s*   Your turn! Click leftmost stick to remove.(   t   HCOLORR   R   R6   RH   t   timet   sleept   COLOR(   R   R"   R#   R$   R   t   farbeR
   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR      s    !!c         C   s8   |  j  j j d k r d } n d } |  j d |  d  S(   Ni    s   Congrats. You're the winner!!!s"   Sorry, the computer is the winner.s2   To play again press space bar. To leave press ESC.(   R   RC   R   RH   (   R   RT   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR!      s    	c         C   s)   |  j  j t j k r% |  j j   n  d  S(   N(   R   R   R   R   RB   RP   (   R   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyRP      s    N(	   R%   R&   R   R   RH   R   R   R!   RP   (    (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyRA   t   s   				t   NimControllerc           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  | j j |  _ t |  _ x' |  j j   D] } | j | j  q1 W|  j  j j	 |  j  j
 j d  |  j  j j	 |  j  j j d  |  j  j j d  |  j  j j   d  S(   Nt   spacet   Escapes   Press space bar to start game(   R   R   R   R-   t   BUSYt   valuest   onclickR@   RB   t   onkeyRC   R   RP   RH   t   listen(   R   R   t   stick(    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR      s    		c         C   s9   |  j  r d  St |  _  |  j j j | |  t |  _  d  S(   N(   R^   R   R   RC   R   R-   (   R   R"   R#   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR      s
    		(   R%   R&   R   R   (    (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR[      s   	R   c           B   s#   e  Z d  Z d Z d Z d   Z RS(   i    i   i   c         C   sF   t  j |  _ | |  _ t |   |  _ t |   |  _ t |   |  _	 d  S(   N(
   R   R   R   RB   R   RC   RA   R   R[   R?   (   R   RB   (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR      s
    	(   R%   R&   R   R   R   R   (    (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyR      s   c          C   s9   t  j   }  |  j d  |  j t t  t |   } d S(   Nt   standards
   EVENTLOOP!(   R+   t   Screent   modeR   R;   R<   R   (   t
   mainscreent   nim(    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt   main   s
    t   __main__(   i?   i?   i   (   i   i   i   (   i   i   i   (   t   __doc__R+   R    RW   R;   R<   R   R   R1   R2   RU   RV   RY   R   R   R   t   objectR   R,   R'   RA   R[   R   Ri   R%   t   mainloop(    (    (    s-   /usr/lib64/python2.7/Demo/turtle/tdemo_nim.pyt   <module>
   s0   
		
	
$E	