<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: AS3 Array Shuffle</title>
	<atom:link href="http://flassari.is/2009/04/as3-array-shuffle/feed/" rel="self" type="application/rss+xml" />
	<link>http://flassari.is/2009/04/as3-array-shuffle/</link>
	<description></description>
	<lastBuildDate>Wed, 09 May 2012 13:29:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: Thales</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-1221</link>
		<dc:creator>Thales</dc:creator>
		<pubDate>Mon, 27 Feb 2012 15:25:13 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-1221</guid>
		<description>Trying an Array: a[1,2,3,4,5,6,7,8,9,10],
This function give us 5% chance of the first position stay with 1 and 20% of the last stay with 10.

function shuffle3(array_arr:Array):Array{
		   for(var i:Number = 0; i &lt; array_arr.length; i++){
			  var randomNum_num = Math.floor(Math.random() * array_arr.length);
			  var arrayIndex = array_arr[i];
			  array_arr[i] = array_arr[randomNum_num];
			  array_arr[randomNum_num] = arrayIndex;
		   }
		   return array_arr;
		}

this one have 10% for each position of that array.</description>
		<content:encoded><![CDATA[<p>Trying an Array: a[1,2,3,4,5,6,7,8,9,10],<br />
This function give us 5% chance of the first position stay with 1 and 20% of the last stay with 10.</p>
<p>function shuffle3(array_arr:Array):Array{<br />
		   for(var i:Number = 0; i &lt; array_arr.length; i++){<br />
			  var randomNum_num = Math.floor(Math.random() * array_arr.length);<br />
			  var arrayIndex = array_arr[i];<br />
			  array_arr[i] = array_arr[randomNum_num];<br />
			  array_arr[randomNum_num] = arrayIndex;<br />
		   }<br />
		   return array_arr;<br />
		}</p>
<p>this one have 10% for each position of that array.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aiux</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-545</link>
		<dc:creator>aiux</dc:creator>
		<pubDate>Mon, 17 Oct 2011 10:55:27 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-545</guid>
		<description>actually nothing is truly random in desktop computing :)</description>
		<content:encoded><![CDATA[<p>actually nothing is truly random in desktop computing :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andy</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-489</link>
		<dc:creator>andy</dc:creator>
		<pubDate>Wed, 05 Oct 2011 17:06:43 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-489</guid>
		<description>splicing is slow, but it also provides a truly random array... the quickest published way is biased toward keeping keeping earlier elements in the initial array earlier in the mixed array, here are my two utility randomizing methods:

public static function randomizeArray(array:Array):Array
		{
			//l=length arr=temp parameter array mixed=randomized array i=index
			var l:int = array.length,arr = array.slice(),mixed:Array = new Array(l),i:int;
			for (i = 0; i&lt;l; i++)
			{
				mixed[i] = arr.splice(int(Math.random() * (l - i)), 1)[0];
			}
			return mixed;
		}

		public static function randomizeArrayQuick(array:Array):Array
		{
			//This method is significantly faster, but not truly random
			//l=length mixed=randomized array r=random number i=index e=array element
			var l:Number = array.length,mixed:Array = array.slice(),r:Number,i:Number,e:Object;
			for (i = 0; i&lt;l; i++)
			{
				e = mixed[i];
				r = Math.floor(Math.random() * l);
				mixed[i] = mixed[r];
				mixed[r] = e;
			}
			return mixed;
		}</description>
		<content:encoded><![CDATA[<p>splicing is slow, but it also provides a truly random array&#8230; the quickest published way is biased toward keeping keeping earlier elements in the initial array earlier in the mixed array, here are my two utility randomizing methods:</p>
<p>public static function randomizeArray(array:Array):Array<br />
		{<br />
			//l=length arr=temp parameter array mixed=randomized array i=index<br />
			var l:int = array.length,arr = array.slice(),mixed:Array = new Array(l),i:int;<br />
			for (i = 0; i&lt;l; i++)<br />
			{<br />
				mixed[i] = arr.splice(int(Math.random() * (l - i)), 1)[0];<br />
			}<br />
			return mixed;<br />
		}</p>
<p>		public static function randomizeArrayQuick(array:Array):Array<br />
		{<br />
			//This method is significantly faster, but not truly random<br />
			//l=length mixed=randomized array r=random number i=index e=array element<br />
			var l:Number = array.length,mixed:Array = array.slice(),r:Number,i:Number,e:Object;<br />
			for (i = 0; i&lt;l; i++)<br />
			{<br />
				e = mixed[i];<br />
				r = Math.floor(Math.random() * l);<br />
				mixed[i] = mixed[r];<br />
				mixed[r] = e;<br />
			}<br />
			return mixed;<br />
		}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sid</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-374</link>
		<dc:creator>sid</dc:creator>
		<pubDate>Mon, 29 Aug 2011 05:33:10 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-374</guid>
		<description>perfect suffling</description>
		<content:encoded><![CDATA[<p>perfect suffling</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andreas</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-43</link>
		<dc:creator>andreas</dc:creator>
		<pubDate>Thu, 10 Feb 2011 14:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-43</guid>
		<description>thanks, comes in handy ... who cares fo 2 milliseconds ;)</description>
		<content:encoded><![CDATA[<p>thanks, comes in handy &#8230; who cares fo 2 milliseconds ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flassari</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-42</link>
		<dc:creator>Flassari</dc:creator>
		<pubDate>Fri, 14 May 2010 14:53:12 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-42</guid>
		<description>Thanks for that info MrSteel, good to have that reference here</description>
		<content:encoded><![CDATA[<p>Thanks for that info MrSteel, good to have that reference here</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MrSteel</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-41</link>
		<dc:creator>MrSteel</dc:creator>
		<pubDate>Fri, 14 May 2010 14:37:28 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-41</guid>
		<description>hi

nice way but it&#039;s not the fastest
take a look http://mrsteel.wordpress.com/2007/06/15/randomize-array-shuffle-an-array-in-flash/ 

shuffle by slice is one of slowest methods actually</description>
		<content:encoded><![CDATA[<p>hi</p>
<p>nice way but it&#8217;s not the fastest<br />
take a look <a href="http://mrsteel.wordpress.com/2007/06/15/randomize-array-shuffle-an-array-in-flash/" rel="nofollow">http://mrsteel.wordpress.com/2007/06/15/randomize-array-shuffle-an-array-in-flash/</a> </p>
<p>shuffle by slice is one of slowest methods actually</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chichilatte</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-40</link>
		<dc:creator>chichilatte</dc:creator>
		<pubDate>Mon, 29 Mar 2010 21:28:39 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-40</guid>
		<description>Ta buddee :)</description>
		<content:encoded><![CDATA[<p>Ta buddee :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: philtre</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-39</link>
		<dc:creator>philtre</dc:creator>
		<pubDate>Tue, 23 Mar 2010 14:29:07 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-39</guid>
		<description>It would probably be a tad faster like this:

var len:int = arr.length;
var arr2:Array = new Array(len);
for(var i:int = 0; i&lt;len; i++)
{
  arr2[i] = arr.splice(int(Math.random() * (len - i)), 1)[0];
}</description>
		<content:encoded><![CDATA[<p>It would probably be a tad faster like this:</p>
<p>var len:int = arr.length;<br />
var arr2:Array = new Array(len);<br />
for(var i:int = 0; i&lt;len; i++)<br />
{<br />
  arr2[i] = arr.splice(int(Math.random() * (len - i)), 1)[0];<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xxxxGame</title>
		<link>http://flassari.is/2009/04/as3-array-shuffle/#comment-38</link>
		<dc:creator>xxxxGame</dc:creator>
		<pubDate>Mon, 22 Mar 2010 02:00:14 +0000</pubDate>
		<guid isPermaLink="false">http://flassari.is/?p=89#comment-38</guid>
		<description>nice thank u!</description>
		<content:encoded><![CDATA[<p>nice thank u!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

