how do i make a random number not appear twice
i have a method where a variable makes a random number between 1 and 22 (i used the random fuction) and every time someone answers a question correct a random number is made (the numbers are connected to questions so that when a random number is chosen a random question is chosen) but sometimes (rarely) the random number will be the same as the number before, how to i make it so that a random number wont repeat?

Interesting question with a mathmatically simple explanation and a not so good way of stopping it. You see computers actually generate notsorandom numbers. This meaning the numbers generated are random to a certain extent. This is why they are called pseudorandom generators. Now there is really no concreate way to fix this as most random things aren't. The only way that might [I]help[/I] is to make an if statment to check to see if the number is equal to a previous number and if it is then make another number. However it is still possible that you will get the same number.
Does that make sense?:confused: 
you can create an array for the whole numbers, and to set empty each number that was taken.

[QUOTE=legolizard;40800]Interesting question with a mathmatically simple explanation and a not so good way of stopping it. You see computers actually generate notsorandom numbers. This meaning the numbers generated are random to a certain extent. This is why they are called pseudorandom generators. Now there is really no concreate way to fix this as most random things aren't. The only way that might [I]help[/I] is to make an if statment to check to see if the number is equal to a previous number and if it is then make another number. However it is still possible that you will get the same number.
Does that make sense?:confused:[/QUOTE] yeaa that makes perfect sense, but it would no take foreverrrr in m situation 
solution to the solution
[QUOTE=nickster654;40823]yeaa that makes perfect sense, but it would no take foreverrrr in m situation[/QUOTE]
if you take his solution and add in 24 variables that change when there question is used and when the ranomizer picks the activated variable it will redo the roll until it gets a non picked number. the 24th variable activates when the original 23 are used up and will stop the randomizing loops that would cause an error. Hope this helps. 
make 2 variables ([I]a, b[/I]).
set [I]a[/I] to random number set [I]a[/I] to [B]b[/B] do whatever with the variable you want set [I]a[/I] to random number if [I]a[/I] is equal to [I]b[/I] repeat if not continue 
All times are GMT 5. The time now is 04:14 AM. 
Copyright ©2021, Carnegie Mellon University
Alice 2.x © 19992012, Alice 3.x © 20082012, Carnegie Mellon University. All rights reserved.