Here's a nice simple shuffling algorithm...
Code: ags
This scales pretty well.
#define RANGE 4
int rn[RANGE];
// fill rn sequentially
int i = 0;
// shuffle
while (i < RANGE) { rn[i] = i; i++}
i = 0;
while (i < RANGE*RANGE)
{
// swap two random elements
int p = random(RANGE-1);
int q = random(RANGE-1);
int s = rn[p];
rn[p] = rn[q];
rn[q] = s;
i++;
}
// deal off the top
i = 0;
int a = rn[i];
i++;
int b = rn[i];
i++;
int c = rn[i];
i++;
This scales pretty well.