News:

Welcome to RetroCoders Community

Main Menu

ELIZA IN POWERBASIC

Started by ron77, Mar 04, 2023, 08:01 PM

Previous topic - Next topic

ron77

hello here is an Eliza code in Powerbasic written by an older gentleman taken from his youtube channel from 2019:


#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN () AS LONG

        DIM a AS STRING
        DIM srm AS LONG
        DIM scm AS LONG

     DESKTOP GET SIZE TO  srm&, scm&

     CONSOLE SET SCREEN    srm&, scm&

    COLOR 14,1,4

     CLS

    PAGE 0,0

        DIM W() AS STRING:DIM J AS INTEGER:DIM NM1 AS STRING:DIM NM2 AS STRING
        DIM W2() AS STRING: DIM Y AS INTEGER
        DIM V AS INTEGER
        DIM I AS INTEGER:DIM P AS INTEGER:DIM R AS STRING:DIM FQ() AS STRING
        DIM N AS STRING
        DIM QNO AS INTEGER :DIM YY AS INTEGER
        DIM R() AS STRING:DIM T1() AS STRING:DIM T2() AS STRING:DIM T3()AS STRING
        DIM Q AS STRING:DIM RP AS STRING
        DIM NR AS INTEGER:DIM F AS INTEGER:DIM FF AS INTEGER
        DIM QX() AS STRING


COLOR 14,1,14
DIM QX$(137),W$(6),W2$(6),R$(143),T1$(101),T2$(100),T3$(100),FQ$(6)

