home *** CD-ROM | disk | FTP | other *** search
/ Dimension 64 13 / Dimension_64_Nr.13_19xx_-_de_Side_A.d64 / t.v.hanoi (.txt) < prev   
Commodore BASIC  |  2023-02-26  |  4KB  |  152 lines

  1. 190 rem die tuerme von hanoi
  2. 200 poke53280,7:poke53281,7:gosub1520
  3. 210 poke53280,6:poke53281,6
  4. 220 t$="[146] [146][164][146][175][146][185][146][162][184][183][163]"
  5. 230 b$="[164][175][185][162][146][184][146][183][146][163][146] "
  6. 240 dimtp$(8),t$(8),bt$(8),b$(8),cs$(20)
  7. 250 cs$(2)="[144]":cs$(04)="[154]":cs$(06)=""
  8. 260 cs$(8)="[159]":cs$(10)="[156]":cs$(12)=""
  9. 270 cs$(14)="[149]"
  10. 280 fori=1to8
  11. 290 c$=mid$(t$,2*i,1):c$=c$+c$+c$:c$=c$+c$+c$:c$=left$(c$+c$,14)
  12. 300 tp$(i)=mid$(t$,2*i-1,1)+c$
  13. 310 c$=mid$(b$,2*i,1):c$=c$+c$+c$:c$=c$+c$+c$:c$=left$(c$+c$,14)
  14. 320 bt$(i)=mid$(b$,2*i-1,1)+c$
  15. 330 nexti
  16. 340 l$=" [180][161][146][170][146] "
  17. 350 r$="[146] [146][180][146][161][170] "
  18. 360 dimlf$(5),rt$(5)
  19. 370 fori=1to5:lf$(i)=mid$(l$,2*i-1,2):rt$(i)=mid$(r$,2*i-1,2):nexti
  20. 380 cr$=chr$(13)
  21. 390 print"[147][129]wieviel scheiben (2 - 7) ? ";:gosub 1400
  22. 400 ifin$=""then390
  23. 410 fori=1tolen(in$)
  24. 420 :t$=mid$(in$,i,1):ift$>="0"andt$<="9"then440
  25. 430 print"[145][145][145]":goto390
  26. 440 nexti
  27. 450 n=val(in$):ifn>7thenprint"[129]nicht mehr als 7 [145][145][145][145][145][145]":fory=1to999:nexty:goto390
  28. 460 ifn<2thenprint"[145][145][145]":goto390
  29. 470 dn$=""
  30. 480 rt$=""
  31. 490 fori=1to3:forj=0to7:p(i,j)=0:nextj:nexti
  32. 500 print"[147]";dn$;"";:p(1,0)=n
  33. 510 fori=1to3:print"[129]                                        ";:nexti
  34. 520 printdn$;"[129]#1#2#3"
  35. 530 printdn$;left$("[145][145][145][145][145][145][145]",n);
  36. 540 fori=1ton:printcs$(i*2);
  37. 550 printleft$("[146]"+rt$,7-i+1);left$("[164]"+bt$(1),2*i+1);"[164]"
  38. 560 p(1,n-i+1)=i*2
  39. 570 nexti
  40. 580 mv=0
  41. 590 tm=ti+60
  42. 600 ifti<tmthen600
  43. 610 gosub1350
  44. 620 pr$="von welcher plattform? ":gosub1250:ifin$=""then610
  45. 630 f=val(in$)
  46. 640 ifp(f,0)<1thenprint"dieser platz ist leer.":goto590
  47. 650 pr$="[156]wohin damit ? ":gosub1250:ifin$=""then610
  48. 660 t=val(in$)
  49. 670 iff=tthenprint"dieser zug geht nicht.":goto590
  50. 680 ifp(t,0)=0then700
  51. 690 ifp(f,p(f,0))>p(t,p(t,0))thenprint"das geht nicht.":goto590
  52. 700 fc=p(f,0):fw=p(f,fc):tc=p(t,0):tw=p(t,tc):mv=mv+1
  53. 710 x=1+13*(f-1)+7-fw/2:print""cs$(fw)
  54. 720 print dn$;left$("[145][145][145][145][145][145][145][145][145]",fc+1);left$("[146]"+rt$+rt$+rt$,x);
  55. 730 lf$=left$("[157][157][157][157][157][157][157][157][157][157][157][157][157][157]",fw+1)
  56. 740 fori=1to 8:t$(i)=left$(tp$(i),1+fw):b$(i)=left$(bt$(i),1+fw):nexti
  57. 750 ht=0:j=1:iff>tthenj=-1
  58. 760 fori=ftotstepj
  59. 770 ifp(i,0)>htthenht=p(i,0)
  60. 780 nexti
  61. 790 ifht=p(t,0)thenht=ht+1:goto810
  62. 800 ifabs(f-t)>1thenifht=p(2,0)thenht=ht+1
  63. 810 fori=fctoht
  64. 820 :for j=1to8
  65. 830 :printt$(j);lf$;b$(j);lf$;"[145][145]";
  66. 840 :nextj
  67. 850 :print"[145]";
  68. 860 nexti
  69. 870 print"";
  70. 880 l$=left$("[157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157]",1+fw):r$=left$(rt$,fw-1)
  71. 890 print"";left$("                ",fw);"[146]";left$("[157][157][157][157][157][157][157][157][157][157][157][157][157][157][157][157]",fw);
  72. 900 iff>tthen980
  73. 910 fori=f*13tot*13-1
  74. 920 :forj=1to5
  75. 930 printlf$(j);r$;rt$(j);l$;
  76. 940 nextj
  77. 950 print"";
  78. 960 nexti
  79. 970 goto1040
  80. 980 fori=t*13tof*13-1
  81. 990 print"[157]";
  82. 1000 :forj=5to1step-1
  83. 1010 ::printlf$(j);r$;rt$(j);l$;
  84. 1020 :nextj
  85. 1030 nexti
  86. 1040 fori=ht-1totcstep-1
  87. 1050 :forj=8to1step-1
  88. 1060 :printt$(j);lf$;b$(j);lf$;"[145][145]";
  89. 1070 :nextj
  90. 1080 :print"";
  91. 1090 nexti
  92. 1100 printleft$("[164]"+bt$(1),fw+1);"[164]"
  93. 1110 p(t,0)=p(t,0)+1
  94. 1120 p(t,p(t,0))=p(f,p(f,0))
  95. 1130 p(f,0)=p(f,0)-1
  96. 1140 ifp(2,0)<>nandp(3,0)<>nthen590
  97. 1150 gosub1350
  98. 1160 print"[144]        [172][162][162][162][162][162][162][162][162][162][162][162][162][187]"
  99. 1170 print"        [161]geschafft!! [146][161]"
  100. 1180 print"        [188][162][162][162][162][162][162][162][162][162][162][162][162][146][190]"
  101. 1190 print"[158]du hast";mv;"schritte dazu gebraucht":print
  102. 1200 t=2^n-1:print"[159]am kuerzesten waeren"t"schritte."
  103. 1210 print"[156]noch eins? ";:gosub1400
  104. 1220 ifleft$(in$,1)<>"j"thenend
  105. 1230 run
  106. 1240 end
  107. 1250 printpr$;
  108. 1260 gosub1400:ifin$=""thenreturn
  109. 1270 ifleft$(in$,1)="q"thenend
  110. 1280 iflen(in$)>1then1300
  111. 1290 ifin$>="1"andin$<="3"thenreturn
  112. 1300 print"falsche eingabe !!!"
  113. 1310 fori=1to500:nexti
  114. 1320 print"[145]                      "
  115. 1330 print"[145][145]";pr$;left$("                                        ",len(in$))
  116. 1340 print"[145]";:goto1250
  117. 1350 print"";
  118. 1360 fori=1to5:print"                                       ":nexti
  119. 1370 print"";
  120. 1380 return
  121. 1390 print""
  122. 1400 in$=" ":zt=ti:zc=2:zd$=chr$(20)
  123. 1410 getz$:if z$<>""then1440
  124. 1420 ifzt<=tithenprintmid$(" [166]",zc,1);"[157]";:zc=3-zc:zt=ti+15
  125. 1430 goto1410
  126. 1440 z=asc(z$):zl=len(in$):if(zand127)<32thenprint" [157]";:goto1480
  127. 1450 iffland(zand127)>64and(zand127)<91thenz$=chr$((z+128)and255)
  128. 1460 ifzl>254then1410
  129. 1470 in$=in$+z$:printz$;zd$;z$;
  130. 1480 ifz=13thenin$=mid$(in$,2):printcr$;:return
  131. 1490 ifz=20andzl>1thenin$=left$(in$,zl-1):print"[157]";:goto1410
  132. 1500 ifz=141thenz$=chr$(-20*(zl>1)):forz=2tozl:printz$;:nextz:goto1400
  133. 1510 goto1410
  134. 1520 print"[147]*** [129]commodore 64 *** [129]tuerme v. hanoi ***"chr$(142)chr$(8)
  135. 1530 print"[144]du hast 3 platten mit einer anzahl von"
  136. 1540 print" scheiben. die aufgabe ist,die scheiben"
  137. 1550 print" an einer anderen stelle in gleicher"
  138. 1560 print" anordnung aufzubauen."
  139. 1570 print"es darf aber dabei immernur eine"
  140. 1580 print" kleinere scheibe auf eine groessere"
  141. 1590 print" scheibe gesetzt werden."
  142. 1600 print"mit so wenig schritten wie moeglich."
  143. 1610 print""
  144. 1620 gosub1640
  145. 1630 return
  146. 1640 print"   bitte auf die leertaste druecken.
  147. 1650 [129]i[178]1[164]250:[130]
  148. 1660 [153]"   bitte auf die leertaste druecken.
  149. 1670 fori=1to250:next
  150. 1680 geta$:ifa$=" "thenreturn
  151. 1690 goto1640
  152.