I saw folks playing around with a "Guess the Animal" game, so thought I'd play around with something similar, which learns as it goes.
The concept is this one: You basically give it a NAME of something, and then some DESCRIPTORS for that something. The program will then let you guess something, and try and associate those descriptors with that name, to see if it can find what you're thinking of.
For example, I give it the following data NAME - DESCRIPTOR:
Steve -- fat, sexy, bald
Pete -- old, stinky, Republican
Bplus -- codes too much, is less than an A, always on [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]
Luke -- old, fat, codes too much
It'll then ask you a series of questions such as:
Is what you're thinking of old?
If you say yes, it eliminates Steve and Bplus from the possible answers, and then it eliminates "old" from the set of possible questions to ask. At this point, it then can ask, "Is what you're thinking of stinky?" If the answer is yes, it'll guess Pete as he's the only option left. If the answer is no, it'll guess Luke, as he's the only option left. If neither guess is correct, it'll ask what you were thinking of and ask for you to add new descriptors to it, so it can continue learning...
Anyway, what I have so far is this little bit (it's getting bed time here tonight, but I thought I'd share to kinda showcase the basic idea behind the concept, and to allow other folks a chance to get started on something similar of their own, to see how they'd go about accomplishing this little task. Bplus likes these type of challenges; maybe he'll want to give us a version of his own, so I'll have someone to compete and compare with, if nobody else is willing to give this little project a shot in the dark. Remember: there's no failure in failing. You can only fail by not trying. ;D
PUT #1, 1, NoN
'put 0's in the file GET #1, 1, NoN
'else get the number of names and descriptions
Nam(i) = t$ 'This should just be a name of something, like Steve, or Steve's car
Nam(i) = t$ 'This should be a descrition and numbers that it's associated with, such as "Fat" + CHR$(0) + " 1 3 5 ". This tells us that NAMES 1, 3, and 5 are all fat.
CLOSE 'And we're finished with disk access, for now.
PrintTotals
GetNewThing
LetMeGuess
PRINT "Since I know stuff, you think of something, and I'll try and guess at what you're thinking of!" FOR i
= 1 TO NoN: PA
(i
) = i:
NEXT 'corresponding to all options starting out FOR i
= 1 TO NoD: PQ
(i
) = i:
NEXT 'corresponding to all possible descriptors starting out finished = -1
PRINT "Is what you're thinking of "; Nam
(PA
(1));
"?";
PRINT "I WON! CHEESY NON-ENDING TO GAME!" GetNewThing 'if we didn't guess the right thing, then the user needs to give us a new thing!
t$ = Des(PQ(guess)) 'our guess data line
l
= INSTR(t$
, CHR$(0)) 'with the breakpoint between descriptor and entry values at point l d$
= LEFT$(t$
, l
- 1) 'the descriptor itself t$
= MID$(t$
, l
+ 1) 'all the records which reference this descriptor PRINT "Is what you're thinking of "; d$;
"?";
IF i$
= "Y" THEN 'it is one of these type items. Eliminate anything without this particular tag. s$
= " " + STR$(PQ
(i
)) + " " IF INSTR(t$
, s$
) = 0 THEN PQ
(i
) = 0 'remove all questions which don't reference this tag. s$
= " " + STR$(PA
(i
)) + " " IF INSTR(t$
, s$
) = 0 THEN PQ
(i
) = 0 'remove all answers which don't reference this tag. PQ(guess) = 0 'remove this question from our line up of future possible questions.
ELSE 'it's not one of these type items. Eliminate everything that holds this tag.
PA = 0: pq = 0
IF PA
(i
) <> 0 THEN PA
= PA
+ 1: PA
(PA
) = PA
(i
):
PRINT i
, "Possible Answer:"; PA
(i
) IF PQ
(i
) <> 0 THEN pq
= pq
+ 1: PQ
(pq
) = PQ
(i
):
PRINT i
, pq
, "Possible Question:"; Des
(PQ
(i
))
INPUT "What do you call this marvelous new thing that I know nothing about =>"; n$
'ShutDown 'not implemented yet, but here's where we could end the program, if we want, just by leaving things blank.
SYSTEM 'this should be an EXIT SUB, once ShutDown is implemented. IF i
<= NoN
THEN 'we already have such a thing PRINT "You've already told me about "; n$;
". ";
ELSE 'otherwise, it's something new to learn about out$
= "So far, I don't know anything about this " + n$
+ "." NoN = NoN + 1
Nam(NoN) = n$
index = i 'this is the index reference of the name we're working with
PRINT "Tell me three new things which describe this "; n$
LearnNewThing:
INPUT " "; t$
'learn something about this thing 'check to see if the thing we're learning is already a listed trait
IF j
<= NoD
THEN 'we found an existing item t1$
= " " + STR$(index
) + " " IF INSTR(Des
(j
), t1$
) THEN 'we already have this fact associated with this descriptor PRINT "Sorry. I already knew this about "; n$;
". Tell me some new thing about it, instead." Des
(j
) = Des
(j
) + " " + STR$(index
) + " " 'add this fact to this descriptor ELSE 'we're learning a completely new descriptor NoD = NoD + 1
Des
(NoD
) = t$
+ CHR$(0) + " " + STR$(index
) + " "
Note that this is a barely viable work-in-progress at this stage. It can open and read a file, but it can't write to one. There's no shutdown routine. There's a lot of unwritten blocks of ELSE, that simple follow up with END IF...
The plan (for me, at least), is to fill in those missing blocks tomorrow, and see about making this a working little project where it'll learn as it goes, so it can figure out how to associate various descriptors to corresponding items.
UNRELATED Note2: This is also similar to how I'd end up writing a learning chat bot, which is what I once tried to explain to Ron about. You basically form a list of nouns, verbs, and adjectives, and then you form these exact style associations between them. Then when the user triggers one of those items, you can flow the conversation to one of the matching associations.
User: I like cars.
Chat Bot: Some cars are green. (green is associated as an attribute with cars)
User: Yeah, but some are blue.
Chat Bot: The sky is blue. (the sky is associated as something having an attribute as blue)