Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Randomising Arrays

Status
Not open for further replies.

JontyMC

Programmer
Nov 26, 2001
1,276
GB
I'm making a card game and I dont want the same card to be dealt in any one hand. I tried this function but it doesnt seem to work:

function pickcard () {
x = random (52);
if (cardpicked [x] == false) {
cardpicked [x] = true;
return (x);
}
else {
pickcard ();
}
}

Is there a way to randomise a whole array, so i could have an array with 52 elements that is randomised?

Thanks,

Jon
 
Wang? Regards,

new.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top