home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disk User Volume 4 #4
/
Commodore_Disk_User_Vol.4_4_1991_-.d64
/
advisor
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
8KB
|
346 lines
10 rem ****************************
12 rem * a new expert system prog *
14 rem ****************************
16 cd$=""
18 cd$(1)=left$(cd$,5)
20 cd$(2)=left$(cd$,11)
22 cd$(3)=left$(cd$,19)
24 it$=" the advisor [146]"
26 print"[147]";tab(12);it$
29 print"";tab(7);" bob garner april 1990 ":gosub482
30 print"[147]";cd$(2);tab(7);" setting the dimensions [146]"
32 dim t(10,10,10),a$(15),v$(15,15),c$(20),vt(10)
34 s1=1065:s2=s1+37:s3=1982:s4=s3-37
36 de$(6)="unknown factor"
38 gosub518
40 gosub 390
42 poke 53281,6:gosub466
44 rem ************
46 rem * the menu *
48 rem ************
50 print"";tab(11);it$
52 print""tab(13)"**the menu**"
54 printtab(10);"1. input data"
56 printtab(10);"2. view the data"
58 printtab(10);"3. save data"
60 printtab(10);"4. retrieve the data"
62 printtab(10);"5. change the data"
64 printtab(10);"6. analyse data"
66 printtab(10);"7. scratch data"
68 printtab(10);"8. disk directory"
70 printtab(10);"9. rank data"
72 printtab(10);"0. quit"
74 printtab(10)" type the number [146]"
76 get m$:if m$="" then 76
78 m=asc(m$):if m<48 or m>57 then gosub 516:m=0:goto76
80 on m-47 gosub88,92,202,272,320,354,536,402,484,232
82 goto86
84 goto50
86 goto42
88 sys 64760
90 rem *********************
92 rem * naming the system *
94 rem *********************
96 print"[147]";tab(11);it$
98 printtab(10);" naming the system [146]"
100 zz=1:print"what will you call the system"
102 print"being created":print"";:input na$
104 rem ********************
106 rem * the attributes *
108 rem ********************
110 print"[147]";tab(11);it$
112 printtab(9);" creating attributes [146]"
114 for t=1to6
116 print"attribute ";t;
118 print"";:input a$(t)
120 next
122 print"[147]"
124 rem **************
126 rem * the values *
128 rem **************
130 print"[147]";tab(11);it$
132 printtab(11);" creating values [146]"
134 for t=1to6
136 print"attribute - ";a$(t)
138 for s=1to3
140 print "value ";s;
142 print"";:input v$(t,s)
144 next:print"":next:print:print:gosub390
146 rem *****************
148 rem * the decisions *
150 rem *****************
152 x=1
154 print"[147]";tab(11);it$
156 printtab(11);" the decisions [146]"
158 print"what if you have all these"
160 fort=1to6
162 print
164 fors=xto3step3
166 printtab(5);s;"[157]. ";v$(t,s)
168 next:next
170 print"";:input "your decision :";de$(x)
172 x=x+1:if x>3 then 176
174 goto154
176 print"[147]";tab(11);it$
178 printtab(11);" the decisions [146]"
180 print"what if ";de$(1);"[146] and "
182 print"";de$(2);"[146] are mixed"
184 print"";:input "your decision :";de$(x)
186 x=x+1
188 print"[147]";tab(11);it$
190 printtab(11);" the decisions [146]"
192 print"what if ";de$(2);"[146] and "
194 print"";de$(3);"[146] are mixed"
196 print"";:input "your decision :";de$(x)
198 return
200 rem ***********************
202 rem * screen view of data *
204 rem ***********************
206 x=1:y=3
208 if y>6then 226
210 print"[147]";tab(8);na$
212 for t=xtoy
214 print"attribute ";t;"- ";a$(t)
216 print
218 for s=1to3
220 printtab(5);"value";s;"- ";v$(t,s)
222 next:next:print:print:print
224 gosub390:y=y+3:x=x+3:goto208
226 print"[147]";tab(5)"these are your decisions"
228 print"":forg=1to5:printtab(6);de$(g):print"":print:next:gosub390:return
230 rem ********************
232 rem * ranking the data *
234 rem ********************
236 print"[147]";tab(11);it$
238 fort=1to6
240 print" values for attribute '";a$(t);"'"
242 fors=1to3
244 print""s;v$(t,s):next
246 print"":for r=1to3
248 ifr=1thens$="first ":goto254
250 ifr=2thens$="second":goto254
252 ifr=3thens$="third "
254 if s>1then printtab(10);"[145][145][145][145] ":goto 258
256 print""
258 print" which would you put ";s$
260 printtab(10)"";:inputc(r)
262 b$(t,r)=v$(t,c(r)):next
264 printtab(10)" ";
266 for s=1to3:v$(t,s)=b$(t,s):nexts
268 print"[147]":nextt:gosub390:return
270 rem *****************
272 rem * save the data *
274 rem *****************
276 print"[147]";tab(12);it$
278 print"are you sure (y/n)"
280 get b$:if b$="" then 280
282 if b$="n" then return
284 print"ok - i have the name file "na$" "
286 print"is this correct (y/n)"
288 get b$:if b$="" then 288
290 if b$="y" and len(na$)>=3 then 302
292 if b$="n" then 296
294 :
296 printtab(7);" type in the correct name [146]"
297 printtab(12);" then [return] [146]"
298 print:printtab(7);:input na$
300 if len(na$)<3 then printcd$(3);tab(11);" invalid entry [146]":gosub390:return
302 printtab(4);"creating ";na$;" disk file"
304 open 15,8,15
306 open4,8,4,na$+",s,w":gosub444
308 print#4,na$
310 for t=1to6:print#4,a$(t):next
312 fort=1to6:for s=1to3:print#4,v$(t,s):next:next
314 for t=1to5:print#4,de$(t):next
316 close15:close4:print:printtab(4);"file saved":gosub 390:return
318 rem *********************
320 rem * retrieve the data *
322 rem *********************
324 print"[147]";tab(11);it$
326 print"which file is to be retrieved"
328 print"";:input na$
330 if len(na$)<3 then printcd$(3);tab(11);"invalid input":gosub390:return
332 ta3=int((19-(len(na$)))/2)
334 printtab(ta3);"retrieving ";na$;"[146] data file"
336 open 15,8,15
338 open4,8,4,na$+",s"
340 input#4,na$
342 for t=1to6:input#4,a$(t):next
344 fort=1to6:for s=1to3:input#4,v$(t,s):next:next:gosub 444
346 for t=1to5:input#4,de$(t):next
348 close15:close4:zz=1
350 print"";tab(ta3);"data file ";na$;"[146] retrieved":gosub390:return
352 rem *******************
354 rem * change the data *
356 rem *******************
358 print"[147]";tab(11);it$
360 print"system name is ",na$;:input na$
362 for t=1to6
364 print"attribute ";t;"- ";a$(t);:input a$(t)
366 print
368 for s=1to3
370 print"value";s;"- ";v$(t,s);:inputv$(t,s)
372 next:next
374 print:print:print
376 print"these are your decisions"
378 for u=1to5
380 print"";u". ";de$(u):print:input"";de$(u)
382 next:print"":gosub390:return
384 rem ****************
386 rem * page control *
388 rem ****************
390 printcd$;tab(6);" space=continue [146] _ = abort [146]"
392 get sp$:if sp$=""then 392
394 if sp$=chr$(32) then return
396 if sp$="_" and zz>0 then tt=0:x=6:goto42
398 gosub516:goto392
400 rem *********************
402 rem * scratch data file *
404 rem *********************
406 open15,8,15
408 print"[147]expert systems"
410 print"continue and the data file will be"
412 print"scratched !"
414 print:print" [space] to continue - '_' to abort [146]"
416 get k$:if k$="" then 416
418 if k$=chr$(32) then 422
420 print:print:printtab(10)" scratch aborted !! ":gosub482:goto434
422 print"which file to be scratched"
424 print"";:input na$
426 print"are you sure [y/n]"
428 get a$:if a$="" then 428
430 if a$="y" then print#15,"s:";na$
432 print"ok ! back to the menu":gosub 482
434 close15:return
436 :
438 :
440 :
442 rem ***************
444 rem * disk errors *
446 rem ***************
448 input#15,en,em$,et,es
450 if en<20 then return
452 print"[147][158] disk error has occurred "
454 print"error number ";en
456 print"error message ";em$
458 print"track number ";et
460 print"sector number ";es
462 close 15
464 rem *****************
466 rem * screen edging *
468 rem *****************
470 print"[147]":poke53281,1:poke53280,6
472 for k=s1tos2:poke k,102:next
474 for k=s2tos3step40:poke k,102:next
476 for k=s3tos4step-1:poke k,102:next
478 for k=s4tos1step-40:poke k,102:next
480 return
482 for y=1to2500:next:return
484 rem **********************
486 rem * read the directory *
488 rem **********************
490 gosub466
492 print" this is the disk directory "
494 open 1,8,0,"$"
496 get#1,x$,x$
498 get#1,x$,x$,x$,x$
500 if st then close 1:gosub390:return
502 get#1,x$:if x$="" then printtab(5);chr$(34):goto498
504 if x$=chr$(34) then q=not q
506 if q then printtab(5);x$;
508 goto502
510 rem *******************
512 rem * screen reverser *
514 rem *******************
516 for l=1to10:sys 52992:gosub532: next:return
518 forj=52992to53018:readk:pokej,k:next
520 data 169,000,133,251,169,004,133,252
522 data 162,004,160,000,177,251,073,128
524 data 145,251,200,208,247,230,252,202
526 data 208,240,096
528 :
530 return
532 for k=1to80:next:return
534 rem ****************
536 rem * the analysis *
538 rem ****************
540 :
542 x=1:q=1
544 :
546 :
548 :
550 :
552 if tt>0 then 556
554 fort=1to6:c$(t)="unknown":next
556 :
558 ifzz=1thengoto574
560 a$(1)="attribute here"
562 t=1:for s=1to3
564 v$(t,s)="value here"
566 next
568 de$(f)="decision here"
570 :
572 print"[147]"
574 for t=1to6
576 gosub636:rem *print boxes*
578 printcd$(1);tab(9);a$(t):printcd$(2);
580 for s=1to3:printtab(5);s;"[157]. ";v$(t,s):next
582 :
584 if zz=0 then printcd$(3);de$(t):gosub390:return
586 rem ***********
588 rem * scoring *
590 rem ***********
592 :
594 printcd$;
596 get b$:if b$="" then 596
598 if b$="1" then vt(t)=3:goto606
600 if b$="2" then vt(t)=2:goto606
602 if b$="3" then vt(t)=1:goto606
604 gosub516:goto596
606 t(q,t,s)=vt(t)
608 :
610 if q>1 then tt=tt-t(q-1,t,s)
612 tt=tt+vt(t)
614 v=val(b$):c$(t)=v$(t,v):tt(q,t,s)=tt
616 if tt=x*3 then f=1:goto626
618 if tt=>(x*2)+1 and tt<=(x*3)-1 then f=4:goto626
620 if tt=x*2 then f=2:goto626
622 if tt=>x+1 and tt<=(x*2)-1 then f=5:goto626
624 if tt=x then f=3:goto626
626 if x<=5 then f=6
628 gosub668
630 if q=>2 then x=6:next:goto634
632 x=x+1:next
634 q=q+1:goto572
636 print"[147]";tab(11);it$
638 printtab(7);"[176][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][174]
640 [153][163]7);"peek peek
642 printtab(7);"[173][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][189]
644 [153]:[153]
646 [153][163]4);"orlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlen^
648 printtab(4);"[194] [194]
650 [153][163]4);"peek peek
652 printtab(4);"[194] [194]
654 [153][163]4);"peek peek
656 printtab(4);"[194] [194]
658 [153][163]4);"/lenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenlenexp
660 if zz=0 then return
662 print"type the number of your choice"
664 return
666 rem *********************
668 rem * the 'why' factors *
670 rem *********************
672 gosub466
674 print"";tab(11);it$
676 ta1=int((37-(len(na$)))/2)
678 print"";tab(ta1);na$;" says "
680 ta1=int((40-len(de$(f)))/2)
682 print"";tab(ta1)de$(f)
684 print"";tab(15)" because :"
686 for g=1to6
688 ta2=int((36-(len(a$(g))+len(c$(g))))/2)
690 printtab(ta2);a$(g);" is ";c$(g)
692 next
694 gosub390:return
696 rem *********