huo writer - a simple AI neural network (link)

New to FreeBASIC? Post your questions here.
Post Reply
ron77
Posts: 212
Joined: Feb 21, 2019 19:24

huo writer - a simple AI neural network (link)

Post by ron77 »

hi all...

an interesting site/blog that i found about programming here is link:
https://harmoniaphilosophica.com/2020/0 ... ties-qb64/

and here is a code originally for Qbasic or QB64 taken from that blog it's called the HUO writer a simple AI philosophical editor using neural networks...
it would be nice if someone translate it to FB dialect - the code works thanks to #lang "qb" dialect...

Code: Select all

#LANG "qb"
'Huo Writer v0.1
'Created by Spyridon Kakos (huo)

OPTION BASE 1

'Declare variables
'The tables have 3 columns for each row
'First column: The text
'Second column: The gender (male, female, neutral, indifferent - m, f, n, i)
'Third column: The number (single, plural, indifferent - s, p, i)
DIM SHARED Tags$(20, 3)
DIM SHARED H1$(14, 3): DIM SHARED H2$(22, 3): DIM SHARED H3$(10, 3): DIM SHARED H3Q$(10, 3)
DIM SHARED H4$(10, 3): DIM SHARED H5$(11, 3)
DIM SHARED I1$(3): DIM SHARED I2$(3)
DIM SHARED K1$(10, 3): DIM SHARED K2$(8, 3): DIM SHARED K3$(10, 3)
DIM SHARED T$(3)
'Neural network tables
'Tables holding the combinations performed by the program to generate the phrases
COMMON SHARED learningMode
COMMON SHARED H1counter
COMMON SHARED H2counter
COMMON SHARED Kcounter
DIM SHARED TempCombinationsH1(100, 3) '(Phrase H.1)
DIM SHARED TempCombinationsH2(100, 2) '(Phrase H.2)
DIM SHARED TempCombinationsK(100, 3) '(Phrase K)
'Tables holding the combinations the human did not like, so that they do not repeat next time
DIM SHARED BadCombinationsH1(100, 3) '(Phrase H.1)
DIM SHARED BadCombinationsH2(100, 2) '(Phrase H.2)
DIM SHARED BadCombinationsK(100, 3) '(Phrase K)


'PHRASE 1 (Phrase H.1)

