Ok, basically, I have “10” profiles, and I want to set it up so each of them play someone once, but not they same person
(PROFILE BEING THE NAME)
EXAMPLE, tracing it would show
“profile 1 vs profile 5”
“profile 4 vs profile 9”
“profile 8 vs profile 6”
etc…
It cant say this (EXAMPLE)
“profile 1 vs profile 2”
“profile 2 vs profile 1”
“profile 1 vs profile 7”
“profile 7 vs profile 9”
see? that can’t happen, because, profile 1 can’t verse profile 2, AND profile 7
and profile 2, cant verse profile 1 twice…
profile 7 cant verse profile 1, and profile 9, it needs to do it for all
this is my current code:
function func_gen_round_robin()
{
var stotal:Number = 0;
var player_vs_who:Array = new Array();
var sequence:Array = new Array();
var tmp1:Number = 0;
var tmp2:Number = 0;
for (var i:Number = 0; i<profiles_amount; i++)
{
if (playerishere* == true) //checks that the profile is ok to check from
{
stotal++;
}
}
//trace("Stotal "+stotal);
if (stotal == 0)
{
errorbox.text = "No players are playing!";
}
var scurr:Number = stotal;
//trace("Scurr "+scurr);
for (var i:Number = 0; i<stotal; i++)
{
sequence* = i;
}
var n:Number = 0;
for (var z:Number = 0; z<stotal; z++)
{
if (player_amount % 2 == 0) //checks if its even
{
tmp1 = Math.floor(Math.random()*scurr);
//trace("Tmp 1 "+tmp1);
tmp2 = sequence[tmp1];
//trace("Tmp 2 "+tmp2);
player_vs_who[tmp2] = playername*;
//trace("Player "+player_vs_who[tmp2]);
sequence[tmp1] = sequence[scurr];
//trace("Sqe tmp1 "+sequence[tmp1]);
//trace("Sqe sccur "+sequence[scurr]);
sequence[scurr] = tmp2;
trace(tmp2);
scurr--;
if (scurr == 0)
{
scurr = stotal;
}
}
else
{
tmp1 = Math.floor(Math.random()*scurr);
trace(tmp1);
tmp2 = sequence[tmp1];
player_vs_who[tmp2] = playername*;
sequence[tmp1] = sequence[scurr];
sequence[scurr] = tmp2;
scurr--;
if (scurr == 0)
{
scurr = stotal;
}
//trace("Player "+player_vs_who[tmp2]);
}
}
for (var i:Number = 0; i<stotal; i++)
{
trace(player_vs_who[i+n] + " vs " + player_vs_who[(i+1)+n]);
n++;
}
}
is there anyway easier to do this?
Thanks in advanced