DATA  "APOLOGIES ARE NOT NECESSARY."
DATA  "ARE SUCH QUESTIONS ON YOUR MIND OFTEN?"
DATA  "ARE YOU DISTURBED BY YOUR DREAMS?"
DATA  "ARE YOU UNCOMFORTABLE WITH THE OPPOSITE SEX?"
DATA  "ARE YOU SAYING NO JUST TO BE NEGATIVE?"
DATA  "ARE YOU SURE OF THAT?"
DATA  "ARE YOU SURE?"
DATA  "ARE YOU TALKING ABOUT ME IN PARTICULAR?"
DATA  "BUT YOU ARE NOT SURE ARE YOU ?"
DATA  "CAN YOU ELABORATE ON THAT?"
DATA  "CAN YOU THINK OF A SPECIFIC EXAMPLE?"
DATA  "CAN'T YOU BE MORE POSITIVE?"
DATA  "COME, COME, ELUCIDATE YOUR THOUGHTS !"
DATA  "COULD THERE BE SOME CONNECTION?"
DATA  "DID YOU COME TO ME BECAUSE YOU ARE UNDECIDED"
DATA  "DO PEOPLE PROBLEMS WORRY YOU?"
DATA  "DO YOU BELIEVE IT IS NORMAL TO BE LIKE THAT"
DATA  "DO YOU DOUBT YOURSELF "
DATA  "DO YOU ENJOY FEELING SAD "
DATA  "DO YOU HAVE MANY FRIENDS?"
DATA  "DO YOU LIKE PARTIES ?"
DATA  "DO YOU LIKE TRAVELLING ?"
DATA  "DO YOU OFTEN FEEL LIKE THAT "
DATA  "DO YOU REALLY THINK SO?"
DATA  "DO YOU SOMETIMES WISH YOU WERE ABLE TO SCREAM ! "
DATA  "DO YOU THINK PEOPLE LIKE ME CAN HELP OTHERS?"
DATA  "DO YOU THINK WHERE YOU LIVE IS YOUR PROBLEM?"
DATA  "DO YOU THINK YOU SHOULD BE ABLE TO DO THAT "
DATA  "DO YOU WANT ME TO RESOLVE THAT "
DATA  "DO YOU WANT TO BE ABLE TO DO THAT "
DATA  "DO YOUR FRIENDS PICK ON YOU?"
DATA  "DO YOUR FRIENDS WORRY YOU?"
DATA  "DOES IT PLEASE YOU TO BELIEVE THAT "
DATA  "DOES THAT QUESTION INTEREST YOU?"
DATA  "DOES THAT REASON EXPLAIN ANY THING ELSE?"
DATA  "DOES THAT TROUBLE YOU?"
DATA  "DON'T ANY OTHER REASONS COME TO MIND?"
DATA  "DON'T YOU BELIEVE THAT I CAN HELP YOU ? "
DATA  "DON'T YOU KNOW?"
DATA  "DON'T YOU REALLY SEE WHY "
DATA  "HAVE YOU ASKED ANYONE ELSE?"
DATA  "HAVE YOU ASKED SUCH QUESTIONS BEFORE?"
DATA  "HAVE YOU TRIED?"
DATA  "HOW DO YOU KNOW YOU CAN'T "
DATA  "HOW LONG HAVE YOU BEEN UPSET"
DATA  "HOW CAN THAT HAPPEN ?"
DATA  "I ALSO SOMETIMES WANT SOMETHING LIKE THAT"
DATA  "I AM BEGINNING TO SEE THE PROBLEM."
DATA  "I DON'T CARE ABOUT THAT -- BUT, PLEASE GO ON."
DATA  "I SEE."
DATA  "I UNDERSTAND."
DATA  "I'M NOT SURE I UNDERSTAND YOU FULLY."
DATA  "IN WHAT WAY?"
DATA  "IS THAT THE REAL REASON?"
DATA  "MY FAVORITE PASTIME IS WALKING.  WHAT IS YOURS?"
DATA  "MY FAVORITE PEOPLE ARE EXTROVERTS. WHAT IS YOUR FAVORITE KIND?"
DATA  "OH, DO YOU LIKE QUIET PEOPLE?"
DATA  "OH, I SEE !"
DATA  "PERHAPS IN GOOD TIME I WILL HELP YOU "
DATA  "PERHAPS IN YOUR FANTASIES I AM YOUR ONLY SUPPORT"
DATA  "PERHAPS YOU CAN NOW COPE BETTER"
DATA  "PERHAPS YOU DON'T WANT TO HAVE THE ANSWER ! "
DATA  "PERHAPS YOU PREFER TO BE CAREFUL "
DATA  "PERHAPS YOU WOULD LIKE A FRIEND TO BE ABLE TO TELL YOU "
DATA  "PERHAPS YOUR LOVE FOR YOUR FRIENDS WORRIES YOU?"
DATA  "PLEASE DON'T BE APOLOGETIC."
DATA  "PLEASE RE-STATE YOUR PROBLEM."
DATA  "REALLY, ALWAYS ?"
DATA  "SAY, DO YOU HAVE ANY INTER-PERSONAL PROBLEMS?"
DATA  "SOME OF YOUR QUESTIONS WILL INTEREST ME."
DATA  "SUPPOSE YOU MAY SOON GET WHAT YOU ASK FOR "
DATA  "TELL ME MORE ABOUT SUCH FEELINGS."
DATA  "THAT IS QUITE INTERESTING."
DATA  "TRY NOT TO BE SO DEFENSIVE!"
DATA  "WE WERE DISCUSSING THAT -- NOT ME."
DATA  "WHAT ABOUT YOUR OWN VIEWS"
DATA  "WHAT ANSWER WOULD PLEASE YOU THE MOST?"
DATA  "WHAT ARE YOU THINKING OF?"
DATA  "WHAT DO YOU THINK?"
DATA  "WHAT DOES THAT SUGGEST TO YOU?"
DATA  "WHAT DOES THE SIMILARITY SUGGEST TO YOU?"
DATA  "WHAT DOES YOUR LATEST DREAM SUGGEST TO YOU?"
DATA  "WHAT ELSE COMES TO MIND WHEN YOU ASK THAT?"
DATA  "WHAT FEELINGS DO YOU HAVE WHEN YOU APOLOGIZE?"
DATA  "WHAT IF YOU NEVER GOT YOUR WISHES ? "
DATA  "WHAT IS IT ABOUT WHERE YOU LIVE THAT WORRIES YOU?"
DATA  "WHAT IS IT THAT YOU REALLY WANT TO KNOW?"
DATA  "WHAT MAKES YOU THINK I AM ABLE TO HELP YOU"
DATA  "WHAT OTHER CONNECTIONS DO YOU SEE?"
DATA  "WHAT OTHER REASONS MIGHT THERE BE?"
DATA  "WHAT PEOPLE APPEAR IN YOUR DREAMS?"
DATA  "WHAT SIGNALS DO YOU SEE AROUND YOU?"
DATA  "WHAT WOULD IT MEAN TO YOU IF YOU GOT YOUR WISHES"
DATA  "WHEN DID YOU DECIDE TO SEE ME ?"
DATA  "WHO DO YOU DREAM OF OFTEN?"
DATA  "WHO DO YOU ENJOY BEING WITH ?"
DATA  "WHO DO YOU IMPOSE ON  ?"
DATA  "WHO DO YOU REALLY BELIEVE IN"
DATA  "WHY ARE YOU INTERESTED IN WHETHER PEOPLE CARE, OR NOT ? "
DATA  "WHY ARE YOU SO CONCERNED "
DATA  "WHY CAN'T YOU EXAMINE YOU OWN MOTIVES ?"
DATA  "WHY DO YOU ASK?"
DATA  "WHY DO YOU BRING UP THAT TOPIC?"
DATA  "WHY DO YOU MENTION THAT?"
DATA  "WHY DO YOU WANT TO DO THAT"
DATA  "WHY DON'T YOU ASK YOURSELF"
DATA  "WHY NOT JUST BE FRIENDLY ?"
DATA  "WHY NOT QUESTION THAT "
DATA  "WHY NOT?"
DATA  "WHY THE UNCERTAIN TONE?"
DATA  "WOULD YOU PREFER IF I DID NOT CARE "
DATA  "YOU ARE BEING A BIT NEGATIVE."
DATA  "YOU AREN'T SURE ?"
DATA  "YOU DON'T SEEM QUITE CERTAIN."
DATA  "YOU SEEM QUITE POSITIVE."
DATA  "YOU WANT ME TO BE ABLE TO ANSWER THAT ?"
DATA  "YOU'RE NOT REALLY TALKING ABOUT ME, ARE YOU?"
DATA "A FEMALE FRIEND"
DATA "A FRIEND YOU HAVE LEFT BEHIND"
DATA "A MALE FRIEND?"
DATA "AFFIRMATIVE"
DATA "NEGATIVE"
DATA "RELAX! ALL WILL BE REVEALED"
DATA "SOMEONE ELSE AS WELL"
DATA "SORRY, BUT IT IS NOT POSSIBLE"
DATA "SUPRISE! SUPRISE! IT'S TRUE!"
DATA "THINK ABOUT THAT LATER!"
DATA "JUST KEEP YOUR HEAD !"
DATA "YOU DO ASK DIFFICULT QUESTIONS!"
DATA "YOU MAY KNOW THE ANSWER TO THAT!"
DATA "YOU WILL KNOW THE ANSWER TO THAT ONE IN A FEW DAYS"