'Set Variables for first phrase (Phrase H.1) generation
'-------------------------------------------------------------------------------------------------------------------
'Start the phrase
H1$(1, 1) = "Think why ": H1$(1, 2) = "i": H1$(1, 3) = "i"
H1$(2, 1) = "The ": H1$(2, 2) = "i": H1$(2, 3) = "i"
H1$(3, 1) = "Consider that ": H1$(3, 2) = "i": H1$(3, 3) = "i"
H1$(4, 1) = "Remember that ": H1$(4, 2) = "i": H1$(4, 3) = "i"
H1$(5, 1) = "All ": H1$(5, 2) = "i": H1$(5, 3) = "p"
H1$(6, 1) = "You see ": H1$(6, 2) = "i": H1$(6, 3) = "i"
H1$(7, 1) = "Always ": H1$(7, 2) = "i": H1$(7, 3) = "i"
H1$(8, 1) = "Never do ": H1$(8, 2) = "i": H1$(8, 3) = "i"
H1$(9, 1) = "We always knew that ": H1$(9, 2) = "i": H1$(9, 3) = "i"
H1$(10, 1) = "It's not that ": H1$(10, 2) = "i": H1$(10, 3) = "i"
H1$(11, 1) = "Do ": H1$(11, 2) = "i": H1$(11, 3) = "i"
H1$(12, 1) = "How can ": H1$(12, 2) = "i": H1$(12, 3) = "i"
H1$(13, 1) = "But don't ": H1$(13, 2) = "i": H1$(13, 3) = "i"
H1$(14, 1) = "Could ": H1$(14, 2) = "i": H1$(14, 3) = "i"
'-------------------------------------------------------------------------------------------------------------------
'Tag to be added here
'-------------------------------------------------------------------------------------------------------------------
'Enter a verb...
H2$(1, 1) = " always obscure ": H2$(1, 2) = "i": H2$(1, 3) = "i"
H2$(2, 1) = " interact with ": H2$(2, 2) = "i": H2$(2, 3) = "p"
H2$(3, 1) = " promote ": H2$(3, 2) = "i": H2$(3, 3) = "p"
H2$(4, 1) = " destroy ": H2$(4, 2) = "i": H2$(4, 3) = "p"
H2$(5, 1) = " support ": H2$(5, 2) = "i": H2$(5, 3) = "p"
H2$(6, 1) = " exist with ": H2$(6, 2) = "i": H2$(6, 3) = "p"
H2$(7, 1) = " kill the One, but give birth to ": H2$(7, 2) = "i": H2$(7, 3) = "p"
H2$(8, 1) = " never include ": H2$(8, 2) = "i": H2$(8, 3) = "p"
H2$(9, 1) = " are not part of ": H2$(9, 2) = "i": H2$(9, 3) = "p"
H2$(10, 1) = " can Be without ": H2$(10, 2) = "i": H2$(10, 3) = "i"
H2$(11, 1) = " cannot exist without ": H2$(11, 2) = "i": H2$(11, 3) = "i"
H2$(12, 1) = " only exist because of ": H2$(12, 2) = "i": H2$(12, 3) = "p"
H2$(13, 1) = " define ": H2$(13, 2) = "i": H2$(13, 3) = "i"
H2$(14, 1) = " interacts with ": H2$(14, 2) = "i": H2$(14, 3) = "s"
H2$(15, 1) = " promotes ": H2$(15, 2) = "i": H2$(15, 3) = "s"
H2$(16, 1) = " destroys ": H2$(16, 2) = "i": H2$(16, 3) = "s"
H2$(17, 1) = " supports ": H2$(17, 2) = "i": H2$(17, 3) = "s"
H2$(18, 1) = " exist with ": H2$(18, 2) = "i": H2$(18, 3) = "s"
H2$(19, 1) = " kills the One, but gives birth to ": H2$(19, 2) = "i": H2$(19, 3) = "s"
H2$(20, 1) = " never includes ": H2$(20, 2) = "i": H2$(20, 3) = "s"
H2$(21, 1) = " is not part of ": H2$(21, 2) = "i": H2$(21, 3) = "s"
H2$(22, 1) = " only exists because of ": H2$(22, 2) = "i": H2$(22, 3) = "s"
'-------------------------------------------------------------------------------------------------------------------
'What does the verb do?
H3$(1, 1) = "thinking.": H3$(1, 2) = "i": H3$(1, 3) = "i"
H3$(2, 1) = "knowledge.": H3$(2, 2) = "i": H3$(2, 3) = "i"
H3$(3, 1) = "the self.": H3$(3, 2) = "i": H3$(3, 3) = "i"
H3$(4, 1) = "humans.": H3$(4, 2) = "i": H3$(4, 3) = "i"
H3$(5, 1) = "us.": H3$(5, 2) = "i": H3$(5, 3) = "i"
H3$(6, 1) = "oblivion.": H3$(6, 2) = "i": H3$(6, 3) = "i"
H3$(7, 1) = "being.": H3$(7, 2) = "i": H3$(7, 3) = "i"
H3$(8, 1) = "existence.": H3$(8, 2) = "i": H3$(8, 3) = "i"
H3$(9, 1) = "the void.": H3$(9, 2) = "i": H3$(9, 3) = "i"
H3$(10, 1) = "nothingness.": H3$(10, 2) = "i": H3$(10, 3) = "i"
'-------------------------------------------------------------------------------------------------------------------
'Endings with questions
H3Q$(1, 1) = "thinking?": H3Q$(1, 2) = "i": H3Q$(1, 3) = "i"
H3Q$(2, 1) = "knowledge?": H3Q$(2, 2) = "i": H3Q$(2, 3) = "i"
H3Q$(3, 1) = "the self?": H3Q$(3, 2) = "i": H3Q$(3, 3) = "i"
H3Q$(4, 1) = "humans?": H3Q$(4, 2) = "i": H3Q$(4, 3) = "i"
H3Q$(5, 1) = "us?": H3Q$(5, 2) = "i": H3Q$(5, 3) = "i"
H3Q$(6, 1) = "oblivion?": H3Q$(6, 2) = "i": H3Q$(6, 3) = "i"
H3Q$(7, 1) = "being?": H3Q$(7, 2) = "i": H3Q$(7, 3) = "i"
H3Q$(8, 1) = "existence?": H3Q$(8, 2) = "i": H3Q$(8, 3) = "i"
H3Q$(9, 1) = "the void?": H3Q$(9, 2) = "i": H3Q$(9, 3) = "i"
H3Q$(10, 1) = "nothingness?": H3Q$(10, 2) = "i": H3Q$(10, 3) = "i"
'-------------------------------------------------------------------------------------------------------------------


