The Rock-Scissors-Paper Game, v.1.0 Purpose. Bring together all you've learned so far, about values, variables, sequential processing, code blocks, ifs and loops. The game is played between the computer and a human player.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
The Rock-Scissors-Paper
Game, v.1.0
Purpose. Bring together all you've learned so far, about values, variables, sequential processing,
code blocks, ifs and loops. The game is played between the computer and a human player.
Requirements. Write a computer game based on rock-paper-scissors. (for reference:
www.worldrps.com.) Name the source file rcp1.cpp. 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.
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 functions in future studies.
The game will replay until the human player decides to quit. Human input will be through the
keyboard, entering R or r for rock, P or p for paper, S or s for scissors, or Q or q to quit. Computer
input will be randomly generated.
Add score keeping to the game to track the numbers of computer wins and human wins -- do not
count ties. Output the numbers of computer wins and human wins after all play ends.
Supplemental. Read about "randomizing" in www.rdb3.com/cpp/exercises/Gaming.supplemental.pdf.
Algorithm.
// initialize the computer's random number generator
// declare variables to track numbers of human and computer wins
// start loop
// determine computer's choice
// prompt for, and read, the human's choice.
// if human wants to quit, break out of loop
// determine the winner
// end loop
// print numbers of human wins and computer wins
Example. Here is sample output for the game, with the input prompt in blue, the human response in
red, and the results in green: Do not color code your I/O!
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]: q
Computer wins: 1
Human wins: 0
Transcribed Image Text:The Rock-Scissors-Paper Game, v.1.0 Purpose. Bring together all you've learned so far, about values, variables, sequential processing, code blocks, ifs and loops. The game is played between the computer and a human player. Requirements. Write a computer game based on rock-paper-scissors. (for reference: www.worldrps.com.) Name the source file rcp1.cpp. 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. 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 functions in future studies. The game will replay until the human player decides to quit. Human input will be through the keyboard, entering R or r for rock, P or p for paper, S or s for scissors, or Q or q to quit. Computer input will be randomly generated. Add score keeping to the game to track the numbers of computer wins and human wins -- do not count ties. Output the numbers of computer wins and human wins after all play ends. Supplemental. Read about "randomizing" in www.rdb3.com/cpp/exercises/Gaming.supplemental.pdf. Algorithm. // initialize the computer's random number generator // declare variables to track numbers of human and computer wins // start loop // determine computer's choice // prompt for, and read, the human's choice. // if human wants to quit, break out of loop // determine the winner // end loop // print numbers of human wins and computer wins Example. Here is sample output for the game, with the input prompt in blue, the human response in red, and the results in green: Do not color code your I/O! 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]: q Computer wins: 1 Human wins: 0
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The code doesn't work properly. for the first two inputs it computer always choose Rock. Also as soon as one user (either computer or human) win two rounds it should output the result. The code should be written wothout using arrays.

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

The prgram should be written without using arrays. how to write it wihtout using arrays?

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education