var runway:CollisionRunwayNode;
var l:int = 3 + int(Math.random() * 5);
var i:int;
while(l--)
{
runway = runways.head;
runways.swap(runway, runways.tail);
i = 2 + int(Math.random() * 2);
while(i--)
{
runway = runways.head;
runways.swap(runway, runway.next);
}
runway = runways.head;
runways.swap(runway, runways.tail);
}
while(!nodeList.empty)
{
// how about head / tail?
}
private function shuffleRunways():void
{
var node:Node = runways.head; // Get first node
while(node != null) /// finish shuffle if you hit end of the list
{
var switchnode:Node = node.next;
if(switchnode != null)
{
var rand:int = int(Math.random() * 6); // We shift this amount
for( var i:int = 0; i < rand; i++)
{
if(switchnode.next != null)
{
switchnode = switchnode.next;
}else
{
switchnode = runways.head; // Return back to head if you are at the end of the list
}
}
runways.swap(node, switchnode) // Make the switch
}
node = node.next;
}
}