Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment you will implement a modified version of Concentration Game. Check out the Wikipedia page on the Concentration Game here: https://en.wikipedia.org/wiki/Concentration_(game) 1 Note

For this assignment you will implement a modified version of Concentration Game. Check out the Wikipedia page on the Concentration Game here: https://en.wikipedia.org/wiki/Concentration_(game) 1 Note that in this assignment (both here and in the code) I used words deck and board interchangeably, for basically the same thing. Before reading the description below, watch the video I made on how your game should play: https://youtu.be/yLNJ98Avyrw I also provide you with a file A3-example-runs.txt that contains the example runs (those I typed while making the video). Watching the videp will make following the below description much easier. Note that the video does not have a sound as it is not needed. All the requirements implied by the video and example runs in A3-example-runs.txt and the provided code in a3_xxxxxx.py and the requirements stated in this assignment should be considered mandatory requirements for the assignment. You may assume that the player will follow your instructions and enter the correct date type but not necessarily the correct data values for that type. For example, if you ask the player for an even integer between 2 and 52 you may assume that indeed they will enter an integer (rather than a real number say), but your program should test if the player entered an integer in the required range and if it is indeed even number. Your program should prompt the player to repeat the entry until correct input is obtained. You should also fully test your program for example, what does your program do if the player does something silly, like enteres a location that is already discovered, or enters two same locations ... Watch the video to see how your program should behave in these cases. Also, think of the design of your program. For example, your program should have a function that displays the current board (I provided that fully), but it should also have a function that displays the board with two new positions revealed (I only provided a header and docstrings for that function). These functions should be called from your game playing function (called play_game). Designing your program by decomposing it into smaller subproblems (to be implemented as functions) makes programming easer, less prone to errors and makes your code more readable. You will be graded on these aspects of your program too. The game is usually played with cards lied down on a table. Your game will not use graphics libraries to display the board, but instead it will print the board with the tools that we have seen in class so far, i.e. printing on Python console. A typical card has a suit and a rank on one side. Lets call that side of a card, a face side, and the other case a dull side. Instead of suit and a rank each of our cards will have a single character on its face side and that character will be an upper case letter of english alphabet or any special character (e.g those you can find on the upper row of your keyboard). A typical card deck has the same drawing on the dull side of the cards. Instead of a drawing our cards will have a character star, *, on their dull side. From now on we can assume we start off with such a deck with some number of cards. For the deck to be suitable for playing Concentration game, each character that appears in the deck needs to appear on an even number of cards. Furthermore, the deck cannot have cards with * on their face sides, as we could not distinguish a face side from an a dull side of such cards. Therefore before playing we need to clean up the deck. In particular, we need to remove all the cards that have a * on their faces. In addition, for each character that appears on an odd number of cards, we need to remove exactly one card with that character from the deck. After such a clean-up, the resulting deck can be used for playing Concentration game. We call such a deck, the one where each character appears on even number of cards and where no card has * on its face side, a playable deck. Finally we call a deck rigorous if it is playable and each character of the deck appears exactly two times. Your game must use a (one dimensional) list as the board, as implied by the provided code in a3_xxxxxx.py The game starts off by asking the player (1) if they wanted a (rigorous) deck, and thus board, automatically generated (2) or if they want to start with the deck given in a file. If option (1) is chosen, you need to first prompt the player for the size of the deck. You should only accept even integers, between 2 and 52 for Option 1. As part of this assignment, I provided you with a fully coded function, called create_board, that returns a rigorous deck of the given size. Thus option 1 only plays a game with rigorous decks. If option (2) is chosen, the deck will be read from a file. The player will enter a name of that file when prompted. I provide you with a couple of practice files. (TAs will test your assignment with these and some other files.) To use them, you need to put those files in the same directory/folder as your program a3_xxxxxx.py. As part of this assignment, I provided you with a fully coded function, called read_raw_board, that reads the file and returns a list containing the deck of cards specified in the file. This deck however is not necessarily playable. Thus you first need to make it playable. For that you will code a function called clean_up_board. I provide a header and docstrings for that function. That function should return a playable deck and that is the deck you will play the game with in Option 2. But before playing the game with it, for the fun of it, you would like to know if the resulting deck is not only playable but also rigorous. For that you will need to complete the function called is_rigorous for which I provide you with the header and docstrings. Finally you will notice that a3_xxxxxx.py has a function called play_game(board). That is where you should put your game paying code. The function play_game takes a playable deck as input parameter (i.e. a deck created by option 1 or option 2). Once the player completes the game, you should also print the number of guesses it took to solve it and how far it is from the optimal (although impossible without luck) len(board)/2 guesses. image text in transcribed

1 Concentration Game 100 points Fr this assigamient you will implement a modited version of anentration Gane. Clark Concentration Game here: https://en.wikipedia.org/wiki/Concentration. (gae) the Wikpedia page on the Note that in this assignment (both bere and in the eode) I used wods "deck and-hoard isteechangeably, for basically the same thing Before reading the description below, watch the video! inade on how your game should plage https://youtu.be/yuusaAry I also peowide you with a file A3-exaple-runs.txt that coutains the example runs thone I typedwbe mking the video) Watching the videp will make following the below description mach easier. Note that the video does not have a sound as it is nDeeded. All the requirements implied by the video aad e ample runs m A3-example-ras.txt aDd the provided code in a3 xxxxx py and the reqairements stated in this assignment should be cosidesed mandatory reqairements for the assigument You may assume that the player will folow your instructions and ester the cect date type bat mot mecssarily the corect data values for that type. For eample, if you ask the player for an even integer betwees 2 and 52 yos may ssume that indeed they will enter an integer (rather than a real Bumber say), but your prograan should test if the player estesed an integer in the mquired raw, and it i inded evetder Your program slaould prompt the parr toprprat tbr e try until eurrert isput s obtained. You shoald also fuly test your program-for example, what does your peogram do if the player does something illy, lake etteres a location that is alteady discovered, or euters two sane locationsWatch the video to ane how your progra sbould belhave in thesea Also, think of the desig of your program. For example, yoar program should hamction that displays the current board (I peowided that fully), but it shoulkd also have a functios that displays the boand with two wositions revealed only provided a brade and doctrings So that function). Tse functicns should be called fro your gme playing function aled play gane) Designing your peogram by decomposing it isto smalee subpeoims (to be impionnted as fanctions makes peogramming easer, less prone to enoes and alkes your eode smore readable. You will be graded on these aspects od urpeogtam too The ganar usually played with cards brd dawn a table. Your game will not grap ellen s display the board, but instead i will peint the board with the tools that we have seen in class so far, Le. piting on Python cosole. A typical eard has a suitand atauk on otse sideLet's call that side of a dazd, a forside.nd tbe other ca e a dull side, bead of suit and a rank each of our eards wil have a single dharactes on its face side and that charactee wil be ana upper ease letter od english alphabet or any special character (e.g those you can find on the upper sow of yor keyboard). A typical card deck has the same drawing on the dull side of the oards. Instead of a drawug our cards will have a character star. *- their dull side. From now on we al, assulnewestart off with such a deck with some number ofcwdFor the drk to be suitable for plaig Concentration game, each character that appears the derk Deeds to appear on aa eves-her of cwds Furthermore. the deck cannot have cards with on their face sides, as we coald uot distinguish a face side from an a dall side of such cards Therfore be ore playing we eed to clean up the deck. In particular, we need to remove all the cards that have a on their faces. In addition, for each character that appears on an odd umber of cards, re meed to remove exactly one card with that character from the deck. After such a clean-up, the resalting deck can be used for playing Concestration game. We call such a derk, the one where each character ay pears on evea number of cards and where no card has * its Nde, a playable Finally we call a deck nigorous if it is playable and each character of the deck apprars eactly two tis Your game mast use a (one dimensional) list as the board as implied by the provided code in a3.xoxp The game starts off bby asling the plver (1) if they waated a (rigoroas) dk and thas board, autonatically gmrrated (2) or if they wat to stazt with the deck given in a file E option (1) s chosen, you aeed to first peosugt the playes for the sine of the dck You sould oaly acorpt eve ltteges betwern 2 and 52 for Option 1. As part of this assiggment I provided you with a fally codd fumcticn calied create beard, that returns a rigorous deck of the given size. Thus option 1 ouly plays a gane with rigrous decks Koption (2) s chosetL the deck will be tead from a leThe planet will eata abu e od that tle wbra peumpted. Ipewsde you with a couple of peactice files (TAs will test your assigumeut with these and some othee les) To we them, you eed to put those 6les in the same directory folder as your progam a3,xxx.Py. As part of this assgest I peovsided you with a fully ded functiou, ealed read-rau-board, that reads tbe fik and returns a list ouataug the deck of cards specifed in the fie. This deck however is not necessarily playable Thas you fiest seed to make it playable. For that you will code a function caled clean,up.board. I provide a header and docstrings for that function. That fuction sold return a playable deck and that is the deck you will play the game with in Option 2. But before playing the gme wih it for the fun of it, you would lke to know if the resulting deck is not only playable but also rigoOS For that you will seed to complete the function called is,rigorous for which I provide you with the brader and dootrings Finally you will notice that a3xox.py has a function caled playgane Cboard. That is whse you should pat you gane paying code. The function play gaze tals a playable deck as inut parameter (ie a deck created by option 1 or option ) Once the player completes the game, yo should also print the mber of ganses it took to sove it and how Ear it r the optimal (alt hoagh impossable without luck) en bosrd)/2 gaesses yrt.ad whtner ebr Outside of those functions, in, in the ain you will do initial coenmuniatiG with t p in the a3,xxxxx specified

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Formal SQL Tuning For Oracle Databases Practical Efficiency Efficient Practice

Authors: Leonid Nossov ,Hanno Ernst ,Victor Chupis

1st Edition

3662570564, 978-3662570562

More Books

Students also viewed these Databases questions

Question

What is the difference between jigs and fixtures?

Answered: 1 week ago

Question

1. Discuss the four components of language.

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago