# Making a sequence that never repeats

**URL:** <https://forum.kirupa.com/t/making-a-sequence-that-never-repeats/219274>\
**Category:** flash\
**Created:** [March 15, 2007, 10:13am UTC](https://forum.kirupa.com/t/making-a-sequence-that-never-repeats/219274 "2007-03-15T10:13:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mythic\_Fr0st](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@Mythic\_Fr0st](https://forum.kirupa.com/u/Mythic_Fr0st)\
**Post date:** [March 15, 2007, 10:13am UTC](https://forum.kirupa.com/t/making-a-sequence-that-never-repeats/219274/1 "2007-03-15T10:13:42Z")

</div>

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:

```auto
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
