home *** CD-ROM | disk | FTP | other *** search
- to putdisk :tnum :dnum :state
- !
- ! Called by HANOI to put a disk on a tower.
- ! first arg. is number of tower (1,2 or 3)
- ! second arg. is number of disk to draw (1 is smallest)
- ! third arg. is "final, "temp, or "erase depending on whether
- ! disk is drawn in final state, in temporary state to indicate
- ! motion, or is being erased (removed from this tower)
- ! Note that this procedure re-draws the tower correctly.
- !
- local "tc
- local "halfsize
- make "tc towercnt :tnum
- make "halfsize sum 20 product :dnum 10
- pu
- if :tnum = 1 [setxy "-240 "-100] [if :tnum = 2 [setxy "-15 "-100] [setxy 210 "-100]]
- pe
- fd product 30 :tc
- pu
- setxy xcor - :halfsize ycor
- pd
- if :state = "final [pencolor 3] [if :state = "temp [pencolor 1] [pe]]
- fd 30
- rt 90
- fd product :halfsize 2
- rt 90
- fd 30
- rt 90
- pu
- fd :halfsize
- rt 90
- pencolor 2
- if :state = "erase [pd; fd 30] [pe; fd 30]
- oflush
- end
-
-