[SOLVED] R data structure game html python CSE 231 Computer Project #10 Fall 2019 Assignment Overview

$25

File Name: R_data_structure_game_html_python_CSE_231_Computer_Project_#10_Fall_2019_Assignment_Overview.zip
File Size: 866.64 KB

5/5 - (1 vote)

CSE 231 Computer Project #10 Fall 2019 Assignment Overview
This assignment focuses on the design, implementation and testing of a Python program which uses an instructor-supplied module to play a card game, as described below.
It is worth 55 points (5.5% of course grade) and must be completed no later than 11:59 PM on Monday, November 25, 2019.
Assignment Deliverables
The deliverable for this assignment is the following file: proj10.py the source code for your Python program
Be sure to use the specified file name and to submit it for grading via the Mimir system before the project deadline.
Assignment Background
Aces Up is a popular solitaire card game which is played by one person with a standard 52-card deck of cards. The rules and a tutorial video are available at:
http://worldofsolitaire.com/
Click on Choose Game at the top of the screen and click on Aces Up.
Your program will allow the user to play a simplified version of Aces Up, with the program managing the game. The game rules are given below.
Game Rules
1. Start: The game is played with one standard deck of 52 cards. The deck is shuffled and becomes the initial stock (pile of cards). The cards in the stock are placed face down.
Four cards are then dealt from the stock, left to right, one to each column of a four-column tableau. During play, additional cards will be added to the tableau, but it starts with just one card in each column. All tableau cards are visible.
The game also has a foundation, which is a single pile of cards. The foundation starts out empty and is filled during play.
2. Goal: The game is won when the stock is empty and the only cards left in the tableau are the four aces.

3. Moves: A player can move only one card at a time and the moved card must be the bottom card of a tableau column.
The card at the bottom of a column can be moved to the foundation if a higher rank card of the same suit is at the bottom of another column. Note that aces are high in this gamethat is, the rank of an ace is greater than the rank of any other card.
If a column of the tableau becomes empty, any card at the bottom of another column can be moved to the empty column.
No other moves are permitted.
4. Deal: A player can choose to deal instead of moving a card. In this case, the top four cards are dealt from the stock, left to right, with one card placed at the bottom of each column of the tableau. (Because four cards are always dealt at the same time the stock will never have fewer than four cards in this game.)
Assignment Specifications
You will develop a program that allows the user to play Aces Up according to the rules given above. The program will use the instructor-supplied cards.py module to model the cards and deck of cards. To help clarify the specifications, we provide a sample interaction with a program satisfying the specifications at the end of this document.
1. The program will recognize the following commands (upper or lower case):
D
F x T xy R
H
Q
Move card from Tableau column x to the Foundation.
Move card from Tableau column x to empty Tableau column y. Restart the game (after shuffling)
Display the menu of choices
Quit
Deal four cards from the stock to the tableau
where x and y denote column numbers, and the columns are numbered from 1 to 4.
The program will repeatedly display the current state of the game and prompt the user to enter a
command until the user wins the game or enters Q (or q), whichever comes first.
The program will detect, report and recover from invalid commands. None of the data structures representing the stock, tableau, or foundation will be altered by an invalid command.

2. The program will use the following function to initialize a game:
init_game() (stock, tableau, foundation)
That function has no parameters. It creates and initializes the stock, tableau, and foundation, and then returns them as a tuple, in that order. This corresponds to rule 1 in the game rules:
stock is a deck class object,
foundation is an empty list, and
tableauisalistoflists,eachcontainingoneofthedealtcards.Thefirstelementof
tableau is the leftmost column when displayed
The deck is shuffled and becomes the initial stock (pile of cards). Four cards are then dealt
from the stock, left to right, one to each column of a four-column tableau. 3. The program will use the following function to deal cards to the tableau:
deal_to_tableau( stock, tableau ): None
That function has two parameters: the data structure representing the stock and the data structure representing the tableau. It will deal a card from the stock to each column of the tableau. It will always deal four cards (why?).
4. The program will use the following function to display the current state of the game:
display( stock, tableau, foundation ) None Provided.
5. The program will use the following function to prompt the user to enter an option and return a representation of the option designed to facilitate subsequent processing.
get_option() list
That function takes no parameters. It prompts the user for an option and checks that the input supplied by the user is of the form requested in the menu. Valid inputs for options are described in item (bullet) 1 of the specifications. If the input is not of the required form, the function prints an error message and returns None.
Note that input with the incorrect number of arguments, e.g. D 2, or incorrect types, e.g. F D, will return None.
Also, note that in this function you do not check that y of T x y is empty (you do not have tableau as a parameter to check that).