'PHRASE 2 (Phrase H.2)

'Set Variables for second phrase (Phrase H.2) generation
H4$(1, 1) = "Could ": H4$(1, 2) = "i": H4$(1, 3) = "i"
H4$(2, 1) = "Can ": H4$(2, 2) = "i": H4$(2, 3) = "i"
H4$(3, 1) = "Should ": H4$(3, 2) = "i": H4$(3, 3) = "i"
H4$(4, 1) = "Must ": H4$(4, 2) = "i": H4$(4, 3) = "i"
H4$(5, 1) = "Maybe ": H4$(5, 2) = "i": H4$(5, 3) = "i"
H4$(6, 1) = "Why ": H4$(6, 2) = "i": H4$(6, 3) = "i"
H4$(7, 1) = "Would ": H4$(7, 2) = "i": H4$(7, 3) = "i"
H4$(8, 1) = "How could ": H4$(8, 2) = "i": H4$(8, 3) = "i"
H4$(9, 1) = "Isn't that ": H4$(9, 2) = "i": H4$(9, 3) = "i"
H4$(10, 1) = "Why never ": H4$(10, 2) = "i": H4$(10, 3) = "i"
'-------------------------------------------------------------------------------------------------------------------
'Tag to be added here
'-------------------------------------------------------------------------------------------------------------------
H5$(1, 1) = " create anything?": H5$(1, 2) = "i": H5$(1, 3) = "i"
H5$(2, 1) = " exist without you?": H5$(2, 2) = "i": H5$(2, 3) = "i"
H5$(3, 1) = " be part of anything?": H5$(3, 2) = "i": H5$(3, 3) = "i"
H5$(4, 1) = " not be?": H5$(4, 2) = "i": H5$(4, 3) = "i"
H5$(5, 1) = " include everything?": H5$(5, 2) = "i": H5$(5, 3) = "p"
H5$(6, 1) = " make you forget?": H5$(6, 2) = "i": H5$(6, 3) = "i"
H5$(7, 1) = " deny our being?": H5$(7, 2) = "i": H5$(7, 3) = "i"
H5$(8, 1) = " be without being?": H5$(8, 2) = "i": H5$(8, 3) = "i"
H5$(9, 1) = " reflect on the calm sea?": H5$(9, 2) = "i": H5$(9, 3) = "i"
H5$(10, 1) = " die?": H5$(10, 2) = "i": H5$(10, 3) = "i"
H5$(11, 1) = " includes everything?": H5$(11, 2) = "i": H5$(11, 3) = "s"
'-------------------------------------------------------------------------------------------------------------------


'INTERMEDIATE PHRASE 1

'Set variables for Intermediate 1 phrase generation
I1$(1) = "But this was always the case."
I1$(2) = "Petty humans."
I1$(3) = "Ignorant men."


'PHRASE 3 (Phrase K)

