mercredi 18 novembre 2015

How can I create a random event that will not repeat results?

I am trying to make a team generating application using Xcode and C++ that will generate either teams of three or teams of four. Currently, I am able to input names and randomly generate the teams using arrays:

    for (j=1;j < count; j++) {

    int index=rand() % count;


    NSString *temp = Array[j];
    Array[j]=Array[index];
    Array[index]=temp;

From this array, I am assigning teams of three based on the order of the array. So Array [1], [2], and [3] make up team #1. Array [4], [5], and [6] make up team #2, and so fourth.

From here, I would like to randomly generate new teams using the same name pool as before, but not having people put in teams with people that they were already in a team with.

For example, if person #1, #2, and #3 were all placed in the same team, the next time I generate teams, person #1, #2, and #3 would all be on separate teams.

This is my main focus for now. Eventually, I would like to be able to make the program adjust to allow for repeat team members as non-repeat team members becomes impossible on later team generations.




Aucun commentaire:

Enregistrer un commentaire