Write a computer game based on rock-paper- scissors in C++. The
2-player game will be interactive: human vs. computer!
Making the game interactive presents a new issue for us -- how do
we get the computer's choice?
To solve this, we will use a "random number
generator", which is the basis for all computer
gaming.
This enables the properly programmed computer to act like it is
actually "thinking" and making its
own decisions.
This is the largest, most involved program we have yet written. It
will require careful step-by- step
development. You will be lead through this one in a series of
steps, in an effort to train you in the
software development process.
In the coding for this game you will use code blocks, loops, and if
and/or switch structures.
Organizing code into "code blocks" will prepare
you for moving code blocks into subprograms in
coming labs.
The game will replay until the human player decides to quit. Human
input will be through the
keyboard, entering R for rock, P for paper, S for scissors, or Q to
quit. Computer input will be
randomly generated. Here is sample output for the game, with the
input prompt in blue, the human
response in red, and the results in green:
Choose: [Rock,Paper,Scissors,Quit]: p
Computer:S, Human:P, Computer wins
Choose: [Rock,Paper,Scissors,Quit]: p
Computer:P, Human:P, tie
Choose: [Rock,Paper,Scissors,Quit]: p
Computer:R, Human:P, Human wins
Choose: [Rock,Paper,Scissors,Quit]: p
Computer:S, Human:P, Computer wins
Choose: [Rock,Paper,Scissors,Quit]: x
Choose: [Rock,Paper,Scissors,Quit]: p
Computer:S, Human:P, Computer wins
Choose: [Rock,Paper,Scissors,Quit]: q
Do not color code your I/O!
Use only techniques taught in this class. Do NOT use regular
expressions. Do NOT use arrays. Do
NOT use subprograms. Do NOT use pointers. These are great
programming tools, but we have not
covered them.
#include<iostream>
#include<time.h> //needed for seeding rand
#include<stdlib.h>//contains srand,rand()
using namespace std;
int main()
{ int choice;
srand (time(NULL)); //initialze random seed
int comp=rand()%3+1;//generates a random no. between 1,2 & 3
and assigns it to Computer
char player='a'; //storing choice of player
while(player!='q'&&player!='Q')
{
cout<<"Choose: [Rock,Paper,Scissors,Quit]:";
cin>>player;
if(player=='r' || player=='R') //converting player move to
equivalent number
{ //rock=1,paper=2,scissors=3
choice=1;
cout<<" Human:R, ";
}
else if(player=='p'||player=='P')
{
choice=2;
cout<<" Human:P ";
}
else if(player=='s'||player=='S')
{
choice=3;
cout<<" Human:S ";
}
else
continue;
//finding result
if(comp==1)
cout<<"Computer:R,";
if(comp==2)
cout<<"Computer:P,";
if(comp==3)
cout<<"Computer:S,";
if(choice==4)
if(comp==1&&choice==3)
cout<<"Computer wins\n";
if(comp==1&choice==2)
cout<<"Human wins\n";
if(comp==2&&choice==1)
cout<<"Computer wins\n";
if(comp==2&&choice==3)
cout<<"Human wins\n";
if(comp==3&&choice==1)
cout<<"Human win\n";
if(comp==3&&choice==2)
cout<<"Computer wins\n";
if(comp==choice)
cout<<"tie\n";
}
return 0;
}

Write a computer game based on rock-paper- scissors in C++. The 2-player game will be interactive:...
This program should be in c++. Rock Paper Scissors: This game is played by children and adults and is popular all over the world. Apart from being a game played to pass time, the game is usually played in situations where something has to be chosen. It is similar in that way to other games like flipping the coin, throwing dice or drawing straws. There is no room for cheating or for knowing what the other person is going to...
C++ Write a program that plays the rock, paper, scissors game. Rock beats scissors; scissors beats paper; paper beats rock. You must use these specific functions in your program. These are the prototypes: char generateP2toss(); int checkThrow(char, char); void printStatistics(int, int, int, int); void finalStatistics(int, int, int, int); void welcome(); Notes on these functions: generateP2toss() will generate the computer's toss (the computer is player2). It returns either an "r", "p", or "s/" checkThrow(char char) will check the throw by passing...
JAVA Beginnings of a paper-rock-scissors game. Paper-rock-scissors is a game often used to make decisions. There are two players. Each player secretly chooses either, paper, rock or scissors. At the count of three, each player reveals what they have chosen. The winner of the game is determined this way: paper beats rock (because paper covers rock) rock beats scissors (because rock crushes scissors) scissors beat paper (because scissors cut paper) If the two players choose the same item, it is...
Rock, Paper, Scissors - Write a MATLAB script file to play Rock, Paper, Scissors with the computer. x=rand; if x< 1/3 then it is Rock, if l/3<= x < 2/3 it is Paper else it is Scissors end if This is how the game should look like on the screen: Enter "r" for Rock, "p" for Paper, or "s" for Scissors", or enter "q" to Quit the game r leftarrow say, this is what you entered Computer choice: Scissors RESULT:...
Create a python program to play rock paper scissors using a while loop and if statements. I have started but have gotten stuck in a continuous loop. Please look over my code and help me find where I went wrong. Here it is: import random #Choice weapons=['Rock' ,'Paper' ,'Scissors'] print('Rock, Paper, Scissors!') print('Rock, Paper, Scissors!') print('Shoot!') human=input('Choose Rock, Paper, Scissors, or Quit! ') print('')#Blank Line while human != 'Quit': human_choice=human computer=random.choice(weapons) print(computer) if human==computer: print("It's a tie!") elif human=='Rock': if...
Objective: Write a program that simulates a game of rock, paper, scissors between a human and the computer in best 2 out of 3 rounds. Requirements: . The player can enter either "rock", "paper", or "scissors'". o If the player enters anything other than that the computer automatically gets a point . The computer randomly selects one of the gestures o Use the Random type to make this easier o Also make sure you import java.util.Random o You can use...
I need the create a Python code that makes a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game) Please help me see why my "continue" is asking the players to start a new game. Here is my code; user1= input("Whats your name? ") user2= input("And your name? ") a = input("%s, do yo want to choose...
Python Language: Please see program listed below of a game called: Rock, Paper, Scissors. Please add an exception, for example if the user inputs something else other than rock, paper or scissors, the exception will print message: "Enter only rock, paper, or scissors". Also add option to keep playing the game, for example: print: "Would you like to play again? Enter Y or N". If the user says Y, the game will repeat, if N, the game will end and...
java pls
Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that is often used to pass time (or sometimes to make decisions.) The rules of the game are outlined below: • • Scissors cuts Paper Paper covers Rock Rock crushes Lizard Lizard poisons Spock Spock smashes Scissors Scissors decapitates Lizard Lizard eats Paper Paper disproves Spock Spock vaporizes Rock Rock crushes Scissors Write a program that simulates the...
IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....