'Set Variables for third phrase (Phrase K) generation
'---------------------------------------------------------------------------------------------------
K1$(1, 1) = "Death": K1$(1, 2) = "i": K1$(1, 3) = "i"
K1$(2, 1) = "Life": K1$(2, 2) = "i": K1$(2, 3) = "i"
K1$(3, 1) = "Self": K1$(3, 2) = "i": K1$(3, 3) = "i"
K1$(4, 1) = "God": K1$(4, 2) = "i": K1$(4, 3) = "i"
K1$(5, 1) = "Existence": K1$(5, 2) = "i": K1$(5, 3) = "i"
K1$(6, 1) = "Being": K1$(6, 2) = "i": K1$(6, 3) = "i"
K1$(7, 1) = "Reality": K1$(7, 2) = "i": K1$(7, 3) = "i"
K1$(8, 1) = "Others": K1$(8, 2) = "i": K1$(8, 3) = "p"
K1$(9, 1) = "Thought": K1$(9, 2) = "i": K1$(9, 3) = "i"
K1$(10, 1) = "Knowledge": K1$(10, 2) = "i": K1$(10, 3) = "i"
'---------------------------------------------------------------------------------------------------
K2$(1, 1) = " defines ": K2$(1, 2) = "i": K2$(1, 3) = "s"
K2$(2, 1) = " is defined by ": K2$(2, 2) = "i": K2$(2, 3) = "s"
K2$(3, 1) = " creates ": K2$(3, 2) = "i": K2$(3, 3) = "s"
K2$(4, 1) = " is created by ": K2$(4, 2) = "i": K2$(4, 3) = "s"
K2$(5, 1) = " define ": K2$(5, 2) = "i": K2$(5, 3) = "p"
K2$(6, 1) = " are defined by ": K2$(6, 2) = "i": K2$(6, 3) = "p"
K2$(7, 1) = " create ": K2$(7, 2) = "i": K2$(7, 3) = "p"
K2$(8, 1) = " are created by ": K2$(8, 2) = "i": K2$(8, 3) = "p"
'--------------------------------------------------------------------------------------------------
K3$(1, 1) = "death.": K3$(1, 2) = "i": K3$(1, 3) = "i"
K3$(2, 1) = "life.": K3$(2, 2) = "i": K3$(2, 3) = "i"
K3$(3, 1) = "self.": K3$(3, 2) = "i": K3$(3, 3) = "i"
K3$(4, 1) = "being.": K3$(4, 2) = "i": K3$(4, 3) = "i"
K3$(5, 1) = "others.": K3$(5, 2) = "i": K3$(5, 3) = "i"
K3$(6, 1) = "existence.": K3$(6, 2) = "i": K3$(6, 3) = "i"
K3$(7, 1) = "reality.": K3$(7, 2) = "i": K3$(7, 3) = "i"
K3$(8, 1) = "God.": K3$(8, 2) = "i": K3$(8, 3) = "i"
K3$(9, 1) = "thought.": K3$(9, 2) = "i": K3$(9, 3) = "i"
K3$(10, 1) = "knowledge.": K3$(10, 2) = "i": K3$(10, 3) = "i"
'--------------------------------------------------------------------------------------------------


'INTERMEDIATE PHRASE 2

'Set variables for Intermediate 2 phrase generation
I2$(1) = "Don't you remember?"
I2$(2) = "Can't you see?"
I2$(3) = "Search deep inside."


'TERMINATING PHRASE

'Set variables for Terminating phrase generation
T$(1) = "Just let go. Feel the terror..."
T$(2) = "Stop thinking. And you will see..."
T$(3) = "Search the abyss. You know it to be true..."


'Neural network variables intialization
H1counter = 1
H2counter = 1
Kcounter = 1


CLS: SCREEN 9: COLOR 7

PRINT "????????????????????????"
PRINT "?                      ?"
PRINT "? Huo Writer 2020 v0.1 ?"
PRINT "?                      ?"
PRINT "????????????????????????"

