
    .hh                         S r SSK7   " S S\5      r " S S\5      rS rS rS	 r\	S
:X  a  \" 5       r
\" \
5        \" 5         gg)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                       \ rS rSrS rSrg)Disc   c                     [         R                  U SSS9  U R                  5         U R                  SUS-  S5        U R	                  US-  SSUS-  -
  5        U R                  5         g )	NsquareF)shapevisibleg      ?   g      @r      )Turtle__init__pu	shapesize	fillcolorst)selfns     A/opt/python-3.13.8/usr/lib/python3.13/turtledemo/minimal_hanoi.pyr   Disc.__init__   sV    He<	sAcE1%qtQ!B$'	     N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r      s    r   r   c                   *    \ rS rSrSrS rS rS rSrg)Tower   z-Hanoi tower, a subclass of built-in type listc                     Xl         g)z-create an empty tower. x is x-position of pegNx)r   r#   s     r   r   Tower.__init__    s    r   c                     UR                  U R                  5        UR                  SS[        U 5      -  -   5        U R	                  U5        g )Nij"   )setxr#   setylenappendr   ds     r   push
Tower.push#   s5    	tvv	tBs4yL !Ar   c                 R    [         R                  U 5      nUR                  S5        U$ )N   )listpopr(   r+   s     r   r2   	Tower.pop'   s    HHTN	sr   r"   N)	r   r   r   r   __doc__r   r-   r2   r   r   r   r   r   r      s    3r   r   c                     U S:  a@  [        U S-
  XU5        UR                  UR                  5       5        [        U S-
  X!U5        g g )Nr   r   )hanoir-   r2   )r   from_with_to_s       r   r6   r6   ,   s@    1uac5u%ac5% r   c                      [        S S5        [        5          [        S[        [        [
        5        [        SSSS9  g ! [         a     g f = f)Nspace   zpress STOP button to exitcenterCourier   boldalignfont)onkeyclearr6   t1t2t3write
Terminatorr   r   r   playrL   2   sG    	$w	GaR)#:	< s   %> 
A
Ac                  4   [        5         [        5         [        SS5        [        S5      q[        S5      q[        S5      q[        SSS5       H!  n [        R                  [        U 5      5        M#     [        SSS	S
9  [        [        S5        [        5         g)Nr   ii   r<   zpress spacebar to start gamer=   r>   rB   r;   	EVENTLOOP)htpenupgotor   rG   rH   rI   ranger-   r   rJ   rE   rL   listen)is    r   mainrW   <   su    D%'44=	tB	qB	sB1Qr]
Q  

(68	$
Hr   __main__N)r4   turtler   r   r1   r   r6   rL   rW   r   msgprintmainloopr   r   r   <module>r]      sX   $ 6 D &  Z
&C	#JJ r   