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

  Formulas and use functions to do calculations

For this project, pretend you're going to go on a trip to visit three places. You should have estimated costs for transportation, hotels, and meals. Create a spreadsheet to calculate the total costs for each item, total cost, and percent of the total..

  Discuss the protection mechanisms

Discuss the protection mechanisms you consider best suited for the technological innovation you have selected for your final project and how those mechanisms fit within the control continuum

  Creation of a base geometric class

The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle and Rectangle, that are derived public from the class Shape.

  Planetary motion in four and higher dimensions

Consider the motion of planets in planar circular orbits around heavy stars in our four­ dimensional spacetime and in  spacetimes with  additional spatial dimensions.

  Would you like to see different software installed in labs

Would you like to see different software or hardware installed in the computer labs?

  Explain the different usability data-gathering techniques

Explain the different usability data-gathering techniques

  Why do you think there is a lot of focus on ethical thinking

Why do you think there is a lot of focus on ethical thinking in today's world?  Why do you think it is important? What are your initial thoughts on ethical thinking?

  Explaining method effective in cracking web passwords

More people are utilizing online shopping and banking. Explain one method that you believe is most effective in cracking Web passwords.

  How many pages are needed to store the entire job

How many pages are needed to store the entire job?

  Develop a web application using krl and the live web

Description/Requirements:Develop a web application using KRL and the Live web.

  Science question

Only those class members that are presented to the users of the class are part of the ______ of the class.

  Identify the security advantages of cloud-based solutions

A.Identify the security advantages of cloud-based solutions. B.Identify the security disadvantages if cloud-based solutions.

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