Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/turtledemo/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/turtledemo/__pycache__/minimal_hanoi.cpython-35.pyc



��Yf�@s�dZddlTGdd�de�ZGdd�de�Zdd�Zd	d
�Zdd�Ze	d
kr�e�Z
ee
�e�dS)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@seZdZdd�ZdS)�DisccCsgtj|dddd�|j�|jd|dd�|j|ddd	|d�|j�dS)
N�shapeZsquareZvisibleFg�?�g@r�)�Turtle�__init__ZpuZ	shapesizeZ	fillcolor�st)�self�n�r�=/opt/alt/python35/lib64/python3.5/turtledemo/minimal_hanoi.pyrs

z
Disc.__init__N)�__name__�
__module__�__qualname__rrrrr
rsrc@s:eZdZdZdd�Zdd�Zdd�ZdS)	�Towerz-Hanoi tower, a subclass of built-in type listcCs
||_dS)z-create an empty tower. x is x-position of pegN)�x)r
rrrr
r szTower.__init__cCs<|j|j�|jddt|��|j|�dS)N��"ij���)Zsetxr�sety�len�append)r
�drrr
�push#sz
Tower.pushcCs tj|�}|jd�|S)Nr)�list�popr)r
rrrr
r's
z	Tower.popN)rrr�__doc__rrrrrrr
rsrcCsQ|dkrMt|d|||�|j|j��t|d|||�dS)Nrr)�hanoirr)rZfrom_Zwith_Zto_rrr
r,srcCsZtdd�t�y-tdttt�tddddd
�Wntk
rUYnXdS)N�space�zpress STOP button to exit�align�center�font�Courier��bold)r#r$r%)�onkey�clearr�t1�t2�t3�writeZ
Terminatorrrrr
�play2s
	
r,cCs�t�t�tdd�td�atd�atd�ax-tddd�D]}tjt	|��qRWt
dddd	d�ttd
�t
�dS)Nr���rrzpress spacebar to start gamer r!r"r#r$r%rZ	EVENTLOOPi���i������)r#r$r%)ZhtZpenupZgotorr(r)r*�rangerrr+r&r,Zlisten)�irrr
�main<s
	

r2�__main__N)
rZturtlerrrrrr,r2r�msg�printZmainlooprrrr
�<module>s