Create the logic for the dice game pig

Assignment Help Basic Computer Science
Reference no: EM131096438

In Chapter 3, one of the exercises explained that in many programming languages you can generate a random number between 1 and a limiting value named LIMIT by using a statement
similar to random Number = random(LIMIT). Create the logic for the dice game Pig in which a player can compete with the computer. Th e object of the game is to be the first to score 100 points. Th e user and computer take turns rolling a pair of dice, the values of which are determined randomly.

Th e game follows these rules:

• On a turn, each player "rolls" two dice. If no 1 appears, the dice values are added to a running total, and the player can choose whether to roll again or pass the turn to the other player.

• If a 1 appears on one of the dice, nothing more is added to the player's total and it becomes the other player's turn.

• If a 1 appears on both of the dice, not only is the player's turn over, but the player's entire accumulated score is reset to 0.

• In this version of the game, when the computer does not roll a 1 and can choose whether to roll again, generate a new random value of 1 or 2. Use this value to decide whether the computer will continue to play or to pass the turn to the player.

Reference no: EM131096438

Questions Cloud

Describe what happens to the training error : 10-701 Machine Learning - Spring 2012 - Problem Set 1. In K-nearest neighbors (KNN), the classification is achieved by majority vote in the vicinity of data. Describe what happens to the training error (using all available data) when the neighbor siz..
How does neoliberalism differ from liberalism in ir : How does neoliberalism differ from liberalism in IR? Define reciprocity and EXPLAIN how it promotes cooperation. How can reciprocity result in more conflict? Explain. Define international regimes. How do they facilitate cooperation?
What is the role of reason in relation to a good will : Why are talents, gifts of fortune and happiness not good in themselves? How do Kant's views compare to Aristotle's? What is the role of reason in relation to a good will?
What are the main assumptions of realism : What are the main assumptions of realism? Identify two of the thinkers that have contributed to realism and describe their contribution. [multiple answers]. What is the most common definition of power? What are its flaws?
Create the logic for the dice game pig : In this version of the game, when the computer does not roll a 1 and can choose whether to roll again, generate a new random value of 1 or 2. Use this value to decide whether the computer will continue to play or to pass the turn to the player.
Determine price based on size : When you write a program to determine price based on size, for the most efficient decision, you should ask first whether the size is _________.
Design an application that reads inventory records : Design an application that reads inventory records and produces a report that shows the price of every item on each day, one through seven.
Display a count of the number of guesses that were required : display a count of the number of guesses that were required.
For each parse tree explain : Show the two distinct parse trees that can be constructed for if expr then if expr then other else other using the grammar given in Figure 5.17. For each parse tree, explain the correspondence of then and else.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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