home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 49
/
049.d81
/
animals
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
4KB
|
150 lines
10 gosub60100:clr:print"[147]"chr$(142)
100 dim tr(999,2),q$(999)
117 gosub 9000
140 goto600
500 print"[147]is there a file of animals to use? (y/n)"
510 get a$:if a$="" then 510
520 if a$="n" then 570
525 if a$<>"y" then 510
530 print"[147] insert disk and press any key"
535 get a$:if a$="" then 535
540 open 3,8,3,"0:animals,s,r"
545 input#3,nx
550 for i=1tonx
555 input#3,q$(i),tr(i,1),tr(i,2)
560 next:close3
570 if p$="y" then return
595 rem ** main menu **
600 print"[147]":printtab(13)"a n i m a l s"
602 print:printtab(16)"m e n u"
605 print:print" 1) read file of animals"
610 print:print" 2) guess an animal"
615 print:print" 3) delete an animal"
620 print:print" 4) save current file of animals"
625 print:print" 5) list known animals"
630 print:print" 6) list questions/pointers"
640 print:print" 7) end program"
650 get a$:if a$="" then 650
655 if a$>"0" and a$<"8" then mm=1
660 on val(a$) gosub 530,1000,5000,3020,6000,4000,700
662 if (mm) then mm=. : goto600
665 goto 650
700 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
710 ifer<>63thenend
720 load"hello connect",8
990 rem ** guess **
1000 x=1:print"[147]":print
1003 print"think of an animal":print "and i will try to guess it":print
1005 print"press any key when you're ready":print
1010 get a$:if a$="" then 1010
1020 if tr(x,1)<0 then print "is it a ";q$(x);"(y/n)? ";:goto 1030
1025 print q$(x);"(y/n)? ";
1030 get an$:if an$="" then 1030
1035 if an$<>"y" and an$<>"n" then 1030
1040 print an$
1045 if an$="y" and tr(x,1) <0 then gosub9300:goto2100
1050 if an$="n" and tr(x,2)=0 then 2000:rem add to tree
1055 if an$="y" then x=tr(x,1):goto 1020
1060 if an$="n" then x=tr(x,2):goto 1020
1065 goto 1020
1995 rem ** learn **
2000 print"i give up. what is your animal?"
2002 le=38:al=1:nu=1:gosub60500:a$=c$
2005 print:print "what question should i ask to "
2007 print"differentiate between a ";q$(x):print"and a ";a$"?"
2008 le=78:gosub60500:nq$=c$
2010 print:print"what should the answer be for your ":print"animal (y/n)?"
2012 getan$:ifan$<>"y"andan$<>"n"then2012
2015 if an$="n" then 2030
2020 q$(nx)=a$:tr(nx,1)=-1:q$(nx+1)=q$(x):tr(nx+1,1)=-1
2025 q$(x)=nq$:tr(x,1)=nx:tr(x,2)=nx+1:nx=nx+2:goto 2100
2030 q$(nx)=q$(x):tr(nx,1)=-1:q$(nx+1)=a$:tr(nx+1,1)=-1
2040 q$(x)=nq$:tr(x,1)=nx:tr(x,2)=nx+1:nx=nx+2
2100 print:print"play again (y/n)?"
2105 get a$:if a$="" then 2105
2110 if a$="y" then 1000
2115 if a$="n" then return
2120 goto 2105
2995 rem ** save file **
3000 print"want to save what i've learned?(y/n)"
3005 get a$:if a$="" then 3005
3010 if a$="n" then 3090
3015 if a$<>"y" then 3005
3020 s$=",":print "[147]insert disk, press any key when ready"
3025 get a$:if a$="" then 3025
3030 open 3,8,3,"@0:animals,s,w"
3040 print#3,nx
3050 fori=1tonx
3060 print#3,q$(i)s$tr(i,1)s$tr(i,2)
3070 next
3080 close3
3090 return
3990 rem ** list questions/ptrs **
4000 print"[147]":fori=1tonx
4010 if q$(i) <>"" then print i;q$(i);tr(i,1);tr(i,2)
4020 next
4050 print:print"press any key to continue"
4055 get a$:if a$="" then 4055
4060 return
4990 rem ** delete animal **
5000 d=0:print"[147]":print:input"animal to delete";ad$
5010 fori=1tonx
5015 if q$(i)=ad$ then d=i:i=nx
5020 next
5025 if d<>0 then 5050
5030 print"doesn't exist":print"press any key to continue"
5035 get a$:if a$="" then 5035
5040 return
5050 o=0:dp=0:sp=0:pq=0:fori=1tonx
5055 if tr(i,1)=d or tr(i,2)=d then pq=i:i=nx
5060 next
5100 if tr(pq,1)=d then dp=1:sp=2:goto 5110
5105 sp=1:dp=2
5110 o=tr(pq,sp)
5115 q$(d)="":tr(d,1)=0:tr(d,2)=0
5120 q$(pq)=q$(o):tr(pq,1)=tr(o,1):tr(pq,2)=tr(o,2)
5130 q$(o)="":tr(o,1)=0:tr(o,2)=0
5150 print:print ad$;" deleted":print"press any key to continue"
5155 get a$:if a$="" then 5155
5160 return
5990 rem ** list animals **
6000 print"[147]":fori=1tonx
6010 if q$(i) <>"" and tr(i,1)=-1 then print q$(i)
6020 next
6050 print:print"press any key to continue"
6055 get a$:if a$="" then 6055
6060 return
8990 rem initial 'knowledge'
9000 q$(1)="does it have wings":tr(1,1)=2:tr(1,2)=3:q$(3)="does it swim"
9050 tr(3,1)=4:tr(3,2)=5:q$(5)="does it have legs":tr(5,1)=6:tr(5,2)=7
9105 q$(2)="duck":tr(2,1)=-1
9110 q$(4)="guppy":tr(4,1)=-1
9115 q$(6)="bear":tr(6,1)=-1
9120 q$(7)="worm":tr(7,1)=-1
9200 nx=8:return
9300 print"i guessed your animal!":return
60100 poke53280, 6:poke53281,14:print"[147]";
60101 print"LOADSTARPRESENTS:"
60102 print" "
60103 print" [193]nimals "
60104 print" "
60105 print" By M. Poultonavage "
60106 print" "
60107 print" (C)opyright 1988 "
60108 print" "
60109 print" "
60110 print"PressSPACEtocontinue"
60111 ifpeek(203)<>60then60111
60112 return
60500 c$="":poke198,.:print"[164]";
60510 fora=1tole+1
60520 getz$:ifz$=""then60520
60530 ifz$=chr$(13)thenprint"[157] ":return
60540 ifz$=chr$(20)anda>1thenprint"[157][157] [157][157][164]";:a=a-1:c$=left$(c$,a-1):goto60520
60550 if(a=le+1)then60520
60560 if(nu)and((z$>="0")and(z$<="9"))then60595
60570 if(al)and((z$>=" "andz$<="/")or(z$>=":"andz$<="z"))then60595
60580 if(al)thenif(z$>="[193]"andz$<="[218]")then60595
60590 goto60520
60595 print"[157]"z$;:poke212,.:print"[164]";:c$=c$+z$:next