PRINT ""
PRINT "Welcome to Huo Writer!"
PRINT "A creation by Spyridon Kakos (huo)"
PRINT "The wisest program that cannot think!"

ProgramStart:
PRINT ""
PRINT "Press 'd' to start the discussion or 'h' for Help"

e$ = ""
DO
    DO
        hyn$ = INKEY$
    LOOP WHILE hyn$ = ""
    SELECT CASE hyn$
        CASE "d", "D"
            GOTO AskInput
        CASE "h", "H"
            GOTO Help
        CASE ELSE
            e$ = "A"
    END SELECT
LOOP WHILE e$ <> ""

Help:
CLS
PRINT "------------- HUO WRITER v0.1 HELP -------------"
PRINT ""
PRINT "I. HOW TO USE"
PRINT ""
PRINT "Enter tags related to the topic of discussion. Then wait for the output."
PRINT "Be patient. Give time to the wise program to think."
PRINT "No, it can't think. And that is immensely wiser than being able to."
PRINT ""
PRINT "II. ENTERING TAGS"
PRINT ""
PRINT "For each tag, define its parameters. The greater the quality of the tag definition, the greater the quality of the output."
PRINT ""
PRINT "Parameters to define:"
PRINT "> Gender: Is the gender of the tag male (m), female (f), neutral (n), an adjective (a) or indifferent (i) ? Tip: Choose neutral if the 'the' is needed, e.g. put 'Death' as male, the 'irrational' as neutral."
PRINT "> Number: Is the number of the tag single (s), plural (p) or indifferent (i) ?"
PRINT ""
PRINT "(press a key to continue...)"
DO
    hyn$ = INKEY$
LOOP WHILE hyn$ = ""
PRINT ""
PRINT "III. NEURAL NETWORK"
PRINT ""
PRINT "If learning mode is enabled, the computer will ask for feedback after each phrase. If the feedback is negative, the selected combination that generated the phrase will not be repeated again. After many iterations, computer 'learns' to think like you do. Bad combinations learned are erased every time the program starts."

GOTO ProgramStart

AskInput:
'Start the program and the discussion!

setLearningMode:
PRINT ""
PRINT "Enable learning mode? (y/n) "

e$ = ""
DO
    DO
        hyn$ = INKEY$
    LOOP WHILE hyn$ = ""
    SELECT CASE hyn$
        CASE "y", "Y"
            learningMode = 1
        CASE "n", "N"
            learningMode = 0
        CASE ELSE
            e$ = "A"
    END SELECT
LOOP WHILE e$ <> ""

CLS
PRINT "------------- HUO WRITER v0.1 DISCUSSION -------------"
PRINT ""
PRINT "Hello my friend."
SLEEP 2
PRINT "Come. Tell me."
SLEEP 2
PRINT "What is our theme of discussion to-day?"
PRINT ""
INPUT "Number of tags: ", tagsNo
PRINT "Thank you"
SLEEP 2
PRINT "": PRINT "Now...": PRINT ""
SLEEP 2
PRINT "Please enter related tags one by one..."
SLEEP 2
PRINT "One word only per tag please. All in small letters."
PRINT "Enter Bye or just press Enter to exit."

'Read related tags for the subject of discussion
FOR I = 1 TO tagsNo
    'textToShow$ = "Tag " + STR$(I) + ": "
    'INPUT textToShow$, Tags$(I)
    PRINT ""
    INPUT "Enter Tag: ", Tags$(I, 1)
    IF Tags$(I, 1) = "Bye" OR Tags$(I, 1) = "" THEN END
    TagGender:
    INPUT "ENTER THE TAG'S GENDER (m, f, n, a, i) : ", Tags$(I, 2)
    IF Tags$(I, 2) <> "m" AND Tags$(I, 2) <> "f" AND Tags$(I, 2) <> "n" AND Tags$(I, 2) <> "a" AND Tags$(I, 2) <> "i" THEN GOTO TagGender
    TagNumber:
    INPUT "ENTER THE NUMBER OF THE TAG (s, p, i)  : ", Tags$(I, 3)
    IF Tags$(I, 3) <> "s" AND Tags$(I, 3) <> "p" AND Tags$(I, 3) <> "i" THEN GOTO TagNumber
