Weird code Hiccup
I am using the following code in a project. It runs in two parts. The first randomizes the numbers 0-2.
The second part randomized the numbers 0-2 so that none of the numbers in the first set match the number in the second set. For example, if the first number in the first part is "1", then the second part will only return "0" or "2" in the first position.
The code works how I'd like it to work, except one out of maybe 15 times, the function skips the first part of the code and goes straight to the second part causing an overflow. Why does the code occasionally skip the first part?
var pi=3;
var t1:Array=[0,1,2];
var t2:Array=new Array();
var trasher:Array=new Array();
chooseThem()
function chooseThem():void
{for (var j:uint=0;j<3;j++)
{trace ("working");
var m=Math.floor(Math.random()*pi);
t1.push(t1
trasher.push(t1
t1.splice(m,1);
pi-=1};
for (var q:uint=0;t2.length<3;q++)
{var f=Math.floor(Math.random()*trasher.length);
trace (trasher.length+"trasher");
if (trasher
}
trace (t1);trace (t2+"t2")}