Guessing game help- How to implement open ended answering mechanism

Hi all! I have to start with saying I am new to the game development so if the title throw you off a little bit, thats probably why :smiley: I recently came across a problem. I was experimenting with a type of a guessing game where the player types an aswer and get a point. But the problem is that there are numerous right answers for a given question. For example, (let’s say) the game ask the player to type the name of a city that is in UK, any city. This makes there are total of 70 right answers. So my question is this, how can I make the game compare the given answer from a selection of possible correct answers? Should I code every single possible answer in the events sheet or should I implement a variable? How could I do that with a variable? Because further down the development, the game could ask a question which consists even more possible answers (like names) I have been trying to figure it out with wiki, youtube and forum for days but no luck. Because I lack experience, sometimes I cant even understand some solutions :smiley: Here is the events sheet:

The game currently able to detect only one answer as right or wrong as you can see. (Nvm the Washington answer, I was just testing with the first thing pop up to my mind :smiley: ) Thank you all in advance!

My suggestion, though it may be a bit on the steep side of the learning curve, is look at an array of structures and the regular expression extension. Have the questions as an array, with the text and list of potential comma separated answers as structure children. Then use regex to check if the answer is in the solution string.

I would envisage the structure looking something like (note the ", " at the answer start, and the “,” at the end of the answer - they’re important for finding the given answer) :


Get the total number of questions for the random selection later on :


To store the question’s text and answer (in this snip a random question is chosen and the question text and answer placed into 2 variable):


And to check if the entered answer is in the list (uses the regex extension) :

image

3 Likes

Thank you so much! It’s kinda difficult to learn yes, but I’m willing!

With this type of system is there a strategy for user typos and spelling mistakes?

İf you are asking me, I think I will simply display an error message to inform that what they write is not a correct answer. But there is an extension called “validate imput”, I may try to configure it to show what is wrong with the given answer, if the player do so.

What I meant by this type of system is when the user has to type an answer rather than select from a range of given answers.

If the user gets the answer wrong, do they get another chance? And does that depend on whether they were completely wrong or just did a typo or spelling mistake?

For example, if the question is name a country in Africa and I instead name a country in Europe, let’s say Bulgaria, then I’ll be wrong. But if I correctly pick an African country, say Angola but incorrectly type it as Anglola, what will happen? Will I get a chance to correct my mistake or will I be marked as wrong? And if so, will the user get frustrated and give up?

HI @neomorphtri
I suggest you a different approache: organize questions and answers in a external json file.

Than you can load it in two different ways:

That would be a good progression once OP has a handle on GDevelop arrays and structures.

1 Like

@Bubble One of the requirements of the is to type the anwers correctly. If they don’t know how to spell it, they won’t get a point for that but because there are more than one question in each level, they will have the ability to just pass the questions they stuck with.Plus I aim to make it online, which you can play with friends and I think the struggle for correct spelling can turn into a funny situation rather than a burden :smiley:

@jumpingj Thank you so much! I was just thinking what if I create somesort of external dictionary for game to compare the answers to and that’s it! I will bookmark the link and study when I learn more about variables!

Also I put this project to self to learn a bit more about variables by experimenting with simpler mechanics of variables. Thank you all for you help! :smiling_face_with_three_hearts:

1 Like

That sounds really good, neomorphtri, haha yayyy for good spellers and proof readers

1 Like