NEXT I

PRINT "": PRINT "Interesting. Let me think...": PRINT "": SLEEP 3

'------------------------------------------
'Generate first phrase (uses H1, H2, H3)
'------------------------------------------
PhraseH1:

RANDOMIZE TIMER
T1 = INT(RND * tagsNo) + 1
IF Tags$(T1, 2) = "a" THEN GOTO PhraseH1 'Cannot put an adjective in the beginning!
T2 = INT(RND * tagsNo) + 1
A = INT(RND * 13) + 1: B = INT(RND * 21) + 1: C = INT(RND * 9) + 1

'----- Validations -----
'If illegal combination (e.g. Always ... always) then, generate new phrase!
'Always + Always is forbidden
IF A = 7 AND B = 1 THEN GOTO PhraseH1
'If number is not equal (plural with plural, single with single) or the number of the next element is not indifferent, then generate phrase again
IF Tags$(T1, 3) <> H2$(B, 3) AND H2$(B, 3) <> "i" THEN GOTO PhraseH1

'Neural network: Check if the combination selected was discarded by human previously. If yes, generate a different one!
FOR I = 1 TO H1counter
    IF BadCombinationsH1(I, 1) = A AND BadCombinationsH1(I, 2) = B AND BadCombinationsH1(I, 3) = C THEN GOTO PhraseH1
NEXT I

'----- Create the phrase -----
'If a question phrase is selected from H1$, then you must select from specific endings from H3Q$, which contains questions
'If no question is selected, then print the phrase by selecting from the H3$ table
'Neutral tags need the The (Question)
IF Tags$(T1, 2) = "n" AND A >= 11 THEN PRINT H1$(A, 1) + "the " + Tags$(T1, 1) + H2$(B, 1) + H3Q$(C, 1): GOTO PhraseH2
'Neutral tags need the The (Non-question)
IF Tags$(T1, 2) = "n" AND A <= 10 THEN PRINT H1$(A, 1) + "the " + Tags$(T1, 1) + H2$(B, 1) + H3$(C, 1): GOTO PhraseH2
'Any other non-neutral tag (Question)
IF A >= 11 THEN PRINT H1$(A, 1) + Tags$(T1, 1) + H2$(B, 1) + H3Q$(C, 1): GOTO PhraseH2
'Any other non-neutral tag (Non-question)
IF A <= 10 THEN PRINT H1$(A, 1) + Tags$(T1, 1) + H2$(B, 1) + H3$(C, 1): GOTO PhraseH2

'Neural network: Store selected combination if the user decides it is a bad one
IF learningMode = 1 THEN

    PRINT "": PRINT "Was this sentence a good one? (y/n)"
    e$ = ""
    DO
        DO
            hyn$ = INKEY$
        LOOP WHILE hyn$ = ""
        SELECT CASE hyn$
            CASE "y", "Y"
                e$ = ""
            CASE "n", "N"
                BadCombinationsH1(H1counter, 1) = A
                BadCombinationsH1(H1counter, 2) = B
                BadCombinationsH1(H1counter, 3) = C
            CASE ELSE
                e$ = "A"
        END SELECT
    LOOP WHILE e$ <> ""
    PRINT "Thank you for your input.": PRINT ""

END IF

SLEEP 3

'------------------------------------
'Generate second phrase (uses H4, H5)
'------------------------------------
PhraseH2:

A = INT(RND * 9) + 1
B = INT(RND * 10) + 1

'Validations
'If number is not equal (plural with plural, single with single) or the number of the next element is not indifferent, then generate phrase again
IF Tags$(T2, 3) <> H5$(B, 3) AND H5$(B, 3) <> "i" THEN GOTO PhraseH2

'Neural network: Check if the combination selected was discarded by human previously. If yes, generate a different one!
FOR I = 1 TO H2counter
    IF BadCombinationsH2(I, 1) = A AND BadCombinationsH2(I, 2) = B THEN GOTO PhraseH2
