联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Algorithm 算法作业Algorithm 算法作业

日期:2024-11-19 05:42

CSE 231

Fall 2024

Computer Project 07

1.  Assignment Overview (learning objectives)

This assignment focuses on the design, implementation and testing of a Python program which uses classes to solve the problem described below.  Note: you are using a class we provide.

This assignment will give you more experience on the use of:

•   Dictionaries

•   Functions

•   Exception handling

•   Classes and OOP

The program allows users to run the game of UNO in multiple rounds through a series of commands. Users can deal cards, check what kind of card do they have, and check who won the game.

2.  Important Note about submission

This assignment is worth 50 points (5.0% of course grade). It must be completed before 11:59 PM EST on Monday, November 18th.

After the due date (11/18), your score will be deducted by 2% for every 1 hour late or a fraction of it. No submissions will be accepted after 24 hours from the due date. The penalty will be applied on the full project score.

The project will be automatically submitted by the due date (11/10). If you want to keep working on it after the deadline with penalty, you must manually click on “Mark as uncompleted”, acknowledge the penalty message and manual click on “Mark as completed” when done.

3. Assignment Deliverable

The deliverable for this assignment is the following file:

proj07.py – the source code for your Python program

Be sure to use the specified file name and to submit it for grading via Codio before the project deadline. Consider using PyCharm at the beginning before submitting it to Codio given limited submissions.

Download the zip files provided on the course webpage including necessary and help files, the starter codes, formatted strings, and sample code interactions are also included.  Codio has the starter code.

Read the full document carefully before getting started. You may miss some information or instructions if you do not, so read the full document.

Every project has a video and a document to get you started with the project. The video will include a table of contents where you can use it to skip to the parts that you want to watch.

4.  Understanding the Game

UNO is a fast-paced card game where the goal is to get rid of all your cards. Each player takes turns playing cards that match the color or number of the card in the discard pile. Special action cards, such as "Skip," "Reverse," and wild cards, add twists and turns to the game.

The best way to understand any game is to play it. The rules of this game are relatively simple, and you can find information about the game in the links below:

https://en.wikipedia.org/wiki/Uno_(card_game)

https://www.youtube.com/watch?v=sWoSZmHsCls

Game Structure

●   Card Color: The possible colors are Red, Green, Blue, and Yellow.

●   Card Value: The value can be a number (0-9) or an action (Skip, Reverse, Draw Two(+2), Color Change, Draw Four(+4)).

●   Wild Color Change: Allows the player to change the current color in play.

●   Wild Draw Four: Forces the next player to draw four cards, and the player playing it also chooses the new color.

●   For this project, there are 13 cards of each color and 8 Wild Cards totaling to 60 cards.

●   The game begins by creating a deck of all of the cards, which is shuffled.

●   Players are asked how many people will be playing (between 2 and 5 players).

●   Each player draws 5 cards from the deck to form. their starting hand.

●   The game begins with the last card in the deck placed in the discard pile.

●   The player can either play a card from their hand that matches the color or value of the card in the    discard pile or play a wild card. Example: if the discard pile shows "Red 7", the player can play any "Red" card or a card with the value "7", or they can use any wild card it is available in their hand.

●   If they cannot play a card, they must draw a card from the deck.

●   If the deck is empty, the deck should be reset using the full discard pile. A new card is then dealt to the discard pile.

●   Special cards trigger various effects:

○   Skip: The next player's turn is skipped.

○   Reverse: The direction of play is reversed.

○   Draw Two (+2): The next player draws two cards and loses their turn.

○   Wild Color Change: The player can choose a new color to continue the game.

○   Wild Draw Four (+4): The next player draws four cards, and the player chooses the new color.

●   Note: Skip, Reverse and Draw Two contains color, so they must match with the color of discard pile.

●   A player wins the game by being the first to play all their cards.

●   The game may continue for multiple rounds, allowing for further competition among the players.


5.  Assignment Specifications and Requirements

5.1. General Requirements

These are general requirements that you need to satisfy to ensure a full score:

1.   Items 1-9 of the Coding Standard will be enforced for this project:

http://www.cse.msu.edu/~cse231/General/coding.standard.html

2.   Per the syllabus, if you "hard code" answers, you will receive a grade of zero for the whole project.

3.   You should only use materials covered in class up to week 12(videos and textbook).

4.   You have to implement at least 12 functions.

a.   A good practice is to have functions that perform. one task at a time. It makes your code more readable.

b.   Any function that you create needs to be used in your code.

c. There must be a function named main() (check section 5.2.2 for more details about the project specifications). The main function is called by:

if __name__ == '__main__':

main()

d.   There must be at least 11 other functions that do something meaningful (it is good to have more functions).

5.2. Assignment Specifications

You will develop a program that allows the user to play the simplified UNO game. The program will use the instructor supplied uno.py module to model the cards, deck, and player. To help clarify the specifications, we provide sample output of a correctly implemented UNO python program below in the Sample Output section.  We also provide a proj07.py file that contains the starter code. Your program must use the import statement for uno.py. You should not modify the uno.py file otherwise you will not pass the tests as we will be using  our own uno.py file that is identical to the file provided in the starter code. Make sure to go through the uno.py file and understand the methods in each class.

In this assignment, you will implement the necessary functions to run a complete game of UNO using the pre-defined classes. You are expected to build the game logic, handle player turns, manage the deck and discard pile, process special cards, and determine the winner. In the main function,

●   You should use the appropriate strings from the starter code.

●    Display a Welcome Banner: Upon starting the program, display a banner to welcome or inform. the user. This is achieved through the banner variable, which contains a welcome message.

●   Prompt repeatedly if the user wants to play a game until the user say no.

●   For each game (round),

○   Ask the user for the number of players (between 2 and 5). If the user doesn’t input a valid number, the program should re-prompt until a valid number is input.

○   Initialize the players using the Player class. The player number starts from 1.

○   Create a deck using the Deck class and deal 5 cards to each player using the appropriate method in the Player and Deck classes.

○   Place the last card from the deck into the discard pile to start the game.


○   At first, the direction of the game will be clockwise, i.g., first Player #1’s turn, then Player #2’s turn, then Player #3’s turn and so on until a reverse card is applied.

○   Display the current card from the discard pile and the current player’s hand.

○   Show the playable cards that match either the color or value of the discard pile’s top card, or any wild card.

○   Ask the user to choose a color. You should display the error message when the card is not valid. Note that if the user wants to play a wild card, then they need to input Wild” here.

○   Then ask the user to choose the value. Note that if the user wants to play a wild card they need to input ‘Color Change’ or ‘+4’ here.

○   If the user chooses an invalid card which is not playable, the program will show a message and ask the user to input again.

○   If there is no playable card, show appropriate message and draw a card from the deck to player’s hand using appropriate method defined in the class.

○   If the deck is empty, reset the deck using the discard pile using the appropriate method defined in the class. A new card is then dealt to the discard pile.

○   Implement the functionalities of the special cards (Skip, Reverse, +2, Color Change, +4).

○   Check how many cards are there in the current player’s hand to determine if they have won. Use the appropriate method from the Player class

○   Determine the next player after each turn according to the direction (clockwise/anti-clockwise)

○   After each turn, show how many cards left in each player’s hand.

○   After completing one round, ask the user whether they want to play another round, if yes, go for another round. Otherwise, show the ending message.

Hints:

Do not modify the uno.py file in any case.

●   You can use a dictionary to store the players.

●   If you initialize a deck class, your deck is automatically created with random shuffling.

●   You can determine the next player by keeping track of the direction.

●   When the player plays a card, you can add that card to the discard pile, thus that card will be the last card for the next turn.

●   A wild card is always playable if it is available at the player’s hand.

●   You can use __str__ () method of Card class to get a string representation of a card when needed.

●   Similarly, you can use __str__ () method of Player class to show how many cards are there in the player’s hand.

6. Grading Rubric

Computer Project #06 Scoring Summary

General Requirements:

(  6 pts) Coding Standard

( 12 pts) At least 12 function definitions

Implementation: 32 pts in total

Visible tests (Test 0 and 1)

Hidden tests (Test 2 and 3)

More points are allocated to the hidden tests. The visible tests serve as a self-check. To pass all the tests, you need to follow the complete instructions in the PDF.

Note:

hard coding an answer earns zero points for the whole project.

•     Use of any advanced data structures not covered in class earns zero points for the whole project.

7. Sample Outputs:

The outputs for Test 0 and Test 1 are in the output0.txt and output1.txt





版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp