Post by Rod on Sept 18, 2022 10:20:26 GMT
I posted this a while back I just cannot find where, the search engine refuses to show me. So, I post it again.
The program will try to guess the animal you are thinking about. It follows a logical process to guess the animal. If it gets it wrong you tell the program what the difference is between the two animals and next time it will guess correctly. The program builds "intelligence" over time. This is a classic early computing program from long long ago.
The program will try to guess the animal you are thinking about. It follows a logical process to guess the animal. If it gets it wrong you tell the program what the difference is between the two animals and next time it will guess correctly. The program builds "intelligence" over time. This is a classic early computing program from long long ago.
dim node$(100,3) 'question, yes node , no node
node$(1,1)="Does it live in the sea"
node$(1,2)="2"
node$(1,3)="3"
node$(2,1)="Is it a whale"
node$(2,2)="0" 'correct
node$(2,3)="?" 'unknown
node$(3,1)="Is it scaly"
node$(3,2)="4"
node$(3,3)="?"
node$(4,1)="Is it a pangolin"
node$(4,2)="0"
node$(4,3)="?"
node=5
question=1
found=0
print "Think of an animal."
print "I am going to guess the animal you are thinking about."
while found=0
print node$(question,1);
input ans$
if upper$(left$(ans$,1))="Y" then r$=node$(question,2) else r$=node$(question,3)
if r$="0" then print "I thought as much." : found=1
if r$="?" then
print "You beat me, what is the name of your animal"
input ani$
ani$="Is it a ";ani$
print "What does your animal have that makes it different"
input que$
que$="Does it have ";que$
node$(question,3)=str$(node)
node$(node,1)=que$
node$(node,2)=str$(node+1)
node$(node,3)=str$(node+2)
node$(node+1,1)=ani$
node$(node+1,2)="0"
node$(node+1,3)="?"
node=node+1
Print "Lets start again."
question=1
else
question=val(r$)
end if
wend