Jump to content
  • Advertisement

Archived

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

Samurai_x

RPS game

This topic is 6007 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

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?

Share this post


Link to post
Share on other sites
Advertisement
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,

Share this post


Link to post
Share on other sites
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.

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!