Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Juan Pablo Califano
If that happens, it's a bug in the player. From the docs: "Returns a pseudo-random number n, where 0 <= n < 1. " So, the biggest number random returns can approximate 1, but should never be 1. What I got wrong in my original answer was that multiplying by 2 and then rounding introduces a bias to

Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Steven Sacks
In the exception that Math.random() returns 1, in which case you would get 2. I don't use Math.random(), though, I use the Parker-Miller PRNG. On 5/9/2010 5:01 PM, Juan Pablo Califano wrote: PS 2: I think the correct way to write the function that returns a number in the range -1 / 1 is: Mat

Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Juan Pablo Califano
PS 2: I think the correct way to write the function that returns a number in the range -1 / 1 is: Math.floor(Math.random * 3) - 1 In this case, you could indeed use int() instead of a static Math method, so I guess I was wrong about your function needing a Math.round call. 2010/5/9 Juan Pablo Ca

Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Steven Sacks
You're right. I was careless on two counts. Fisher-Yates it is. On 5/9/2010 4:36 PM, Juan Pablo Califano wrote: Steven, sorry to contradict you, but although your code is simple and sort of works, there a couple of problems with it. First, the sorting function is wrong. A sorting function is

Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Juan Pablo Califano
Steven, sorry to contradict you, but although your code is simple and sort of works, there a couple of problems with it. First, the sorting function is wrong. A sorting function is supposed to return -1,0 or 1. But it only returns -1 or 0. The problem is you are coercing the result to int. You sh

Re: [Flashcoders] Producing a random list with no repeats

2010-05-09 Thread Steven Sacks
Here's a very clean, fast and simple way to randomize an array. array.sort(randomizeFunction); function randomize(a:int, b:int):int { return int(Math.random() * 2) - 1; } If you're not happy with Math.random()'s randomness, there are plenty of other random number generators out there, such

[Flashcoders] Re: Re: Producing a random list with no repeats

2010-05-09 Thread Alan Neilsen
Thanks to all the suggestions re my random list problem. Particular thanks to Gerry Beauregard for this suggestion: "It's probably best just to create an Array or Vector containing numbers 1 to 40. (Vectors are only available in AS3, not sure about Array). Shuffle the array, then choose the f

Re: [Flashcoders] Apple developing flash-like alternative

2010-05-09 Thread Dave Watts
> Well, you have a point Paul.  But compare and contrast to Microsoft.   > Microsoft liked > the Flash client too, so they came up with their own.  They never went on an > insult > spree.  Apple apparently likes the Flash client too, but they did go on an > insult spree. > That's underhanded to m

RE: [Flashcoders] Apple developing flash-like alternative

2010-05-09 Thread Mendelsohn, Michael
Well, you have a point Paul. But compare and contrast to Microsoft. Microsoft liked the Flash client too, so they came up with their own. They never went on an insult spree. Apple apparently likes the Flash client too, but they did go on an insult spree. That's underhanded to me, and in my

Re: [Flashcoders] Apple developing flash-like alternative

2010-05-09 Thread Paul Andrews
On 09/05/2010 02:55, Mendelsohn, Michael wrote: I'd rather not go negative, especially on this list which is so valuable to me, but this Flash Alternative news simply disgusts me. It's as underhanded as a business can get. Why would any business reveal their intentions before they are re