Re: [Flashcoders] Random numbers list

2008-07-29 Thread Ron Wheeler
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. ;)
L



Eduardo Barbosa a écrit :

Hi Laurent,

Your first suggestion is a very simple and clever trick i'll 
definetely keep

in 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 2
3) when the length of array 1 would be 10 i would start picking the 
numbers

out 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 the

same 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 
always

different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in 
such a way

that 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 never

two 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


RE: [Flashcoders] Random numbers list

2008-07-29 Thread Keith Reinfeld

 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. ;)

Make a temporary copy of the allnumbers array then splice from the copy.

AS2: 
code

var allNumbers:Array = [0, 1, 2, 3, ..., 100];
var tenNumbers:Array = [38, 10, 70, 30, 63, 20, 66, 37, 16, 87];
function getNumberIn():Void{
var ca:Array = [].concat(allNumbers);
var n:Number = 10;
while(n--){
tenNumbers[n] = ca.splice(Math.floor(Math.random() *
ca.length - 1), 1);
}
trace(\ntenNumbers = +tenNumbers);
}

/code

Regards, 

-Keith 
http://keithreinfeld.home.comcast.net
 



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Random numbers list

2008-07-29 Thread Helmut Granda
No, that is not the only way you can target a path in the MAC. for example I
different projects some require to distribute the PPV classes with the
project so i add the classes inside the same folder I am working on.
/Application.as
/src/
/src/ppvclasses

Then in my application I just do:

import org.papervision3d.cameras.FreeCamera3D

But if I am just testing it doesnt matter where the classes are as long as I
target the class path properly.

If you are still having issues I would recommend to read the following
document:

http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004file=1075.html


On Tue, Jul 29, 2008 at 9:21 AM, Ron Wheeler [EMAIL PROTECTED]
 wrote:

 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. ;)
 L



 Eduardo Barbosa a écrit :

 Hi Laurent,

 Your first suggestion is a very simple and clever trick i'll definetely
 keep
 in 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 2
 3) when the length of array 1 would be 10 i would start picking the
 numbers
 out 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
 the
 same 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
 always
 different from all the previous?

 I need to continuosly rewrite an array of 10 random numbers in such a
 way
 that 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
 never
 two 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




-- 
...helmut
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Random numbers list

2008-07-29 Thread Helmut Granda
wrong thread... oh my and its only tuesday!

On Tue, Jul 29, 2008 at 9:57 AM, Helmut Granda [EMAIL PROTECTED]wrote:

 No, that is not the only way you can target a path in the MAC. for example
 I different projects some require to distribute the PPV classes with the
 project so i add the classes inside the same folder I am working on.
 /Application.as
 /src/
 /src/ppvclasses

 Then in my application I just do:

 import org.papervision3d.cameras.FreeCamera3D

 But if I am just testing it doesnt matter where the classes are as long as
 I target the class path properly.

 If you are still having issues I would recommend to read the following
 document:


 http://livedocs.adobe.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004file=1075.html


 On Tue, Jul 29, 2008 at 9:21 AM, Ron Wheeler 
 [EMAIL PROTECTED] wrote:

 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. ;)
 L



 Eduardo Barbosa a écrit :

 Hi Laurent,

 Your first suggestion is a very simple and clever trick i'll definetely
 keep
 in 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 2
 3) when the length of array 1 would be 10 i would start picking the
 numbers
 out 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 the
 same 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
 always
 different from all the previous?

 I need to continuosly rewrite an array of 10 random numbers in such a
 way
 that 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
 never
 two 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




 --
 ...helmut




-- 
...helmut
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Random numbers list

2008-07-29 Thread laurent

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. ;)
L



Eduardo Barbosa a écrit :

Hi Laurent,

Your first suggestion is a very simple and clever trick i'll 
definetely keep

in 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 2
3) when the length of array 1 would be 10 i would start picking the 
numbers

out 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 the

same 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 
always

different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in 
such a way

that 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 never

two 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


RE: [Flashcoders] Random numbers list

2008-07-29 Thread Jesse Graupmann
I'm sure this isn't needed by now, just thought I'd take it as a fun
challenge.
 

var rangeMin:int = 0;
var rangeMax:int = 100;
var rangeSample:int = 10;


// copy
var numbers:Array = [];

// original values
var numberList:Array = [];
for ( var i:int = 0; i = (rangeMax - rangeMin); i++ ) numberList[ i ] =
rangeMin + i;


function getRandomArray( len:int ):Array 
{
// reset copy when needed
if ( numbers.length  len ) numbers = [].concat(numberList); 

// transfer random values to new array
var array:Array = [];
for ( var i:int = 0; i  len; i++ ) array [ i ] = numbers.splice(
int( Math.random() * numbers.length), 1 );

return array;
}



