I am creating my first card game, and need to shuffle the cards. So for starters, I have created a shuffle button for a sample stack of 4 values with the line:
int i = arc4random() % 4;
NSLog(@"%d", i);
Shuffling works well, but I want this button to allow the user to distribute random cards until there are no more cards in the stack. Each time I click this sample button, I need NSLoged
result to be something like 3, then 1, then 0, then 2, then "No more cards", for example (instead of a list of four random numbers and a message).
Is there a simple way to "distribute a number" randomly with each click of a button?
Also, does arc4random
generate real random numbers or pseudo-random numbers? I have read a lot of threads about it, and it doesn't seem so clear. What would be the best way to randomize numbers?