Jump to content
  • Advertisement

Archived

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

PsyCHo puNk

randomly assigning a enumerated domain to an array

This topic is 6438 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!