Generate a random number (from 1-16) without repeating a num

I am creating a card game. I need to generate 16 numbers (1-16) in random without REPEATS. How do I generate a random number in that range that won’t create one that has already been repeated?

Thank you :slight_smile:

Here is a way to do it:
RandomNotRepeat.gdg (25.7 KB)

Basically it does the following:

  1. Create a void structure
  2. Create a random number N
  3. If N exists in the structure (is a child, Structure.N exists) return to [2]
  4. If N doesn’t exist in the structure, add it. And do whatever you want with this new N, it will be, for example 5, only once
  5. Return to [2] if all the numbers (16 in your case) have not been created yet.
1 Like

Thank you :slight_smile:

How can I open gdg file?

This is 3 years old. Don’t necropost. Gdg files are the files that were opened instead of json files on old versions of GDevelop. You cannot open them anymore, and the solution in such files are probably incompatible with newer versions.

1 Like