I am building a Rock Paper Scissors game and I am trying to implement a system where there will never be a tie. My current system is
if (userSelection == 0)
computerPick =[self computerGenerateResponce];
if (computerPick == 0)
while (computerPick == 0)
computerPick = [self computerGenerateResponce];
Is there a better way to implement this system? This works, but seems a little bit clunky.
At a minimum, you can eliminate the if(computerPick == 0) level, since that is the first thing that while(computerPick == 0) does. This will not affect your algorithm at all. Then, you can probably consolidate the call into the condition check, and further, you can just use implicit boolean casting:
This will essentially just keep assigning a new pick to computerPick until it is not zero.