Rock Paper Scissors Solved

$24.99 $18.99

Problem Description You will be implementing the game of rock, paper, scissors. In this game, players randomly select rock, paper, or scissors. Rock beats scissors, paper beats rock, and scissors beats paper. If both players choose the same they choose again until someone wins. For your version, you will have a human player play against…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Problem Description

You will be implementing the game of rock, paper, scissors. In this game, players randomly select rock, paper, or scissors. Rock beats scissors, paper beats rock, and scissors beats paper. If both players choose the same they choose again until someone wins. For your version, you will have a human player play against the computer. In addition, when the game completes the player has the option to play another game.

Additional Details

Input

Command Line Arguments

  • The first command line argument is the seed to the random number generator

    • Optional

    • It will always be valid

    • It is an integer

Standard Input

  • WillNOTalways be valid

    • If invalid input is entered you should prompt the user again for input until valid input is entered

  • When asked for a move, valid input consists of any of the following with 0 or more whitespace characters before or after it. Capitalization does not matter.

    • Rock: r, (r)ock, or rock

    • Paper: p, (p)aper, or paper

    • Scissors: s, (s)cissors, or scissors

  • When asked if the player would like to play again, valid input consists of any of the following with 0 or more whitespace characters before or after it. Capitalization does not matter.

    • Yes: y, (y)es, or yes

    • No: n, (n)o, or no

Random Number Generator

  • Use the std::minstd_randrandom number generator

  • If a seed is provided use the seed to the random number generator

  • If a seed is not provided use time(nullptr), the current time, to seed the random number generator

  • To have the computer randomly select a move you should have the computer randomly generate a number between 0 and 2

    • 0 = Rock

    • 1 = Paper

    • 2 = Scissors

  • There should be code covered in class to make the choice of this random number fairly easily for you, so make sure to use that

  • Since different operating systems implement random number generators differently it is still possible that if you implement everything perfectly you will see different results on YOURcomputer compared to what the solutions are. If you submit and you’ve done things correctly it will pass the test cases.

    • This happens most often with people who are running their code on MACs.

      • I think people that are running Cygwin or Linux should have the same results as those on Kodethon but don’t quote me on this.

    • If you run your code on Kodethon and you’ve done things correctly your output will match mine. So if you think you’ve done everything correctly but your outputs are different than mine, run your code on Kodethon and see what you get.

Example

  • Input has been underlined so that you can differentiate between what is input and what is output

    • You do not have to underline anything

  • I’ve also provided an example executable named ExampleRockPaperScissors that you can run by doing./RockPaperScissors seedwhere seed is an integer

    • It is only guaranteed to run on Kodethon and may not run on your personal computer

Example 1

./RockPaperScissors 3

Enter (R)ock, P(aper), or (S)cissors for your move: bob

Enter (R)ock, P(aper), or (S)cissors for your move: rock man

Enter (R)ock, P(aper), or (S)cissors for your move: Rock The ai played rock.

You and the AI both played rock.

Keep playing until someone wins.

Enter (R)ock, P(aper), or (S)cissors for your move: p

The ai played rock.

You win!

Would you like to replay the game?

Enter (Y)es or (N)o: Y

Enter (R)ock, P(aper), or (S)cissors for your move: s(c)

Enter (R)ock, P(aper), or (S)cissors for your move: (s)cIssOrs The ai played scissors.

You and the AI both played scissors.

Keep playing until someone wins.

Enter (R)ock, P(aper), or (S)cissors for your move: p

The ai played scissors.

The AI wins 🙁

Would you like to replay the game?

Enter (Y)es or (N)o: n

Rock Paper Scissors Solved
$24.99 $18.99