Back to index

python3.2  3.2.2
Classes | Functions | Variables
turtledemo.minimal_hanoi Namespace Reference

Classes

class  Disc
class  Tower

Functions

def hanoi
def play
def main

Variables

tuple msg = main()

Function Documentation

def turtledemo.minimal_hanoi.hanoi (   n,
  from_,
  with_,
  to_ 
)

Definition at line 44 of file minimal_hanoi.py.

00044 
00045 def hanoi(n, from_, with_, to_):
00046     if n > 0:
00047         hanoi(n-1, from_, to_, with_)
00048         to_.push(from_.pop())
00049         hanoi(n-1, with_, from_, to_)

Definition at line 57 of file minimal_hanoi.py.

00057 
00058 def main():
00059     global t1, t2, t3
00060     ht(); penup(); goto(0, -225)   # writer turtle
00061     t1 = Tower(-250)
00062     t2 = Tower(0)
00063     t3 = Tower(250)
00064     # make tower of 6 discs
00065     for i in range(6,0,-1):
00066         t1.push(Disc(i))
00067     # prepare spartanic user interface ;-)
00068     write("press spacebar to start game",
00069           align="center", font=("Courier", 16, "bold"))
00070     onkey(play, "space")
00071     listen()
00072     return "EVENTLOOP"

Here is the call graph for this function:

Definition at line 50 of file minimal_hanoi.py.

00050 
00051 def play():
00052     onkey(None,"space")
00053     clear()
00054     hanoi(6, t1, t2, t3)
00055     write("press STOP button to exit",
00056           align="center", font=("Courier", 16, "bold"))

Here is the call graph for this function:


Variable Documentation

Definition at line 74 of file minimal_hanoi.py.