for ( i = 0; i  20; i++ ) trace(  i + :  + getRandomArray( rangeSample )
);




 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 
 always
 different from all the previous?

 I need to continuosly rewrite an array of 10 random numbers in 
 such a way
 that 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 never
 two 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


Re: [Flashcoders] Random numbers list

2008-07-29 Thread Juan Pablo Califano
This is very similar to what other people have already said. Basically, you
can have two lists: one acts as a pool from where you'll grab numbers,
randomly; the other one is a sequence of unique numbers.

First, you fill the pool with numbers that fall between some range. Then you
take one of the numbers in the pool and put it in the sequence list, untill
you've filled it up.

To refresh the sequence, just pick a random index from it, replace the
value pointed by that index with a random value taken from the pool and put
the value extracted from the sequence back into the pool.

In code:

import flash.utils.Timer;
import flash.events.TimerEvent;

var uniqueSequence:Array = [];
var numbersPool:Array = [];

var maxRange:int = 100;
var minRange:int = 0;

var sequenceSize:int = 10;

function init():void {
 var i:int = minRange;
 while(imaxRange) {
  numbersPool.push(i);
  i++;
 }

 i = 0;
 while(isequenceSize) {
  uniqueSequence.push(getFromPool());
  i++;
 }
}

function getFromPool():int {
 var idx:int = Math.round((numbersPool.length - 1 )* Math.random());
 return numbersPool.splice(idx,1)[0];
}

function refresh():void {
 var seqIdx:int = Math.round((sequenceSize - 1 )* Math.random());
 var tmp:int = uniqueSequence[seqIdx];
 uniqueSequence[seqIdx] = getFromPool();
 numbersPool.push(tmp);
 trace(uniqueSequence);
}

function handleTimer(evt:TimerEvent):void {
 refresh();
}

init();

var timer:Timer = new Timer(250,5);
timer.addEventListener(TimerEvent.TIMER, handleTimer);
timer.start();


Cheers
Juan Pablo Califano


2008/7/29, Jesse Graupmann [EMAIL PROTECTED]:

 I'm sure this isn't needed by now, just thought I'd take it as a fun
 challenge.


 var rangeMin:int = 0;
 var rangeMax:int = 100;
 var rangeSample:int = 10;


 // copy
 var numbers:Array = [];

 // original values
 var numberList:Array = [];
 for ( var i:int = 0; i = (rangeMax - rangeMin); i++ ) numberList[ i ] =
 rangeMin + i;


 function getRandomArray( len:int ):Array
 {
// reset copy when needed
if ( numbers.length  len ) numbers = [].concat(numberList);

// transfer random values to new array
var array:Array = [];
for ( var i:int = 0; i  len; i++ ) array [ i ] = numbers.splice(
 int( Math.random() * numbers.length), 1 );

return array;
 }



 for ( i = 0; i  20; i++ ) trace(  i + :  + getRandomArray( rangeSample )
 );



 
  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
  always
  different from all the previous?
 
  I need to continuosly rewrite an array of 10 random numbers in
  such a way
  that 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 never
  two 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

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Random numbers list

2008-07-28 Thread Eduardo Barbosa
Hi all!

What I am trying to figure out is this:

How to generate a sequence of random numbers where the newest is always
different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in such a way
that 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 never
two 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


Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
you could make a first array filled with all number from 0 to 100 and 
then you splice to any random index range between 0 and the new size of 
the array.

You fill another array with the last spliced number. do I make sense ?
cheers
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 always
different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in such a way
that 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 never
two 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


Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent

oops no i did not get you point actually..
hm...more complex...:)
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 always
different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in such a way
that 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 never
two 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


Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
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 
the same 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 always
different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in such a way
that 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 never
two 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


RE: [Flashcoders] Random numbers list

2008-07-28 Thread Steve Abaffy
Every time you generate a new random number go through the array and see if
any match the new number if so generate a new one and check again, if not
add it to the array.
With only 10 numbers in the array it would check very fast so you wouldn't
be taking a performance hit. 


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Eduardo
Barbosa
Sent: Monday, July 28, 2008 4:43 PM
To: Flashcoders mailing list
Subject: [Flashcoders] Random numbers list

Hi all!

What I am trying to figure out is this:

How to generate a sequence of random numbers where the newest is always
different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in such a way
that 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 never
two 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



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Random numbers list

2008-07-28 Thread Matt S.
Can numbers repeat? Is this a constant loop where, for instance, the
number 12 could show up two times in twenty seconds? Or would you want
12 to show up once and then go out of circulation permanently?

.m

On Mon, Jul 28, 2008 at 5:42 PM, Eduardo Barbosa [EMAIL PROTECTED] wrote:
 Hi all!

 What I am trying to figure out is this:

 How to generate a sequence of random numbers where the newest is always
 different from all the previous?

 I need to continuosly rewrite an array of 10 random numbers in such a way
 that 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 never
 two 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

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Random numbers list

