//usr/lib64/lib64//lib64/lib64//ó
V
Qc @ s^ 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 e j ƒ Z e j d ƒ e j e e ƒ d „ Z e d k rZe ƒ 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.
iÿÿÿÿNi€ 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&