Archived

This topic is now archived and is closed to further replies.

PsyCHo puNk

randomly assigning a enumerated domain to an array

Recommended Posts

PsyCHo puNk    122
Say I have the numbers 1 to 10, and an array with 10 elements. I want to assign the numbers each once to the array in a random order. Does anyone know a easy way to do this? I have tried nesting a while loop in a for loop but it was buggy. It is being used in a simple sliding tile puzzle game to load the image pieces randomly.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
oke i''m not an expert.... but,

I would like to be once on the news and,

something like this....

int temp;
boolean taken = true;

for (int i = 0; i < 10; i++)
{
while (taken)
temp = random();
for (int j = 0; j <= i; j++)
{
if (temp = array[j])
{
taken = true;
j = i+1;
}
else
taken = false;
}
array = temp;
}

something like that.... maybe it''s no good but it''s something you know.

So bye,

Booster,

dutchman

Share this post


Link to post
Share on other sites