home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 49 / 049.d81 / animals (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  4KB  |  150 lines

  1. 10 gosub60100:clr:print"[147]"chr$(142)
  2. 100 dim tr(999,2),q$(999)
  3. 117 gosub 9000
  4. 140 goto600
  5. 500 print"[147]is there a file of animals to use? (y/n)"
  6. 510 get a$:if a$="" then 510
  7. 520 if a$="n" then 570
  8. 525 if a$<>"y" then 510
  9. 530 print"[147]    insert disk and press any key"
  10. 535 get a$:if a$="" then 535
  11. 540 open 3,8,3,"0:animals,s,r"
  12. 545 input#3,nx
  13. 550 for i=1tonx
  14. 555 input#3,q$(i),tr(i,1),tr(i,2)
  15. 560 next:close3
  16. 570 if p$="y" then return
  17. 595 rem  **  main menu  **
  18. 600 print"[147]":printtab(13)"a n i m a l s"
  19. 602 print:printtab(16)"m e n u"
  20. 605 print:print"   1)  read file of animals"
  21. 610 print:print"   2)  guess an animal"
  22. 615 print:print"   3)  delete an animal"
  23. 620 print:print"   4)  save current file of animals"
  24. 625 print:print"   5)  list known animals"
  25. 630 print:print"   6)  list questions/pointers"
  26. 640 print:print"   7)  end program"
  27. 650 get a$:if a$="" then 650
  28. 655 if a$>"0" and a$<"8" then mm=1
  29. 660 on val(a$) gosub 530,1000,5000,3020,6000,4000,700
  30. 662 if (mm) then mm=. : goto600
  31. 665 goto 650
  32. 700 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
  33. 710 ifer<>63thenend
  34. 720 load"hello connect",8
  35. 990 rem  **  guess  **
  36. 1000 x=1:print"[147]":print
  37. 1003 print"think of an animal":print "and i will try to guess it":print
  38. 1005 print"press any key when you're ready":print
  39. 1010 get a$:if a$="" then 1010
  40. 1020 if tr(x,1)<0 then print "is it a ";q$(x);"(y/n)? ";:goto 1030
  41. 1025 print q$(x);"(y/n)? ";
  42. 1030 get an$:if an$="" then 1030
  43. 1035 if an$<>"y" and an$<>"n" then 1030
  44. 1040 print an$
  45. 1045 if an$="y" and tr(x,1) <0 then gosub9300:goto2100
  46. 1050 if an$="n" and tr(x,2)=0 then 2000:rem  add to tree
  47. 1055 if an$="y" then x=tr(x,1):goto 1020
  48. 1060 if an$="n" then x=tr(x,2):goto 1020
  49. 1065 goto 1020
  50. 1995 rem  **  learn  **
  51. 2000 print"i give up.  what is your animal?"
  52. 2002 le=38:al=1:nu=1:gosub60500:a$=c$
  53. 2005 print:print "what question should i ask to "
  54. 2007 print"differentiate between a ";q$(x):print"and a ";a$"?"
  55. 2008 le=78:gosub60500:nq$=c$
  56. 2010 print:print"what should the answer be for your ":print"animal  (y/n)?"
  57. 2012 getan$:ifan$<>"y"andan$<>"n"then2012
  58. 2015 if an$="n" then 2030
  59. 2020 q$(nx)=a$:tr(nx,1)=-1:q$(nx+1)=q$(x):tr(nx+1,1)=-1
  60. 2025 q$(x)=nq$:tr(x,1)=nx:tr(x,2)=nx+1:nx=nx+2:goto 2100
  61. 2030 q$(nx)=q$(x):tr(nx,1)=-1:q$(nx+1)=a$:tr(nx+1,1)=-1
  62. 2040 q$(x)=nq$:tr(x,1)=nx:tr(x,2)=nx+1:nx=nx+2
  63. 2100 print:print"play again (y/n)?"
  64. 2105 get a$:if a$="" then 2105
  65. 2110 if a$="y" then 1000
  66. 2115 if a$="n" then return
  67. 2120 goto 2105
  68. 2995 rem  **  save file  **
  69. 3000 print"want to save what i've learned?(y/n)"
  70. 3005 get a$:if a$="" then 3005
  71. 3010 if a$="n" then 3090
  72. 3015 if a$<>"y" then 3005
  73. 3020 s$=",":print "[147]insert disk, press any key when ready"
  74. 3025 get a$:if a$="" then 3025
  75. 3030 open 3,8,3,"@0:animals,s,w"
  76. 3040 print#3,nx
  77. 3050 fori=1tonx
  78. 3060 print#3,q$(i)s$tr(i,1)s$tr(i,2)
  79. 3070 next
  80. 3080 close3
  81. 3090 return
  82. 3990 rem  **  list questions/ptrs  **
  83. 4000 print"[147]":fori=1tonx
  84. 4010 if q$(i) <>"" then print i;q$(i);tr(i,1);tr(i,2)
  85. 4020 next
  86. 4050 print:print"press any key to continue"
  87. 4055 get a$:if a$="" then 4055
  88. 4060 return
  89. 4990 rem  **  delete animal  **
  90. 5000 d=0:print"[147]":print:input"animal to delete";ad$
  91. 5010 fori=1tonx
  92. 5015 if q$(i)=ad$ then d=i:i=nx
  93. 5020 next
  94. 5025 if d<>0 then 5050
  95. 5030 print"doesn't exist":print"press any key to continue"
  96. 5035 get a$:if a$="" then 5035
  97. 5040 return
  98. 5050 o=0:dp=0:sp=0:pq=0:fori=1tonx
  99. 5055 if tr(i,1)=d or tr(i,2)=d then pq=i:i=nx
  100. 5060 next
  101. 5100 if tr(pq,1)=d then dp=1:sp=2:goto 5110
  102. 5105 sp=1:dp=2
  103. 5110 o=tr(pq,sp)
  104. 5115 q$(d)="":tr(d,1)=0:tr(d,2)=0
  105. 5120 q$(pq)=q$(o):tr(pq,1)=tr(o,1):tr(pq,2)=tr(o,2)
  106. 5130 q$(o)="":tr(o,1)=0:tr(o,2)=0
  107. 5150 print:print ad$;" deleted":print"press any key to continue"
  108. 5155 get a$:if a$="" then 5155
  109. 5160 return
  110. 5990 rem  **  list animals  **
  111. 6000 print"[147]":fori=1tonx
  112. 6010 if q$(i) <>"" and tr(i,1)=-1 then print q$(i)
  113. 6020 next
  114. 6050 print:print"press any key to continue"
  115. 6055 get a$:if a$="" then 6055
  116. 6060 return
  117. 8990 rem  initial 'knowledge'
  118. 9000 q$(1)="does it have wings":tr(1,1)=2:tr(1,2)=3:q$(3)="does it swim"
  119. 9050 tr(3,1)=4:tr(3,2)=5:q$(5)="does it have legs":tr(5,1)=6:tr(5,2)=7
  120. 9105 q$(2)="duck":tr(2,1)=-1
  121. 9110 q$(4)="guppy":tr(4,1)=-1
  122. 9115 q$(6)="bear":tr(6,1)=-1
  123. 9120 q$(7)="worm":tr(7,1)=-1
  124. 9200 nx=8:return
  125. 9300 print"i guessed your animal!":return
  126. 60100 poke53280, 6:poke53281,14:print"[147]";
  127. 60101 print"LOADSTARPRESENTS:"
  128. 60102 print"                        "
  129. 60103 print"        [193]nimals          "
  130. 60104 print"                         "
  131. 60105 print"   By M. Poultonavage    "
  132. 60106 print"                         "
  133. 60107 print"    (C)opyright 1988     "
  134. 60108 print"                         "
  135. 60109 print"                        "
  136. 60110 print"PressSPACEtocontinue"
  137. 60111 ifpeek(203)<>60then60111
  138. 60112 return
  139. 60500 c$="":poke198,.:print"[164]";
  140. 60510 fora=1tole+1
  141. 60520 getz$:ifz$=""then60520
  142. 60530 ifz$=chr$(13)thenprint"[157] ":return
  143. 60540 ifz$=chr$(20)anda>1thenprint"[157][157]  [157][157][164]";:a=a-1:c$=left$(c$,a-1):goto60520
  144. 60550 if(a=le+1)then60520
  145. 60560 if(nu)and((z$>="0")and(z$<="9"))then60595
  146. 60570 if(al)and((z$>=" "andz$<="/")or(z$>=":"andz$<="z"))then60595
  147. 60580 if(al)thenif(z$>="[193]"andz$<="[218]")then60595
  148. 60590 goto60520
  149. 60595 print"[157]"z$;:poke212,.:print"[164]";:c$=c$+z$:next
  150.