NEXT I

'----- Create the phrase -----
IF Tags$(T1, 2) = "n" THEN PRINT H4$(A, 1) + "the " + Tags$(T2, 1) + H5$(B, 1): GOTO Intermediate1
IF Tags$(T1, 2) <> "n" THEN PRINT H4$(A, 1) + Tags$(T2, 1) + H5$(B, 1)

'Neural network: Store selected combination if the user decides it is a bad one
IF learningMode = 1 THEN

    PRINT "": PRINT "Was this sentence a good one? (y/n)"
    e$ = ""
    DO
        DO
            hyn$ = INKEY$
        LOOP WHILE hyn$ = ""
        SELECT CASE hyn$
            CASE "y", "Y"
                e$ = ""
            CASE "n", "N"
                BadCombinationsH2(H2counter, 1) = A
                BadCombinationsH2(H2counter, 2) = B
            CASE ELSE
                e$ = "A"
        END SELECT
    LOOP WHILE e$ <> ""
    PRINT "Thank you for your input.": PRINT ""

END IF

SLEEP 3

'------------------------------
'Generate intermediate phrase 1
'------------------------------
Intermediate1:
RANDOMIZE TIMER
A = INT(RND * 3) + 1
PRINT I1$(A)
SLEEP 3

'----------------------
'Generate third phrase
'----------------------
PhraseK:
RANDOMIZE TIMER
A = INT(RND * 9) + 1: B = INT(RND * 7) + 1: C = INT(RND * 9) + 1
IF C = A THEN GOTO PhraseK
'If number is not equal (plural with plural, single with single) or the number of the next element is not indifferent, then generate phrase again
IF K1$(A, 3) <> K2$(B, 3) AND K2$(B, 3) <> "i" THEN GOTO PhraseK

'Neural network: Check if the combination selected was discarded by human previously. If yes, generate a different one!
FOR I = 1 TO Kcounter
    IF BadCombinationsK(I, 1) = A AND BadCombinationsK(I, 2) = B AND BadCombinationsK(I, 3) = C THEN GOTO PhraseK
NEXT I

'----- Create the phrase -----
PRINT K1$(A, 1) + K2$(B, 1) + K3$(C, 1)

'Neural network: Store selected combination if the user decides it is a bad one
IF learningMode = 1 THEN

    PRINT "": PRINT "Was this sentence a good one? (y/n)"
    e$ = ""
    DO
        DO
            hyn$ = INKEY$
        LOOP WHILE hyn$ = ""
        SELECT CASE hyn$
            CASE "y", "Y"
                e$ = ""
            CASE "n", "N"
                BadCombinationsK(Kcounter, 1) = A
                BadCombinationsK(Kcounter, 2) = B
                BadCombinationsK(Kcounter, 3) = C
            CASE ELSE
                e$ = "A"
        END SELECT
    LOOP WHILE e$ <> ""
    PRINT "Thank you for your input.": PRINT ""

END IF

SLEEP 3

'------------------------------
'Generate intermediate phrase 2
'------------------------------
Intermediate2:
RANDOMIZE TIMER
A = INT(RND * 3) + 1
PRINT I2$(A)
SLEEP 3

'---------------------------
'Generate terminating phrase
'---------------------------
Terminate:
RANDOMIZE TIMER
A = INT(RND * 3) + 1
PRINT T$(A)
SLEEP 3

'Want to continue?
PRINT "": PRINT "Want more? (y/n) "

e$ = ""
DO
    DO
        hyn$ = INKEY$
    LOOP WHILE hyn$ = ""
    SELECT CASE hyn$
        CASE "y", "Y"
            H1counter = H1counter + 1
            H2counter = H2counter + 1
            Kcounter = Kcounter + 1
            GOTO AskInput
        CASE "n", "N"
            END
    END SELECT
LOOP WHILE e$ <> ""

END



Post Reply