That's a good idea! Ron Wheeler a écrit :
If you do not care if the sequences repeat, you could fill an array with the numbers from 1 to 100 arranged in a random order.When you want to grab 10, just pick a random integer between 0 and 89 and grab the block of 10 numbers following that point. This would charge a penalty once when you loaded the 100 but your refresh of the 10 would be very fast.You could have a counter on the array of 100 and every so often (after 10-50 blocks of 10 used) regenerate the sequence of 100 if you want to avoid repeating the same sequence.Ron laurent wrote:yes like: allNumbers:Array = [ 0, 1, 2, 3, ..., 100 ]; tenNumbers:Array = []; public function getNumberIn():void{ var n:int = tenNumbers.splice( int( Math.random * 10 ), 1 );tenNumbers.push( allNumbers.splice( int( Math.random * allNumbers.length ), 1 ) );allNumbers.push( n ); } Could be like that. ;) LEduardo Barbosa a écrit :Hi Laurent,Your first suggestion is a very simple and clever trick i'll definetely keepin mind for future situations. However for this second variation you mean that I: 1) pick the numbers out of array 1 and splice it 2) move those numbers into array 23) when the length of array 1 would be 10 i would start picking the numbersout of array 2 and do the inverse. Is this what you mean?On Mon, Jul 28, 2008 at 11:01 PM, laurent <[EMAIL PROTECTED]> wrote:still it can be done like that you always keep the number of numbers between two arrays...and swap numbers from one to another, that your sure to neve have twice thesame one yeah...! :] L Eduardo Barbosa a écrit :Hi all! What I am trying to figure out is this:How to generate a sequence of random numbers where the newest is alwaysdifferent from all the previous?I need to continuosly rewrite an array of 10 random numbers in such a waythat at any given time they are all different. Let's say that my range is 0 to 100 it starts with random numbers, all different: {3, 34, 12, 69, 6, 44, 31, 90, 88, 23}at a set interval some values are replaced by new ones so there are nevertwo equal numbers, so, after 2 seconds it may look like this: {3, 66, 12, 79, 6, 44, 10, 81, 88, 23} Any ideas? Thanks :) Eduardo _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders __________ Information from ESET NOD32 Antivirus, version of virus signature database 3257 (20080710) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders__________ Information from ESET NOD32 Antivirus, version of virus signature database 3257 (20080710) __________The message was checked by ESET NOD32 Antivirus. http://www.eset.com_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders__________ Information from ESET NOD32 Antivirus, version of virus signature database 3257 (20080710) __________The message was checked by ESET NOD32 Antivirus. http://www.eset.com_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders__________ Information from ESET NOD32 Antivirus, version of virus signature database 3257 (20080710) __________The message was checked by ESET NOD32 Antivirus. http://www.eset.com
_______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders