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

  Determine average compression rate for each type of frame

The mpeg stat program can be used to display statistics for video streams

  Implement avl single and double rotations

1. Show the result of inserting 2, 1, 4, 5, 9, 3, 6, 7 into an initially empty AVL tree. 2. Keys 1, 2, ... , 2k - 1 are inserted in order into an initially empty AVL tree. Prove that the resulting tree is perfectly balanced. 3. Write the remaining pr..

  List the student number

A database records information about tutorials in a particular unit offering (such as ICT285 this semester). A student is supposed to attend only one of several available tutorials, each of which is taken by a tutor at a particular day and time. A..

  Slugworth candies

Slugworth Candies, LLC, is a candy maker company that employs 450 people. The company is composed of six departments: Executive Staff (20), Human Relations (6), Finance and Accounting (15), Marketing and Sales (15), Factory (150), and Research & D..

  Technologies dependent on the use of cryptography

How are biometric technologies dependent on the use of cryptography?

  Differences between stand-alone risk and diversifiable risk

What will happen to the portfolio's risk if more andmore randomly selected stocks are added?

  Why they do not fit the functional paradigm

List 2 items, which are non-functional features found in Scheme. Explain why they do not fit the functional paradigm.

  What will be the average access time

What will be the average access time when both read and write are taken into consideration with write through strategy?

  What you learn in following module

Do you conduct routine and regular maintenance on your personal computer? Do you do use utilities like disk clean-up, error checking, defragmentation, and back-up?

  Use matlab to write a function function

Use Matlab to write a function function, call it fRotate, with a function, an interval, and an angle as its input arguments.

  Convert from decimal to octal and hexadecimal

Convert from decimal to octal and hexadecimal a. 16.4 b. 39 c. 48.67

  The it manager for the only print shop in a small town in id

The IT manager for the only print shop in a small town in Idaho. The shop is connected to the internet by satellite link. Orders are received via the internet as well as by walk-ins with portable storage drives or smart phones that can transfer files..

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