My Artificial Intelligence Code Doesn't Work -- Help please! {Solved -- thank you! Any input?]

help_me_please
debugging

#1

The code has been fixed, but I would love to hear any improvements!
Huge amount of credit to

  • Sophia71205
  • MR.GAM3R
  • Work_kids_coding
  • ThinBuffalo
  • KoalaKrazy
  • Ahappycoder

Hello fellow coders! I have an assignment for a coding class that I have been working on – it is to create an artificial intelligence that can “hold a conversation”. I got stuck in this code, because I just can’t figure out a way to program this type of thing in Hopscotch. Any help would be greatly appreciated, and, of course, you would be credited in my final project.
Also, please give input on how I can improve the AI in general – suggestions such as a better conversation flow, or topics that you prefer to talk about. Thank you so much!

Here is the link:

@POMTL and @WynFrens, please help!

Here is the problem described in more detail:
I would like to be able to have the program check an answer, and continue the conversation by asking a question about that answer, or making a comment about that answer. Sometimes, I want the comments/questions to be the same, and sometimes I want them to be different. Something like this chart:

My concern is using forever loops to check for whether I have clicked one button or another. Check in the code to see. If I don’t use forever loops, then I have trouble with it checking at the right time, and if I do use forever loops, then it constantly checks and doesn’t show anything else.
Thank you so much!

Also, could anybody help with this part of the code? If I put this code in:


Then it works, but if I put this code in:

Then it doesn’t work. Any ideas on why?


W0ah some people replied ​// exy's gt
#2

The project looks good so far! Unfortunetly, I have no idea how to fix it.


#3

@WynterDiamond I will help you. What exactly do you need help with? So far it looks good.


#4

I also can help you, what happened?


#5

It looks great so far! I don’t know I to fix it, sorry


#6

User variable like this

For each thing you tap it sets the variable to a different number. Then the text checks what number it is to determine what to say


#7

Maybe less options in the beginning would help you not get confused or serve as a better model.
Like instead of all those options you could have:

I’m feeling bad. I’m feeling good. I’m feeling okay.

But that’s all I have, sorry. I haven’t really made AI before.
But I’d suggest drawing out or making a flowchart to plan what you want the code to do instead of just freely coding, as you can run into a lot of problems.


#8

It’s really good right now, you could just keep adding more features.


#9

I didn’t see any bugs in what you have so far.


#10

It looks cool
I tried it but maybe more conversation in the project
Like make the person in the game ask more about someone else like what are your favorite things or something
Just a idea


#11

Thank you @DMF and @MR.GAM3R, here is my problem:
I would like to be able to have the program check an answer, and continue the conversation by asking a question about that answer, or making a comment about that answer. Sometimes, I want the comments/questions to be the same, and sometimes I want them to be different. Something like this chart:

My concern is using forever loops to check for whether I have clicked one button or another. Check in the code to see. If I don’t use forever loops, then I have trouble with it checking at the right time, and if I do use forever loops, then it constantly checks and doesn’t show anything else.
Thank you so much!


#12

@Work_kids_coding, do you have any ideas on this? I don’t know why, but I just thought that you may have an idea :slight_smile:


#13

@WynterDiamond Yes I do! Just a minute


#14

Okay, thank you! :smiley:


#15

@WynterDiamond So, you want the program to calculate the answer the user provided and then provide a random answer to your answer?


#16

No, what I would like it to do is check which answer was given and pick a response. But my problem is in the checking of which answer was chosen. I’m just a bit confused about how to do that.


#17

@WynterDiamond Why don’t you just add values to each answer?


#18

and response… I forgot to mention response


#19

and then make it pick at random depending on the answer


#20

Well, what I’ve been trying to do is have it check for the variable to be 1, 2, or 3, for my different answers, but my problem is having it check at the right time. I’m close, and the first iteration works, but then then it simply shows the answer of the variable that the last answer was. Sorry, I’m not that great at explaining this :stuck_out_tongue: