Difficulties getting random without duplicates

Get help using Construct 2

Post » Tue Oct 20, 2015 8:24 am

Hi everyone !

I know that the question I'm going to ask has already been asked several times. I've tried the techniques I found on the forum, but the way I want to randomize my data is a bit more complicated (I guess it's not, but I can't figure out what I'm doing wrong).

First, I'm new to game programming and I'm probably making terrible mistakes, please forgive my incomptence.

What I want to do
    I want to make a trivia game that takes the form of several mini-games. But that is not important.
    I want to load the questions (and their related answers) from an external .txt and randomize them in a way that the same question doesn't appear twice.

I get the logic behind both techniques :
    I successfully get my questions and answers from the .txt
    I successfully randomize them
    I don't manage to avoid duplicates

Here is a link to my .capx : drive.google.com/file/d/0B8I4fWcKPnzhZDVoMXdsbzdtTk0/view?usp=sharing

If someone can help me in another way than giving me a link to the following tutorials, I would be grateful forever.

Thank you.

Edit : sorry for the links, it seems like I don't have the permission to post well-formated URLs.
Edit2 : ok now I understand why I can't post URL.
Last edited by davidbox on Tue Oct 20, 2015 8:32 am, edited 1 time in total.
Posts: 5
Reputation: 869

Post » Tue Oct 20, 2015 8:32 am

Sorry none of your links work.

But, this is how you do it. In the tutorial section there are a number examples on random, none duplicates using array.

So the array randomizes pulls a number and deletes the number (so impossible to get duplicate)
You now have a number. Use that number to get your question from txt however you do that.

Edit: okay you put links in ;)

What you want is to have array for numbers (number questions you trying to randomize) have that array in a function that spits out the number, which is deleted as I said previously.
Use that number to fetch your questions.

Or shuffle it into array at start of game, then delete on at a time
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
Posts: 1,429
Reputation: 12,708

Post » Tue Oct 20, 2015 9:15 am

Thank you for you answer DUTOIT.
I'll try to focus and get this thing done, I've spent hours testing stuff...

Edit: Finally got it! Thanks DUTOIT, your explanation helped me to see what I was doing wrong.
Posts: 5
Reputation: 869

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests