Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 4 [10 marks] Write a procedure to play the game Rock, Paper, Scissors. To begin the game the user should simply call the function

image text in transcribed
Question 4 [10 marks] Write a procedure to play the game Rock, Paper, Scissors. To begin the game the user should simply call the function (rps). The user should then be prompted with their score (initially zero) and a well-labelled input field. When the user chooses their option (rock paper or scissors), their answer will be compared to a randomly chosen computer option. Depending on the outcome, the user's score will go up, down, or stay the same in the next round. The code you write for this should be structured according to the below points procedure performs one round per iteration. * All helper functions for this code should be nested within the rps * The main game loop should be a tail-recursive procedure, that . A player's score should be displayed at the start of every round, including changes from the outcome of the previous round o Player wins: score 1 o Player loses: score 1 o Draw: score 0 Hint: the public (rps) method need not do any more than start the game loop with a score of zero You may require some additional features not discussed in lecture Randomn integers: Put (#%require random)) at the top of your file to import the random library from the racket base code. Use (random n) to pick a random integer from [O, n) . (only racket/base * User input: The (read) procedure evaluates to the value passed in by the user. For simplicity you may use the convention that Rock = 0, Paper-1, Scissors-2, and expect the user to input a value in that range. If you would like the user to enter the words rock/paper/scissors, take a look at the quote special form (not required for this assignment). Question 4 [10 marks] Write a procedure to play the game Rock, Paper, Scissors. To begin the game the user should simply call the function (rps). The user should then be prompted with their score (initially zero) and a well-labelled input field. When the user chooses their option (rock paper or scissors), their answer will be compared to a randomly chosen computer option. Depending on the outcome, the user's score will go up, down, or stay the same in the next round. The code you write for this should be structured according to the below points procedure performs one round per iteration. * All helper functions for this code should be nested within the rps * The main game loop should be a tail-recursive procedure, that . A player's score should be displayed at the start of every round, including changes from the outcome of the previous round o Player wins: score 1 o Player loses: score 1 o Draw: score 0 Hint: the public (rps) method need not do any more than start the game loop with a score of zero You may require some additional features not discussed in lecture Randomn integers: Put (#%require random)) at the top of your file to import the random library from the racket base code. Use (random n) to pick a random integer from [O, n) . (only racket/base * User input: The (read) procedure evaluates to the value passed in by the user. For simplicity you may use the convention that Rock = 0, Paper-1, Scissors-2, and expect the user to input a value in that range. If you would like the user to enter the words rock/paper/scissors, take a look at the quote special form (not required for this assignment)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What forms of control are evident at the Buffalo call centre?

Answered: 1 week ago

Question

Explain the strength of acid and alkali solutions with examples

Answered: 1 week ago

Question

Introduce and define metals and nonmetals and explain with examples

Answered: 1 week ago