
    d                         d Z ddlT  G d de          Z G d de          Zd Zd Zd	 Ze	d
k    r! e            Z
 ee
            e             dS dS )a         turtle-example-suite:

         tdemo_minimal_hanoi.py

A minimal 'Towers of Hanoi' animation:
A tower of 6 discs is transferred from the
left to the right peg.

An imho quite elegant and concise
implementation using a tower class, which
is derived from the built-in type list.

Discs are turtles with shape "square", but
stretched to rectangles by shapesize()
 ---------------------------------------
       To exit press STOP button
 ---------------------------------------
    )*c                       e Zd Zd ZdS )Discc                    t                               | dd           |                                  |                     d|dz  d           |                     |dz  dd|dz  z
             |                                  d S )	NsquareF)shapevisibleg      ?   g      @r      )Turtle__init__pu	shapesize	fillcolorst)selfns     *  /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/turtledemo/minimal_hanoi.pyr   zDisc.__init__   st    He<<<			sAcE1%%%qtQ!B$'''					    N)__name__
__module____qualname__r    r   r   r   r      s#            r   r   c                   $    e Zd ZdZd Zd Zd ZdS )Towerz-Hanoi tower, a subclass of built-in type listc                     || _         dS )z-create an empty tower. x is x-position of pegN)x)r   r   s     r   r   zTower.__init__    s    r   c                     |                     | j                   |                    ddt          |           z  z              |                     |           d S )Nij"   )setxr   setylenappendr   ds     r   pushz
Tower.push#   sG    	tv	tBs4yyL !!!Ar   c                 d    t                               |           }|                    d           |S )N   )listpopr!   r$   s     r   r*   z	Tower.pop'   s%    HHTNN	sr   N)r   r   r   __doc__r   r&   r*   r   r   r   r   r      sG        33        r   r   c                     | dk    rSt          | dz
  |||           |                    |                                           t          | dz
  |||           d S d S )Nr   r   )hanoir&   r*   )r   from_with_to_s       r   r-   r-   ,   sb    1uuac5#u%%%ac5%%%%%% ur   c                      t          d d           t                       	 t          dt          t          t
                     t          ddd           d S # t          $ r Y d S w xY w)Nspace   zpress STOP button to exitcenterCourier   boldalignfont)onkeyclearr-   t1t2t3write
Terminatorr   r   r   playrC   2   s    	$w	GGGaR)#:	< 	< 	< 	< 	< 	<   s   3A 
A#"A#c                     t                       t                       t          dd           t          d          at          d          at          d          at          ddd          D ])} t                              t          |                      *t          ddd	
           t          t          d           t                       dS )Nr   ii   r3   zpress spacebar to start gamer4   r5   r9   r2   	EVENTLOOP)htpenupgotor   r>   r?   r@   ranger&   r   rA   r<   rC   listen)is    r   mainrN   <   s    DDD%'''44===	tB	qB	sB1Qr]]  
Q	
(68 8 8 8	$
HHH;r   __main__N)r+   turtler   r   r)   r   r-   rC   rN   r   msgprintmainloopr   r   r   <module>rT      s    $        6       D   & & &      Z
$&&C	E#JJJHJJJJJ r   