How would you represent the game as a collection of objects

Assignment Help Python Programming
Reference no: EM132183614

Assignment - OOP Review and Best Practices

For this assignment, you will be implementing a simple game called Pig.

Overview

This week we reviewed Object Oriented Programming concepts, as well as went over best practices associated with OOP. For this week's assignment, you will be implementing a simple game called Pig. Details about the game can be found here. Your job will be to code a functional application that implements this game for two players. Next week, we will expand on this assignment and allow the computer to play, using a certain strategy.

All development should be done in this repository.

1. Read the assignment over a few times. At least twice. It always helps to have a clear picture of the overall assignment when understanding how to build a solution.

2. Think about the problem for a while, and even try writing or drawing a solution using pencil and paper or a whiteboard.

3. Before submitting the assignment, review the "Functional Requirements" section and make sure you hit all the points. This will not guarantee a perfect score, however.

Rules of The Game

The rules of Pig are simple. The game features two players, whose goal is to reach 100 points first. Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn, the player is faced with two decisions:

- roll - If the player rolls a
o 1: the player scores nothing and it becomes the opponent's turn.
o 2 - 6: the number is added to the player's turn total and the player's turn continues.
- hold - The turn total is added to the player's score and it becomes the opponent's turn.

The key to the game is this: on every roll, a player faces a decision about how large a turn total should be risked to possibly get an even larger total. You can play this online (requires java) to get a feel for the game.

Design
Now it is time to stop, and think about the design of the program. You could certainly write this assignment using no classes, but would clearly defeat the purpose of the assignment. How would you represent the game as a collection of objects? What entities do you think are in the game that should be modeled as an object? The design for this program will be up to you, but your code must implement the game fully as described above and in the functional requirements.

To help guide your design, you should think about the following entities:

- Players: in this case, we only need two (human) players per game, but how would we model a single player? What properties should it have and what actions should it have to implement?
- The Die: for this variant of Pig, we are using a single die. How can we model this as an object?

- How do we model the state of the game itself? For example, we need to track the players, their scores, and the die being used for the game.

Testability

To make your code easier to test for correctness, please remember:
- When using any random features in your code, make sure to use a random seed. To keep everyone consistent, use a seed of 0 at the beginning of your code.
- When asking the human for a decision, you should accept the letter 'r' to indicate a roll, or a `11' to indicate the player wants to hold
- When the game is over, the program should stop. To run another game, you need to run the program again.

Functional Requirements
- The game should continue until one of the players has a score that is greater than or equal to 100
- At every step, the program should output to the player what was rolled, the current score for this turn so far, and their total score in the game before asking for a decision.
- Every rule listed in the "Rules Of The Game" section should work (i.e., rolling a one ends a player's turn with no points added to their score)

Verified Expert

Pig dice game created using the python. This game is created using different rules which are given in the requirement. n number of players can able to play the game in a single time. both human players and computer players can play this game at the same time. The system will automatically generate the initial player and announces the result. functional requirements, design(according to the rules) and implementation were also done.

Reference no: EM132183614

Questions Cloud

Finder providing referral services for fee may : Finder providing referral services for fee may. All records of agent activities on behalf of client during listing period need to be retained by agent's broker.
Explain the outcomes of the relevant legal proceedings : Evaluation report writing is an essential component of a psychology professional's work with clients in the legal system. The results of evaluations have to be.
Global business market and why : What kind of leadership you promote in your global business market and why?
Agile it organization design : How you use technology in your global business. What kind of lessons you adopt from the "Agile IT Organization Design?"
How would you represent the game as a collection of objects : How would you represent the game as a collection of objects? What entities do you think are in the game that should be modeled as an object?
Codes of conduct are really necessary : Are they of any value in helping establish an ethical culture in a company? Explain and defend your responses.
Discuss about the custody evaluation : Forensic professionals are often called upon to provide opinions about custody in cases of divorce, parental termination, and reestablishment of custody.
What is group support systems : What is a Group Support Systems? Explain the effects of Power, and Influence in an Organization. Info. Tech.
Environmental hazard is delivered to buyer by seller : Notice of any environmental hazard is delivered to a buyer by a seller in writing on.

Reviews

len2183614

12/2/2018 10:23:00 PM

For this assignment, you will be implementing a simple game called Pig. Details on the game can be obtained from the link attached Also, the same details will be on the first page that was scanned in. Lastly, please work with me on the price. Also, I' am a repeat customer, and I' am sure to have more assignments for you before the end of this month.

len2183614

12/2/2018 10:22:13 PM

Extra Credit For extra credit, you can: • Implement the same game as above but that allows for a configurable number of players (via a command line parameter called --numPlayers) • Allow for more than one game at at time. Remember, at the end of a game, the scores and the game state need to be reset

Write a Review

Python Programming Questions & Answers

  Write a python script that builds an html file

Write a Python script that builds an HTML file of your own design. Add an image tag into your HTML and link it to an image on your hard drive.

  Adopt a service oriented architecture

adopt a Service Oriented Architecture (SOA) for its future IT infrastructure. Queensland Health executives were impressed with your Template based, Reference

  Ida to reverse engineer a piece of shellcode

You are a Malware Investigator at 0xC0ff33, Inc and an incident responder came across injected shellcode during an investigation. He has done all he can in IDA and has passed on the .idb file to you. Figure out what the purpose of the malware was ..

  Write a program that uses all of your functions

Write a program that uses all of your functions from above to carry out an RSA key generation, encryption, and decryption.

  Program for simulating a supermarket self-service

Design and model two classes: Product and CheckoutRegister - Create an activity chart which describes the behaviour of the checkout system

  Write a program to simulate the grocery store

You have been asked to write a program to simulate the grocery store as it checks out customers. YOU ARE REQURED TO USE A QUEUE TO SOLVE THE PROBLEM.

  Calculate the cost of that order and add

A good friend of yours is managing a fund raiser for a football team. He needs a program to calculate the total amount of candy sold at a football game.

  Code a console-based program in python

CP1404/CP5632 2016 SP2/22/52 Assignment 1 - Shopping List 1.0. You are to plan and then code a console-based program in Python 3, as described in the following information and sample output. This assignment will help you build skills using selectio..

  What is the optimal production policy

QBUS 2310 Management Science Assignment. What is the optimal production policy and what is the profit under this policy

  Create a cheat commands in the game

Create a cheat commands in the game so player can pick up any item he wants from any location in the map - Display all possible actions you can carry out in game.

  Write a python program that generates a small web site

ICT112 Assignment. Your task in this assignment is to write a Python program that generates a small web site to inform Sunshine Coast people about some aspect of the local environment or a local sustainability issue

  Implement your algorithm in python

Write an algorithm in structured English (pseudocode) that describes the steps required to perform the task specified and reinforce topic material related to the programming work cycle, and the input, processing, output program structure.

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