'DATA FOR PEOPLE
DATA "SOMEONE ELSE AS WELL","THAT LATER!","A MALE FRIEND"
DATA "A FEMALE FRIEND","YOUR ADVISOR","A FRIEND YOU HAVE LEFT BEHIND"

'DATA FOR SORT REPLIES
DATA "WHO","WHAT","WHY","WHEN","WHERE","HOW"

'--------------------------------------------------------
            'GET TOTAL DATA
            FOR I%=1 TO 143
            R$(I%)=READ$(I%)
            NEXT I%

            'GET PEOPLE DATA FROM TOTAL DATA
            FOR I%=1 TO 6
            FQ$(I%)=R$(I%+131)
            NEXT I%

            'GET QUESTION DATA FROM TOTAL DATA
            FOR I%=1 TO 6
            W2$(I%)=R$(I%+137)
            NEXT I%

 '-------------------------------------------------------

 CLS
FOR P%= 1 TO 6:?:NEXT P%

? "                          PLEASE CLICK THE 'RESIZE' ICON @ TOP RIGHT"
?
? "                              THIS PROGRAM IS COPYRIGHT 2019 BY"
? "                                     EDWARD C AYLWARD FMS":?
? "                               web - http://www.Ted-Aylward.com":?
? "                              THIS PROGRAM IS FOR ENTERTAINMENT ONLY"
? "                                NO WARRANTY IS GIVEN OR IMPLIED":?
? "                          THIS PROGRAM IS FREE AND MAY NOT TO BE SOLD":?
? "                                      (FEEDBACK WELCOME)"
?:? "                               HIT THE SPACE BAR TO CONTINUE"
WAITKEY$
CLS
? "                       HELLO, I AM ELIZA. WHAT IS YOUR NAME ";:INPUT N$:N$=UCASE$(N$):?
? "                       OK,";N$;", I WILL TRY TO HELP YOU TO SOLVE YOUR PROBLEM.":?
? "                       I DO THIS BY LISTENING TO YOUR QUESTIONS AND GIVING YOU ANSWERS"
? "                       THAT LEAD YOU TO ANSWERING RELATED QUESTIONS.":?
? "                       AS WE PROGRESS YOU WILL SEE YOUR PROBLEM UNRAVEL AS YOU GRADUALLY"
? "                       ASK QUESTIONS THAT WILL ANSWER THEMSELVES!":?
? "                       THE QUESTIONS THAT YOU ASK MUST BE ABLE TO BE ANSWERED !"
? "                           PLEASE DO NOT USE ANY PUNCTUATION - THANK YOU ! "
?
? "                       TELL ME, ";N$;", WHAT IS THE THE NAME OF SOMEONE YOU TRUST ";:INPUT NM1:NM1=UCASE$(NM1)
? "                       AND NOW GIVE ME THE NAME OF SOMEONE YOU DO NOT TRUST " ;:INPUT NM2:NM2=UCASE$(NM2):?
? "                       WHEN YOU HAVE ASKED ALL THE QUESTIONS THAT YOU WANT - TYPE FINISH "
? "                       YOU CAN ASK UP TO A HUNDRED QUESTIONS. ":?
? "                       ALL YOUR QUESTIONS AND THE ANSWERS WILL THEN BE DISPLAYED "
?:?"                                    WHEN YOU ARE READY HIT THE SPACE BAR "
WAITKEY$

    CLS
    ? "          HI, "; N$;" ,NICE OF YOU TO TALK TO ME"
    ?:?

     RANDOMIZE TIMER

     '-----------------------------------------------
    'GET QUESTIONS FROM KB - ENSURE ALL UPPER CASE
    FOR J=1 TO 100
    PRINT "    QUESTION NO. "J;" ";:INPUT Q$:Q$=UCASE$(Q$)
    Q$=Q$+" ":Q$=" "+Q$
     IF Q$=" FINISH " THEN BEND


   '-----------------------------------------------------
                'CHECK IF -I AM - IS IN QUESTION

                '***********************
                'CHECK FOR YOU/ME & SWAP

                Y=INSTR(Q$,"YOU")
                IF Y>0 THEN MID$(Q$,Y,3)="ME ":GOTO YM

                Y=INSTR(Q$," ME ")
                IF Y>0 THEN MID$(Q$,Y,5)=" YOU "
                '*************************

                YM:

                Y=INSTR(Q$,"I AM")
                YY= INT((RND(1))*5)

               IF Y>0 AND YY=0 THEN ? "   WHY ARE YOU " MID$(Q$,Y+5,LEN(Q$));" ?":GOTO CHECKOUT
               IF Y>0 AND YY=1 THEN ? "   WHO IS " MID$(Q$,Y+5,LEN(Q$));" ?":GOTO CHECKOUT
               IF Y>0 AND YY=2 THEN ? "   WHEN ARE YOU " MID$(Q$,Y+5,LEN(Q$));" ?":GOTO CHECKOUT
               IF Y>0 AND YY=3 THEN ? "   WHERE ARE YOU " MID$(Q$,Y+5,LEN(Q$));" ?":GOTO CHECKOUT
               IF Y>0 AND YY=4 THEN ? "   HOW ARE YOU " MID$(Q$,Y+5,LEN(Q$));" ?":GOTO CHECKOUT


    '----------------------------------------------------------
               'ADD RANDOM COMMENT OF PEOPLE IF WORD IS IN ? (WHO, WHAT, WHY ......)
               FOR I%=1 TO 6
               Y = INSTR(Q$,W2$(I%))
               IF Y>0 THEN PRINT "      ASK ";FQ$(INT(RND(1)*6));" ";W2$(INT(RND(1)*6));"?":GOTO CHECKOUT
               NEXT I%
       '------------------------------------------------
               'CHECK IF ELIZA IS IN QUESTION

               Y=INSTR(Q$,"ELIZA")
               YY= INT((RND(1))*6)

               IF Y>0 AND YY=0 THEN ? "    ARE YOU IN LOVE WITH ME ?":GOTO CHECKOUT
               IF Y>0 AND YY=2 THEN ? "    I HAVE BEEN THINKING ABOUT YOU ";N$:GOTO CHECKOUT
               IF Y>0 AND YY=3 THEN ? "    I THINK THAT YOU ARE A GOOD PERSON ":GOTO CHECKOUT
               IF Y>0 AND YY=4 THEN ? "    PLEASE STAY WITH ME !":GOTO CHECKOUT
               IF Y>0 AND YY=5 THEN ? "    I AM HAPPY WITH YOU ";N$:GOTO CHECKOUT
               IF Y>0 AND YY=1 THEN ? "    OH ! GO ON THEN -- GIVE ME A KISS ! ?":GOTO CHECKOUT

      '-----------------------------------------------------

      'CHECK IF -IS SHE - IN QUESTION
      Y=INSTR(Q$,"IS SHE ")
      IF Y>0 THEN ? "    WHY IS SHE " MID$(Q$,Y+7,LEN(Q$));" ?":GOTO CHECKOUT

       'CHECK IF - SHE IS - IN QUESTION
      Y=INSTR(Q$,"SHE IS")
      IF Y>0 THEN ? "    WHY IS SHE " MID$(Q$,Y+6,LEN(Q$));" ?":GOTO CHECKOUT

     'CHECK IF -HE IS - IS IN QUESTION
      Y=INSTR(Q$,"HE IS ")
      IF Y>0 THEN ? "    WHY IS HE " MID$(Q$,Y+5,LEN(Q$));" ?":GOTO CHECKOUT

      'CHECK IF -IS HE - IS IN QUESTION
      Y=INSTR(Q$,"IS HE ")
      IF Y>0 THEN ? "    WHY IS HE " MID$(Q$,Y+6,LEN(Q$));" ?":GOTO CHECKOUT

      'CHECK IF - PROBLEM - HELP - IN QUESTION
        V%=INT(RND(1)*12)
      Y=INSTR(Q$,"PROBLEM")
      Y=Y+INSTR(Q$,"HELP")
      IF Y>0 AND V%=0 THEN ? "    OF COURSE I CAN HELP YOU ";N$; ", BUT BE CAREFUL WITH ";NM2$:GOTO CHECKOUT
      IF Y>0 AND V%=1 THEN ? "    I MAY BE ABLE TO HELP YOU ";N$; ", ----  BEWARE OF ";NM2$:GOTO CHECKOUT
      IF Y>0 AND V%=2 THEN ? "    THE TIMING MAY BE OK ";N$; ", BUT ";NM2$;" WILL TRY TO CAUSE TROUBLE ":GOTO CHECKOUT
      IF Y>0 AND V%=3 THEN ? "    LET THE MATTER REST FOR NOW ";N$; ", BUT ";NM2$; " MAY BE A PROBLEM ":GOTO CHECKOUT
      IF Y>0 AND V%=4 THEN ? "    GIVE IT - MAYBE - A WEEK OR TWO ";N$; ", BUT DONT TRUST ";NM2$:GOTO CHECKOUT
      IF Y>0 AND V%=5 THEN ? "    I CAN'T HELP YOU IN THIS MATTER ";N$;", BE ON YOUR GUARD WITH ";NM2$:GOTO CHECKOUT

      IF Y>0 AND V%=6 THEN ? "    OF COURSE I CAN HELP YOU ";N$; ", BUT TRUST ";NM1$:GOTO CHECKOUT
      IF Y>0 AND V%=7 THEN ? "    I MAY BE ABLE TO HELP YOU ";N$; ", ----  GET COMFORT FROM ";NM1$:GOTO CHECKOUT
      IF Y>0 AND V%=8 THEN ? "    THE TIMING MAY BE OK ";N$; ", BUT ";NM1$;" WILL HELP YOU IN THE TROUBLES ":GOTO CHECKOUT
      IF Y>0 AND V%=9 THEN ? "    LET THE MATTER REST FOR NOW ";N$; ", BUT ";NM1$; " MAY HELP WITH THIS PROBLEM ":GOTO CHECKOUT
      IF Y>0 AND V%=10 THEN ? "    GIVE IT - MAYBE - A WEEK OR TWO ";N$; ", BUT BELIEVE IN ";NM1$:GOTO CHECKOUT
      IF Y>0 AND V%=11 THEN ? "    I CAN'T HELP YOU IN THIS MATTER ";N$;", BUT ";NM1$; " MAY PROTECT YOU FROM ";NM2$:GOTO CHECKOUT

      ' ADD RANDOM COMMENT
          IF INT((RND(1))*6)=5 THEN PRINT "     "; N$;",";
          PRINT "    ";R$(RND(1)*131)
          V%=INT(RND(1)*6)
          IF V%=4 THEN PRINT "   ASK ";NM1$;" , "; R$(129+V%)
          :GOTO CHECKOUT

     '---------------------------------------------------

  CHECKOUT:
        PRINT
        NEXT J
        BEND:


END FUNCTION