The function returns a list as follows:
None, if the input is not of the required form
[D], for deal
[F, x], where x is an int, for moving a card to the foundation
[T, x, y], where x and y are ints, for moving a card within the tableau from
column x to column y
[R], for restart
[H], for displaying the menu
[Q], for quit
6. The program will use the following function to determine if a requested move to the foundation is valid:
validate_move_to_foundation( tableau, from_col ) bool
That function has two parameters: the data structure representing the tableau and an int indicating the column whose bottom card should be moved. The function will return True, if the move is valid; and False, otherwise. In the latter case, it will also print an appropriate error message. There are two errors that can be caught: from_col is empty or move is invalid. Remember: a card can be moved to the foundation only if a higher ranked card of the same suit is at the bottom of a Tableau column.
Hint: consider tableau index and remember that Ace is high. Also, from_col must be a valid value (1 <= from_col <= 4).7. The program will use the following function to move a card from the tableau to the foundation:move_to_foundation( tableau, foundation, from_col ) NoneThat function has three parameters: the data structure representing the tableau, the data structure representing the foundation, and an int indicating the column whose bottom card should be moved. If the move is valid, the function will update the tableau and foundation; otherwise, it will do nothing to them. Hint: the list pop() method is useful, if you desire a terse function. from_col must be a valid value (1 <= from_col <= 4).8. The program will use the following function to determine if a requested move to within the tableau is valid:validate_move_within_tableau( tableau, from_col, to_col ) boolThat function has three parameters: the data structure representing the tableau, an int indicating the column whose bottom card should be moved, and an int indicating the column the card should be moved to. The function will return True, if the move is valid; and False, otherwise. In the latter case, it will also print an appropriate error message. Remember: you can only move a card to an empty tableau slot. Also, from_col and to_col must be valid column values(1 <= from_col <= 4 and 1 <= to_col <= 4).9. The program will use the following function to move a card from the tableau to the foundation:move_within_tableau( tableau, from_col, to_col ) NoneThat function has three parameters: the data structure representing the tableau, an int indicating the column whose bottom card should be moved, and an int indicating the column the card should be moved to. If the move is valid, the function will update the tableau; otherwise, it will do nothing to it. Hint: the list pop() method is useful, if you desire a terse function.from_col and to_col must be valid column values: (1 <= from_col <= 4 and1 <= to_col <= 4).10. The program will use the following function to check if the game has been won:check_for_win( stock, tableau ) boolThat function has two parameters: the data structure representing the stock and the data structure representing the tableau. If returns True, if the stock is empty and the tableau contains only the four aces; and False, otherwise.11. Once you write all your function, it is time to write your main function:a) Your program should start by initializing the board (the stock, the tableau and thefoundation).b) Display the menu and the board.c) Ask to input an option and check the validity of the input.d) If D, deal four cards from the stock to the tableaue) If F x, move card from Tableau column x to the Foundationf) If T x y, move card from Tableau column x to empty Tableau column y.g) If R, restart the game by initializing the board (after shuffling). Display the rules andthe menu.h) If H, display the menu of choicesi) If Q, quit the gamej) If none of these options, the program should display an error message.k) The program should repeat until the user won or quit the game. Display a goodbyemessage. Assignment Notes1. Before you begin to write any code, play with the provided demo program and look over the sample interaction supplied on the project website to be sure you understand the rules of the game and how you will simulate the demo program. The demo program is at http://worldofsolitaire.com/: Click on Choose Game at the top of the screen and click on Aces Up. 2. We provide a module called cards.py that contains a Card class and a Deck class. Your program must use this module (import cards). Do not modify this file! This is a generic module for any card game and happens to be implemented with aces low (having a rank of 1). Your game requires aces to have a rank higher than any other card. Your program must implement aces high without modifying the cards module.3. Laboratory Exercise #11 demonstrates how to use the cards module. Understanding those programs should give you a good idea how you can use the module in your game.4. We have provided a framework named proj10.py to get you started.Using this framework is mandatory. Begin by downloading proj10.py. Check that it compiles. Gradually replace the stub code (marked with comments) with your own code. (Delete the stub code.)5. The coding standard for CSE 231 is posted on the course website:http://www.cse.msu.edu/~cse231/General/coding.standard.htmlItems 1-9 of the Coding Standard will be enforced for this project.6. Your program may not use any global variables inside of functions. That is, all variables used in a function body must belong to the functions local name space. The only global references will be to functions and constants.7. Your program may not use any nested functions. That is, you may not nest the definition of a function inside another function definition.8. Your program must contain the functions listed above; you may develop additional functions, as appropriate.TEST 1Input options:D: Deal to the Tableau (one card on each column).F x: Move card from Tableau column x to the Foundation.T x y: Move card from Tableau column x to empty Tableau column y. R: Restart the game (after shuffling)H: Display the menu of choicesQ: Quit the gamestock tableau foundation XX A K Q AInput an option (DFTRHQ): HInput options:D: Deal to the Tableau (one card on each column).F x: Move card from Tableau column x to the Foundation.T x y: Move card from Tableau column x to empty Tableau column y. R: Restart the game (after shuffling)H: Display the menu of choicesQ: Quit the gamestock tableau foundation XX A K Q AInput an option (DFTRHQ): Dstock tableau foundation XX A K Q AK Q A KInput an option (DFTRHQ): R=========== Restarting: new game ============Aces High Card Game:Tableau columns are numbered 1,2,3,4.Only the card at the bottom of a Tableau column can be moved.A card can be moved to the Foundation only if a higher ranked cardof the same suit is at the bottom of another Tableau column. To win, all cards except aces must be in the Foundation.Input options:D: Deal to the Tableau (one card on each column).F x: Move card from Tableau column x to the Foundation.T x y: Move card from Tableau column x to empty Tableau column y. R: Restart the game (after shuffling)H: Display the menu of choicesQ: Quit the gamestock tableau foundation XX A K Q AInput an option (DFTRHQ): QYou have chosen to quit. TEST 2 : stock is only queens, kings, and acesInput options:D: Deal to the Tableau (one card on each column).F x: Move card from Tableau column x to the Foundation.T x y: Move card from Tableau column x to empty Tableau column y. R: Restart the game (after shuffling)H: Display the menu of choicesQ: Quit the gamestock tableau foundation XX A K Q AInput an option (DFTRHQ): F 1 Error, cannot move A.stock tableau foundation XX A K Q AInput an option (DFTRHQ): F 2stocktableau foundationXX A QA KInput an option (DFTRHQ): F 3stock tableau foundation XX A A QInput an option (DFTRHQ): Dstock tableau foundation XX A Q A A QK KInput an option (DFTRHQ): f 4stock tableau foundation XX A Q A A KKInput an option (DFTRHQ): F 2stock tableau foundation XX A AA QKInput an option (DFTRHQ): T 1 2stock tableau foundation XX A K A A Q Input an option (DFTRHQ): F 2stocktableau foundationXX A AA K Input an option (DFTRHQ): Dstock tableau foundation A A A A KQ KQInput an option (DFTRHQ): F 3stock tableau foundation A A A A KQ QInput an option (DFTRHQ): F 4stocktableau foundationA A A A Q QInput an option (DFTRHQ): F 1You won! TEST 3: stock is only queens, kings, and acesInput options:D: Deal to the Tableau (one card on each column).F x: Move card from Tableau column x to the Foundation.T x y: Move card from Tableau column x to empty Tableau column y. R: Restart the game (after shuffling)H: Display the menu of choicesQ: Quit the gamestock tableau foundation XX Q Q Q QInput an option (DFTRHQ): Dstock tableau foundation XX Q Q Q QA K A KInput an option (DFTRHQ): F aError in option: F aInvalid option.stock tableau foundation XX Q Q Q QA K A KInput an option (DFTRHQ): T 2Error in option: T 2Invalid option.stock tableau foundation XX Q Q Q QA K A KInput an option (DFTRHQ): D 2Error in option: D 2Invalid option.stock tableau foundation XX Q Q Q QA K A KInput an option (DFTRHQ): F 2 stock tableau foundation XX Q Q Q Q KA AKInput an option (DFTRHQ): F 4stock tableau foundation XX Q Q Q Q KA AInput an option (DFTRHQ): F 2stock tableau foundation XX Q QQ QA AInput an option (DFTRHQ): T 1 2stock tableau foundation XX Q A Q Q QAInput an option (DFTRHQ): F 1stock tableau foundation XX A Q Q QAInput an option (DFTRHQ): T 3 1stock tableau foundation XX A A Q Q QInput an option (DFTRHQ): dstock tableau foundation A A Q Q QA K A KInput an option (DFTRHQ): F 4stock tableau foundation A A Q Q KA K A Input an option (DFTRHQ): F 4stock tableau foundation A A Q QA K AInput an option (DFTRHQ): T 3 4stocktableau foundationA A Q A Q A KInput an option (DFTRHQ): 3Error in option: 3Invalid option.stocktableau foundationA A Q A Q A KInput an option (DFTRHQ): F 3stocktableau foundationA A A Q A KInput an option (DFTRHQ): T 1 3stocktableau foundationA A A A Q KInput an option (DFTRHQ): F 3Error, cannot move A.stocktableau foundationA A A A Q KInput an option (DFTRHQ): F 2You won! TEST 4Input options:D: Deal to the Tableau (one card on each column).F x: Move card from Tableau column x to the Foundation.T x y: Move card from Tableau column x to empty Tableau column y. R: Restart the game (after shuffling)H: Display the menu of choicesQ: Quit the gamestock tableau foundation XX 9 J 105Input an option (DFTRHQ):f 4stocktableau foundationXX9J10 5Input an option (DFTRHQ):T 1 4stock tableau foundation XX J 109 5Input an option (DFTRHQ):dstock tableau foundation XX 4 J 109 5863Input an option (DFTRHQ):f 4stock tableau foundation XX 4 J 109 38 6Input an option (DFTRHQ):f 4Error, cannot move 9.stock tableau foundation XX 4 J 109 386Input an option (DFTRHQ):f 2stock tableau foundation XX 4 J 109 86Input an option (DFTRHQ):f 3 stock tableau foundation XX 4 J 109 6Input an option (DFTRHQ):dstock tableau foundation XX 4 J 109 653QAInput an option (DFTRHQ):f 3stock tableau foundation XX 4 J 109 Q53 AInput an option (DFTRHQ): f 2stock tableau foundation XX 4 J 109 35AInput an option (DFTRHQ):f 1stock tableau foundation XX 4 J 109 5AInput an option (DFTRHQ):f 1stock tableau foundation XX J 109 4AInput an option (DFTRHQ):t 4 1stock tableau foundation XX A J 109 4Input an option (DFTRHQ):dstock tableau foundation XX A J 109 47724Input an option (DFTRHQ):f 3stock tableau foundation XX A J 109 277 4Input an option (DFTRHQ): f 4 stock tableau foundation XX A J 109 477Input an option (DFTRHQ):f 2stock tableau foundation XX A J 109 77Input an option (DFTRHQ):f 1stock tableau foundation XX A J 109 7Input an option (DFTRHQ):dstock tableau foundation XX A J 109 72A65Input an option (DFTRHQ):dstock tableau foundation XX A J 109 72A652648Input an option (DFTRHQ):f 1stock tableau foundation XX A J 109 22A65648Input an option (DFTRHQ):f 1stock tableau foundation XX A J 109 2A65648Input an option (DFTRHQ):f 2stock tableau foundation XX A J 109 6A 6 5 4 8Input an option (DFTRHQ):f 3stocktableau foundation XX A J 109 4 A 6 58Input an option (DFTRHQ):f 3Error, cannot move 6.stock tableau foundation XX A J 109 4A 6 5 8Input an option (DFTRHQ):dstock tableau foundation XX AJ109 4JA659A8KInput an option (DFTRHQ):f 2stock tableau foundation XX AJ109 9JA65A8KInput an option (DFTRHQ):f 1stock tableau foundation XX AJ109 JA65A8KInput an option (DFTRHQ):f 4stock tableau foundation XX A J 109 KA 6 5 A 8Input an option (DFTRHQ):f 4stock tableau foundation XX A J 109 8A 6 5 AInput an option (DFTRHQ):f 4 stock tableau foundation XX A J 109 5A 6 AInput an option (DFTRHQ):f 4stocktableau foundationXXAJ10 9A 6 AInput an option (DFTRHQ):t 2 4stock tableau foundation XX A J 10A 96 AInput an option (DFTRHQ):f 2stocktableau foundationXXA10 AJ6 AInput an option (DFTRHQ):t 3 2stock tableau foundation XX A A 10A J6Input an option (DFTRHQ):dstock tableau foundation XX A A 10A J8 7 6 K QInput an option (DFTRHQ):dstock tableau foundation XX A A 10A J876KA2Q99Input an option (DFTRHQ):f 2stock tableau foundation XX A A 10A 28 7 6 K A Q9 9Input an option (DFTRHQ):f 4stock tableau foundation XX A A 10A 9876KAQ9Input an option (DFTRHQ):dstock tableau foundation XX A A 10A 9876KAJQ5893Input an option (DFTRHQ):f 4stock tableau foundation XX A A 10A 5876KAJQ893Input an option (DFTRHQ):f 3stock tableau foundation XX A A 10A 3876KAJQ89Input an option (DFTRHQ):f 3stock tableau foundation XX A A 10A 9876KAJQ8Input an option (DFTRHQ):f 1stock tableau foundation XX A A 10A 8876KAJQ Input an option (DFTRHQ):f 3stock tableau foundation XX A A 10A Q876KAJInput an option (DFTRHQ):f 3stock tableau foundation XX A A 10A 687 K A JInput an option (DFTRHQ):f 3stocktableau foundationXXAAA1087 K A JInput an option (DFTRHQ):t 4 3stocktableau foundationXXAAKA108 7 A JInput an option (DFTRHQ):f 3stocktableau foundationXXAAAK8 7 A JInput an option (DFTRHQ):t 1 3stocktableau foundationXXAAAAK8 7 JInput an option (DFTRHQ):f 1stocktableau foundationXXAAAA87 JInput an option (DFTRHQ):f 2stocktableau foundation XXAAAAJ7Input an option (DFTRHQ):dstock tableau foundation XX AAA A JK 7 6 10 4Input an option (DFTRHQ):f 2stock tableau foundation XX AAA A 4K7610Input an option (DFTRHQ):f 2stock tableau foundation XX AAA A 7K610Input an option (DFTRHQ):f 4stocktableau foundationXXAAAA10K6Input an option (DFTRHQ):f 3stocktableau foundationXXAAAA6KInput an option (DFTRHQ):f 1stocktableau foundationXXAAAAKInput an option (DFTRHQ):dstock tableau foundation XX AAA A KQ7K3Input an option (DFTRHQ):f 4stocktableau foundationXXAAAA3Q7KInput an option (DFTRHQ):f 1 stocktableau foundationXXAAAAQ7KInput an option (DFTRHQ):f 2stocktableau foundationXXAAAA7KInput an option (DFTRHQ):f 3stocktableau foundationXXAAAAKInput an option (DFTRHQ):dstocktableau foundationAAAAK10 Q 10 JInput an option (DFTRHQ):qYou have chosen to quit. Grading RubricComputer Project #10Scoring SummaryGeneral Requirements:(5 pts) Coding Standard 1-9(descriptive comments, mnemonic identifiers, format, etc…)Implementations:(3 pts) init_game(6 pts) validate_move_to_foundation(4 pts) move_to_foundation(6 pts) validate_move_within_tableau(4 pts) move_within_tableau(4 pts) check_for_win(2 pts) Test 1(7 pts) Test 2(7 pts) Test 3(7 pts) Test 4

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] R data structure game html python CSE 231 Computer Project #10 Fall 2019 Assignment Overview
$25