- Aug 28, 2018
- 1,217
- 778
I'm working on a little deduction thing where some variables are arranged randomly in a list, and you're trying to figure out what order they're in. The clues come in the form of comparative statements, i.e. "First_Example is ranked higher than Second_Example." That part's easy, I just generate two random numbers and then have strings that point to that number's place in the list...
a = renpy.random.randrange(0,8)
c = renpy.random.randrange(0,8)
texta = ExampleList[a]
textc = ExampleList[c]
if a < c:
"[texta] is ranked higher than [textc]"
...And so forth. I don't know if that's necessarily the best way to do it, but that's not what I'm concerned about right now. The problem is, when I run a loop of a bunch of those statements (say 20), I see more than a couple duplicates. So I was trying to figure out how to have it check for duplicates before it said the clue, but apparently I'm missing something here (I'm much more familiar with C# than ren'py), because I can't figure out how to make that work. The last thing I tried was putting the two random numbers together as a tuple, then checking whether that tuple was in a different list, and adding the tuple to that list (and moving forward with the clue) if it wasn't. However, even when I set it up so that the random numbers would be the same every time (set the parameters to 0,1 instead of 0,8), it still didn't read them as being duplicates.
What am I missing here? I understand that I'm very novice when it comes to python, but this really doesn't seem like it should be that hard.
a = renpy.random.randrange(0,8)
c = renpy.random.randrange(0,8)
texta = ExampleList[a]
textc = ExampleList[c]
if a < c:
"[texta] is ranked higher than [textc]"
...And so forth. I don't know if that's necessarily the best way to do it, but that's not what I'm concerned about right now. The problem is, when I run a loop of a bunch of those statements (say 20), I see more than a couple duplicates. So I was trying to figure out how to have it check for duplicates before it said the clue, but apparently I'm missing something here (I'm much more familiar with C# than ren'py), because I can't figure out how to make that work. The last thing I tried was putting the two random numbers together as a tuple, then checking whether that tuple was in a different list, and adding the tuple to that list (and moving forward with the clue) if it wasn't. However, even when I set it up so that the random numbers would be the same every time (set the parameters to 0,1 instead of 0,8), it still didn't read them as being duplicates.
What am I missing here? I understand that I'm very novice when it comes to python, but this really doesn't seem like it should be that hard.