RPS game
I''m trying to do a simple Rock Paper Scissors game but I cant get the computer to pick a number between 1-3.
1 rock
2 paper
3 scissors
can anyone help?
use rand() % 2 + 1
store the return value in a variable, then put statements like if value == 1 then rock, else if value == 2 then paper else scissors,
store the return value in a variable, then put statements like if value == 1 then rock, else if value == 2 then paper else scissors,
quote:Original post by mickey
use rand() % 2 + 1
store the return value in a variable, then put statements like if value == 1 then rock, else if value == 2 then paper else scissors,
That would be rand() % 3 + 1 ... and be warned that the low bits of rand() aren''t that random.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement