A person to play rock-paper-scissors with a computer

Assignment Help Electrical Engineering
Reference no: EM13958052

Rock, Paper, Scissors
Description:
To expand further, we want to try out logic in interacting with users. Here is a sample of a game, using loops and decisions to allow a person to play rock-paper-scissors with a computer.
Pseudocode
We have a helper function that we will use here that tells us who won. It will result in +1 if the player wins, a -1 if the computer wins, and a 0 if it is a tie.
function compareOutcome(computerMove: Integer, 
playerChoice : Integer) returns Integer
And the main flow of our logic is as such.
while (true)
Integer : computerChoice = randomChooser()
Integer : playerEntry = prompt user to enter a value
If (playerEntry is not a valid input)
Prompt user they have picked a bad number and try again
Else
Integer : outcome = compareOutcome(computerMove, playerEntry)
If (outcome = 0)
Prompt user it is a tie, and try again
Else if (outcome = -1)
Prompt user they lost
Break out of loop
Else
Prompt user they won
Break out of loop
End if
End if
end loop
Flowchart


Note: In this case, note the advantages and disadvantages of flowcharts and pseudocode. The flowchart is easy to follow the logic for one scenario, but does it make it easier or harder to understand the code as a whole? There is no strict answer, but one that tells you a bit about your way of thinking and personal preference.
Interaction Scenario
For either of the solutions above, follow the logic and map out your interaction step-by-step, trying to exercise all paths of the logic. You will have to take at least 2 times through the game to map all scenarios.
Scenario 1
Step User Input System Response
1 User chooses 50 System says lower
2 ... ..


Scenario 2
Step User Input System Response





(copy and add more if needed/desired)
Number Guessing Game
Description
Now it is your turn to try out user interaction with a simple game. This goes back to the number guessing game. The user will input a number each time, say between 1 and 100. The computer will randomly select 1 number each game (note this is different than the example above where it selects a new answer each round), and the game continues until the user guesses the right number. 
Like above, your solution should accommodate for invalid input, but do not worry about how to make that logic work for now. Your solution should give some hints though if the guess the user made was too high or too low, to help them on their way.
Flowchart
<Your solution here>
Pseudocodeour solution here> 

Reference no: EM13958052

Questions Cloud

Calculate the residual income/eva of lakeside hospital : Calculate the residual income/EVA of Lakeside Hospital.
Relative merits of fixed and floating exchange rate regimes : Debate the relative merits of fixed and floating exchange rate regimes. From the perspective of an international business, what are the most important criteria in a choice between the systems? Which system is the more desirable for an international b..
Discuss the the customer is always right attitude : Discuss the “the customer is always right” attitude. As a customer, do you believe that you are always right and that companies should cater to what you want to have? As an employee, what do you do when you believe the customer is right, but the comp..
Find the speed of the stream : A two digit number is such that the product of its digits is 35. When 18 is added to the number, the digits interchange their places. Find the number.
A person to play rock-paper-scissors with a computer : To expand further, we want to try out logic in interacting with users. Here is a sample of a game, using loops and decisions to allow a person to play rock-paper-scissors with a computer.
Write down the strategies of the two players : How many twbgames are then: in this game (excluding the game itself)? b. Write down the strategies of the two players. c. Find all pure strategy subgame perfect Nash equilania.
What are the projected availabilities of each machine : A manager must decide between two machines. The manager will take into account each machine’s operating costs and initial costs, and its breakdown and repair times. Projected times for machine B are an average operating time of 54 hours and a repair ..
Evaluate the cost incurred by talbot partners compared : Evaluate the cost incurred by Talbot Partners compared to the benchmark cost.
Swot analysis part of the marketing plan for microbrewery : The swot analysis part of the marketing plan for a microbrewery would contain information of :

Reviews

Write a Review

Electrical Engineering Questions & Answers

  How many moles n have been introduced into the bag

The pressure of the gas within the bag remains at 1 atm and its temperature remains at room temperature 20.0 Celsius. How many moles 'n' have been introduced into the bag by the time its volume reaches 22.4 L

  Find what is the maximum power dissipated in the load

What is the maximum power dissipated in the load when the Thévenin voltage is 21 V cos(52 rad/s t + 82°), the Thévenin impedance is 102 -j 184 ohm and the load impedance is 102 + j 184 ohm

  Write down the principle of energy conversion

Write down the principle of energy conversion and give an example for single and double excited system.

  Average normal stress

Steel rods AB and BC each have a diameter of 5 mm. If the load of p= 2 kN is applied to the ring, and if ? = 60°, determine the following:

  Does edm affect the fatigue strength of cold worked metals

It is possible to infiltrate P/M parts with various resins as well as with metals. What possible applications can benefit from infiltration? Explain. Explain why the mechanical properties of workpiece materials are not significant in most of the p..

  Calculate the motors starting current

A 1000V, 50 hp compound motor runs at a speed of 750 rpm at full load. The armature, series and shunt field resistances are 0.5 ohm, 1 ohm, and 200 ohm, respectively. The motor efficiency at this condition is 80%. Calculate the motors starting cur..

  Find the exit velocity and the 2nd law efficiency

Steam enters an adiabatic nozzle at 3.5Mpa and 300C with a low velocity and leaves at 1.6Mpa and 250C at a rate of 0.4kg/s. If the surrounding is 10 at 100Kpa and 18C, find A) The exit velocity B)The 2Nd law efficiency

  Implement the sequence detector mealy state machine

Design a Mealy state machinethat is a *majority vote* detector that indicates when the majorityof the last three samples received are ones. When at least 2out of the last 3 inputs received are ones, it will output a1.

  In the circuit shown in figure a-4 the zener diode is

in the circuit shown in figure a-4 the zener diode is rated at 5.6 v and is operating in the zener region. if the

  What is the mole fraction of oxygen in the mixture

10.0-L ask contains 1.031 g O2 and 0.572 g CO2 at 18C. What are the partial pressures of oxygen and carbon dioxide. What is the total pressure. What is the mole fraction of oxygen in the mixture.

  Derive the voltage measured by the voltmeter

Derive the voltage measured by the voltmeter - Determine the minimum value of Rm required to ensure that the measurement error is smaller than 1 percent of vmi.

  Write function printbinary that displays the number of bits

Write a function printBinary() that displays the number of bits used VB2010. Using 'sizeof()' if the user enters and int 17 the function should display 000000000000000000000000000010001.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd