Inteligentny program Genius 18

Zdrojový kód


   10 REM (c) Busy soft 10.08.1989
   20 REM : open #
   30 POKE 23693,58: POKE 23624,57: POKE 23697,0: CLS : RESTORE 1100: GO SUB 1080: LET a$=b$:
      GO SUB 730: PRINT a$''"Som inteligentny pocitac."'"(Vdaka tomuto programu.)":
      LET pozdrav=0: LET e$="": LET m$=CHR$ 31: LET n$=m$

   40 INPUT ">"; LINE a$: LET z=1: FOR a=1 TO LEN a$: LET b$=a$(a):
      IF b$=" " OR b$="!" OR b$="?" OR b$="." THEN NEXT a: GO TO 40
   60 IF a$=CHR$ 20+CHR$ 1+"Heslo je:"+n$+" "+m$ THEN PRINT '"Ako si uhadol heslo ?"'USR 4867
   70 INK 1: PRINT '">";a$: POKE 23695,58: POKE 23697,0: IF a$(LEN a$)="!" AND pozdrav THEN
      RESTORE 1190: GO SUB 1080: PRINT b$
   80 GO SUB 930: GO SUB 970: GO SUB 1030
   90 RESTORE 1090: READ d: FOR c=1 TO d: READ b$: FOR d=1 TO LEN b$: LET b$(d)=CHR$ (CODE b$(d)-1):
      NEXT d: LET b$=" "+b$: GO SUB 880: IF a THEN RESTORE 1210: GO TO 340
  100 NEXT c
  110 RESTORE 1100: GO SUB 830: IF pozdrav AND NOT a THEN GO TO 150
  120 IF NOT a THEN RESTORE 1120: GO SUB 1080: PRINT b$: GO TO 40
  130 LET d$="": IF pozdrav=0 THEN LET pozdrav=1:
      LET d$=CHR$ 13+CHR$ 13+"Co pekne mi povies ?"+CHR$ 13+"(Pripadne sa aj spytas ?)"
  140 LET a$=b$: GO SUB 730: PRINT a$;d$: GO TO 40
  150 LET b$="reset": GO SUB 880: IF a THEN LET e$=b$: RESTORE 1200: GO TO 340
  160 IF a$(LEN a$-1) <> "?" THEN GO TO 440
  170 LET e$="": FOR a=LEN a$ TO 1 STEP -1
  180 IF a$(a)="?" OR a$(a)=" " OR a$(a)="." THEN LET a$=a$( TO a-1): NEXT a
  190 LET x=1
  200 RESTORE 1220: GO SUB 830
  210 IF NOT a AND x THEN LET z=0: GO TO 380
  220 IF NOT a THEN LET e$=c$: GO SUB 660: LET c$=e$: LET e$="": GO TO 290
  230 RESTORE 1230: FOR a=4 TO 4*d+INT (3.9*RND ): READ c$: NEXT a
  240 LET a=1: LET c$=c$+"M"
  250 IF c$(a)="_" THEN LET c$=c$( TO a-1)+STR$ INT ((100*(CODE c$(a+1)-48)+10*(CODE c$(a+2)-48)
      + CODE c$(a+3)-48)*RND +1)+c$(a+4 TO )
  260 LET a=a+1: IF c$(a) <> "M" THEN GO TO 250
  270 LET c$=c$( TO LEN c$-1)
  280 GO SUB 790: LET x=0: GO TO 200
  290 LET cislo=RND : IF cislo<.7 THEN GO TO 550
  300 IF cislo<.8 THEN LET a$=c$: GO TO 550
  310 RESTORE 1130: GO SUB 1080: LET a$=b$: GO TO 550
  320 GO SUB 880: IF NOT a THEN LET a$=e$: GO TO 350
  330 RESTORE 1140
  340 GO SUB 1080: LET a$=b$: GO TO 590
  350 IF b$=" ano " THEN LET e$="": GO TO 40
  360 IF e$ <> "reset" THEN GO TO 170
  370 STOP 
  380 GO SUB 660: IF a THEN GO TO 550
  390 GO SUB 620: IF a THEN GO TO 550
  400 IF z THEN GO TO 330
  410 IF RND >.5 THEN GO TO 310
  420 LET a$="nie": IF RND >.5 THEN LET a$="ano"
  430 GO TO 550
  440 RESTORE 1110: GO SUB 850: IF a THEN LET a=a+LEN b$+1
  450 LET a=a+1: FOR b=a TO LEN a$: IF a$(b)="," THEN RESTORE 1170: GO SUB 1070: PRINT b$: GO TO 40
  460 NEXT b
  470 IF e$="" THEN GO TO 500
  480 LET b$=" ano ": GO SUB 880: LET b$=" nie ": IF a THEN GO TO 320
  490 GO SUB 880: IF a THEN LET b$=" ano ": GO TO 320
  500 LET e$=a$: RESTORE 1220: GO SUB 830: IF a THEN RESTORE 1180: GO SUB 1070: LET a$=b$: GO TO 590
  510 LET e$=""
  520 RESTORE 1150: GO SUB 830: IF a THEN RESTORE 1160: GO TO 340
  530 GO SUB 660: IF a THEN GO TO 550
  540 GO SUB 620: IF NOT a THEN GO TO 330
  550 IF RND >.2 THEN GO TO 590
  560 RESTORE 1110: GO SUB 850: IF a THEN GO TO 590
  570 RESTORE 1110: GO SUB 1070
  580 LET a$=b$+", ze  "+a$
  590 GO SUB 970: FOR a=1 TO LEN a$: IF a$(a)="_" THEN LET a$(a)="."
  600 NEXT a: GO SUB 740: PRINT a$: LET n$=m$: LET m$=a$: GO TO 40

  610 REM #######################
  620 REM ## neni-je je-neni
  630 LET b$="neni": LET c$="je": GO SUB 780: IF a THEN RETURN 
  640 LET b$="nie je": LET c$="je": GO SUB 780: IF a THEN RETURN 
  650 LET b$="je": LET c$="nie je": GO TO 780

  660 REM ## som-si mam-mas
  670 LET b$="ty": LET c$=" ": GO SUB 780: LET b$="ja": LET c$=" ": GO SUB 780
  680 LET b$="mam": LET c$="mas": GO SUB 780: IF a THEN GO SUB 700: LET a=1: RETURN 
  690 LET b$="mas": LET c$="mam": GO SUB 780: IF a THEN GO SUB 700: LET a=1: RETURN 
  700 LET b$="som": LET c$="si": GO SUB 780: IF a THEN RETURN 
  710 LET b$="si": LET c$="som": GO SUB 780: RETURN 

  720 REM ## zlozenie vety
  730 GO SUB 970
  740 IF a$(1) >= "a" AND a$(1) <= "z" THEN LET a$=CHR$ (CODE a$-32)+a$(2 TO )
  750 IF a$(LEN a$) <> "." AND a$(LEN a$) <> "!" AND a$(LEN a$) <> "?" THEN LET a$=a$+"."
  760 RETURN 

  770 REM ## vymena slova
  780 LET b$=" "+b$+" "
  790 GO SUB 880: IF NOT a THEN RETURN 
  800 LET a$=a$(1 TO a-1)+" "+c$+" "+a$(a+LEN b$ TO ): RETURN 

  810 REM ## prve pismeno velke
  820 LET c$(1)=CHR$ (CODE c$-32): RETURN 

  830 REM ## hladaj viac slov
  840 LET d$=" ": GO TO 860
  850 LET d$=""
  860 READ c: FOR d=1 TO c: READ b$: LET b$=" "+b$+d$: GO SUB 880: IF a THEN RETURN 
  870 NEXT d: RETURN 

  880 REM ## hladaj slovo
  890 IF a$(1) <> " " OR a$(LEN a$) <> " " THEN LET a$=" "+a$+" "
  900 FOR a=1 TO LEN a$-LEN b$+1
  910 IF b$=a$(a TO a+LEN b$-1) THEN RETURN 
  920 NEXT a: LET a=0: RETURN 

  930 REM ## male pismo
  940 FOR a=1 TO LEN a$
  950 IF a$(a) >= "A" AND a$(a) <= "Z" THEN LET a$(a)=CHR$ (CODE a$(a)+32)
  960 NEXT a: RETURN 

  970 REM ## medzery
  980 FOR a=1 TO LEN a$-2
  990 IF a$(a)<" " THEN LET a$(a)=" "
 1000 IF a$(a)=" " AND a$(a+1)=" " THEN LET a$=a$(1 TO a)+a$(a+2 TO )+".": GO TO 1000
 1010 NEXT a
 1020 IF a$(1)=" " THEN LET a$=a$(2 TO ): GO TO 1020
 1030 FOR a=LEN a$ TO 1 STEP -1
 1040 IF a$(a)=" " OR a$(a)="." OR a$(a)="!" THEN LET a$=a$( TO a-1): NEXT a
 1050 RETURN 

 1060 REM #######################
 1070 REM ## nacitanie z dat
 1080 READ e: FOR a=0 TO RND *e: READ b$: NEXT a: RETURN 

 1090 DATA 4,"lplpu","qjd","ipwop","kfc"
 1100 DATA 14,"cau","cao","dobre rano","dobry vecer","dobry den","ahoj","servus","nazdar","vitaj",
      "zdravim","s pozdravom","zdrastvuj","halo","helou"
 1110 DATA 4,"myslim si","domievam sa","som presvedceny","dufam"
 1120 DATA 4,"Bud trochu slusnejsi !","Preco ma nepozdravis ?","Bolo by vhodne ma pozdravit...",
      "Nevies pozdravit ?"
 1130 DATA 4,"neviem","nie som kompetentny odpovedat",".... odpoved je neista","odpoved je vo hviezdach___"
 1140 DATA 10,"???","nechapem","prosim ?","nerozumiem","formuluj to inac !","Nonsense in BASIC",
      "mas pravdu","vonku svieti slnko.","dnes je pekne pocasie","ale netaraj___"
 1150 DATA 10,"chcem","chces","chce","chceme","chcete","chcu","chcel","chcela","chcelo","chceli","chciet"
 1160 DATA 3,"chciet je pekna vlastnost___","chciet nie je zakazane___","od chcenia uz dvaja umreli___",
      "raz jeden chcel___"
 1170 DATA 4,"Tie vyrazy pis kratsie.","Dlhy text - kratky rozum...","Radsej pis jednoduche vety.",
      "Zlozite vety nemam rad."
 1180 DATA 4,"to ma byt otazka ?","to sa ma pytas ?","mam na to odpovedat ?","mam sa k tomu vyjadrit ?"
 1190 DATA 4,"Zachovaj klud !","Zvysovat hlas nemusis...","Neznervoznuj sa !","Nebud nervozny !"
 1200 DATA 4,"Mam sa resetnut ?","Chces reset ?","Prestalo ta to bavit ?","Uz ta to omrzelo ?"
 1210 DATA 4,"nadavat sa neslusi___","co nadavas ?","pis slusne___","nenadavaj"
 1220 DATA 26,"kolko","kedy","ako","kam","coze","kto","preco","co","kde","naco","zaco","ake","aky",
      "aka","koho","komu","kom","kym","coho","comu","com","cim","ktory","ktora","ktore","kolkeho"
 1230 DATA "_300","asi _100","vela","malo"
 1240 DATA "teraz","urcite dnes","dnes","v case blizsie neurcenom"
 1250 DATA "po slovensky","po rusky","normalne","urcite nejako"
 1260 DATA "domov","hore","prec","dole"
 1270 DATA "nic","toze","nic vazneho","to"
 1280 DATA "on","nikto","niekto konkretny","niekto blizsie neurceny"
 1290 DATA "pre stare vreco a novu zaplatu","pre nic","len tak","pre dovody blizsie neurcene"
 1300 DATA "nic","nieco","blbost","nieco blizsie neurcene"
 1310 DATA "na marse","v jame","v riti","na mieste blizsie neurcenom"
 1320 DATA "na stare vreco a novu zaplatu","na figu","na hlavu","nanic"
 1330 DATA "za _500,- Kcs","za nic","za fajku mocky","za macku vo vreci"
 1340 DATA "pekne","cervene","skarede","zle"
 1350 DATA "modry","velky","kockaty","gulaty"
 1360 DATA "dobra","zelena","pekna","hneda"
 1370 DATA "nikoho","niekoho","asi toho","oneho"
 1380 DATA "nikomu","niekomu","asi tomu","onemu"
 1390 DATA "nikom","niekom","asi tom","onom"
 1400 DATA "nikym","niekym","asi tym","onym"
 1410 DATA "nicoho","niecoho","asi toho","oneho"
 1420 DATA "nicomu","niecomu","asi tomu","onomu"
 1430 DATA "nicom","niecom","asi tom","onom"
 1440 DATA "nicim","niecim","asi tym","onym"
 1450 DATA "ziadny","asi ten","druhy zprava","niktory"
 1460 DATA "ziadna","asi ta","tretia zlava","niktora"
 1470 DATA "ziadne","asi to","stvrte zprava","niktore"
 1480 DATA "_029-teho","okolo _029-teho","_029._011","asi _029._011"


Popis
Toto je inteligentny program, ktory na kazdu otazku rozumne odpovie a vie sa aj hadat. Je zalozeny na analyze slov vo vete a ich nahrade inymi vhodnymi slovami. Hlavna rozhodovacia inteligencia je tvorena funkciou RND :-)

Poznámky
Do finalnej podoby bol tento zdrojak skompilovany programom Hisoft Basic compiler.

Poslal
Busy