aUCBLogo Demos and Tests / hanoi4
;Hi Andreas !
;Thank you for your response ,
;here is the demo reworked using updategraph ,
;so it will run under version 4.65
;Best Regards !
;mhelhefny
;------------------------hanoi4.lg--------------------------------------
to color
colors=[1 2 3 4 5 6 8 9 10 11 12 ]
end
to draw :i :d
make "x 0 if :d=="a[make "x -240] if :d=="b[make "x 240]
make "h run (word ": "h :d) setpc item :i :colors
pu setxy :x-(:i*9) (25*:h)-40 pd fd :i*18 waitms 4
updategraph
end
to hanoi :n :from :aux :to_
if :n== 0[stop]
hanoi :n- 1 :from :to_ :aux
move :n :from :to_
hanoi :n- 1 :aux :from :to_
end
to hanoi4
pr [type number of discs (max. 11) ?]
make "n first readList
color
make "ha 0 make "hb 0 make "hc 0 cs ht penpaint pd setpc 0
setlabelsize [25 45] htable hanoi :n "a "c "b
end
to move :n :from :to_
make "k run(word ": "h :to_) make word "h :to_ :k+1
setpensize [20 20] penpaint draw :n :to_ setpensize [23 23] pe draw :n :from
make "l run(word ": "h :from) make word "h :from :l-1
end
to htable
pu setxy -360 -40 penpaint setpensize [20 20] pd rt 90 fd 720
pu setxy -260 -80 label "A fd 240 label "B fd 240 label "C
for [i :n 1 -1][make "ha :ha+1 draw :i "a]
end