0 Favourites

Difficulties getting random without duplicates

  • 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.

      randomize-array_p587279?#p587279 how-do-i-get-a-random-nr-not-to-repeat_p808042?#p808042

    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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
random bugs and suggestions
90 4,518
Tom's avatar
Tom Construct Team Founder
Unread hot topic
0 Favourites
Rep is very random...
73 17,907
allavett's avatar
allavett
Unread hot topic
0 Favourites
Duplicating objects....
32 2,523
Jeswen's avatar
Jeswen