2008-07-28 Thread Eduardo Barbosa
Hi Matt,

Yes numbers can and should repeat through time. They just cant be repeated
within the sequence at a given discreet time. Makes sense? :)

On Mon, Jul 28, 2008 at 11:15 PM, Matt S. [EMAIL PROTECTED] wrote:

 Can numbers repeat? Is this a constant loop where, for instance, the
 number 12 could show up two times in twenty seconds? Or would you want
 12 to show up once and then go out of circulation permanently?

 .m

 On Mon, Jul 28, 2008 at 5:42 PM, Eduardo Barbosa [EMAIL PROTECTED]
 wrote:
  Hi all!
 
  What I am trying to figure out is this:
 
  How to generate a sequence of random numbers where the newest is always
  different from all the previous?
 
  I need to continuosly rewrite an array of 10 random numbers in such a way
  that 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 never
  two 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
 
 ___
 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


Re: [Flashcoders] Random numbers list

2008-07-28 Thread Eduardo Barbosa
Hi Laurent,

Your first suggestion is a very simple and clever trick i'll definetely keep
in 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 2
3) when the length of array 1 would be 10 i would start picking the numbers
out 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 the
 same 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 always
 different from all the previous?

 I need to continuosly rewrite an array of 10 random numbers in such a way
 that 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 never
 two 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


Re: [Flashcoders] Random numbers list

2008-07-28 Thread Eduardo Barbosa
Hi Steve,

That was actually my first thought. I had a while loop and inside a for ...
in loop to iterate through the array to check if the number was already
there. But then for some reason the script made flash unresponsive.

However  I just came up with this which seems to be working, but i'm still
very curious to learn of better ways of achieving this:

function pickUniqueNumber():Number {

var randomNum:Number;
var loop:Boolean = true;

var numberList:String = |+currentNumbers.join(|)+|;

while (loop) {

randomNum = random(wallpaperList.length);

var numberString:String = |+randomNum+|;

if (numberList.indexOf(numberString) == -1) {
currentNumbers.push(randomNum);
loop = false;
}
}
return randomNum;
}

On Mon, Jul 28, 2008 at 11:04 PM, Steve Abaffy [EMAIL PROTECTED]wrote:

 Every time you generate a new random number go through the array and see if
 any match the new number if so generate a new one and check again, if not
 add it to the array.
 With only 10 numbers in the array it would check very fast so you wouldn't
 be taking a performance hit.


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Eduardo
 Barbosa
 Sent: Monday, July 28, 2008 4:43 PM
 To: Flashcoders mailing list
 Subject: [Flashcoders] Random numbers list

 Hi all!

 What I am trying to figure out is this:

 How to generate a sequence of random numbers where the newest is always
 different from all the previous?

 I need to continuosly rewrite an array of 10 random numbers in such a way
 that 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 never
 two 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



 ___
 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


Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent


yes like:

allNumber:Array = [ 0, 1, 2, 3, ..., 100 ];
tenNumbers:Array = [];


public function getNumberIn():void{
   var i:in = int( Math.random * allNumber.length );
  tenNumbers.push( allNumber.splice( i, 1 ) );
}

then I don't know how you pick up the number to pass from tenNumbers to 
allNumber.


L

Eduardo Barbosa a écrit :

Hi Laurent,

Your first suggestion is a very simple and clever trick i'll definetely keep
in 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 2
3) when the length of array 1 would be 10 i would start picking the numbers
out 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 the
same 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 always
different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in such a way
that 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 never
two 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


Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent
or perhaps tenNumber[ tenNumbers.length ] is faster than 
tenNumbers.push() never know about that one...the second return 
something so perhaps its slower..


laurent a écrit :


yes like:

allNumber:Array = [ 0, 1, 2, 3, ..., 100 ];
tenNumbers:Array = [];


public function getNumberIn():void{
   var i:in = int( Math.random * allNumber.length );
  tenNumbers.push( allNumber.splice( i, 1 ) );
}

then I don't know how you pick up the number to pass from tenNumbers 
to allNumber.


L

Eduardo Barbosa a écrit :

Hi Laurent,

Your first suggestion is a very simple and clever trick i'll 
definetely keep

in 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 2
3) when the length of array 1 would be 10 i would start picking the 
numbers

out 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 the

same 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 
always

different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in such 
a way

that 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 
never

two 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


Re: [Flashcoders] Random numbers list

2008-07-28 Thread laurent


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. ;)
L



Eduardo Barbosa a écrit :

Hi Laurent,

Your first suggestion is a very simple and clever trick i'll 
definetely keep

in 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 2
3) when the length of array 1 would be 10 i would start picking the 
numbers

out 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 the

same 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 
always

different from all the previous?

I need to continuosly rewrite an array of 10 random numbers in such 
a way

that 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 
never

two 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