Build a program that bends the rules to trounce

Assignment Help Python Programming
Reference no: EM131501963

Assignment

In this part of the  assignment, you will build a program that bends the rules to trounce its human opponent time and time again. In case you aren't familiar with the Word Guessing game, the rules are as follows:

1. One player chooses a secret word, then writes out a number of dashes equal to the word length.

2. The other player begins guessing letters. Whenever they guess a letter contained in the hidden word, the first player reveals each instance of that letter in the word. Otherwise, the guess is wrong.

3. The game ends either when all the letters in the word have been revealed or when the guesser has run out of guesses.

Fundamental to the game is the fact the first player accurately represents the word they have chosen. That way, when the other players guess letters, they can reveal whether that letter is in the word. But what happens if the player doesn't do this? Suppose that you are playing Word Guessing and it's your turn to choose a word, which we'll assume is of length four. Rather than committing to a secret word, you instead compile a list of every four-letter word in the English language. For simplicity, let's assume that English only has a few four-letter words, all of which are reprinted here:

ALLY BETA COOL DEAL ELSE FLEW GOOD HOPE IBEX

Now, suppose that your opponent guesses the letter 'E.' You now need to tell your opponent which letters in the word you've "picked" are E's. Of course, you haven't picked a word, and so you have multiple options about where you reveal the E's. Here's the above word list, with E's highlighted in each word:

ALLY BETA COOL DEAL ELSE FLEW GOOD HOPE IBEX

Every word in the word list falls into one of five "word categories:"

  • ----, containing the word ALLY, COOL, and GOOD.
  • -E--, containing BETA and DEAL.
  • --E-, containing FLEW and IBEX.
  • E--E, containing ELSE.
  • ---E, containing HOPE.

Since the letters you reveal have to correspond to some word in the word list, you can choose to reveal any one of the above five categories. There are many ways to pick which category to reveal - perhaps you want to steer your opponent toward a smaller category with more obscure words, or toward a larger category in the hopes of keeping your options open.  If we adopt the larger category approach and always choose the largest of the remaining word categories you would pick the category ----. This reduces your word list down to ALLY COOL GOOD and since you didn't reveal any letters, you would tell your opponent that their guess was wrong.

Your program should do the following:

1. Read the file dictionary.txt, which contains the full contents of the Official Scrabble Player's Dictionary, Second Edition. This word list has over 120,000 words, which should be more than enough for our purposes.

1. Prompt the user for a word length, re-prompting as necessary until they enter a number such that there's at least one word that's exactly that long. That is, if the user wants to play with words of length -42 or 137, since no English words are that long, you should re-prompt them.

2. Prompt the user for a number of guesses, which must be an integer greater than zero. Don't worry about unusually large numbers of guesses - after all, having more than 26 guesses is clearly not going to help your opponent!

3. Prompt the user for whether they want to have a running total of the number of words remaining in the word list. This completely ruins the illusion of a fair game that you'll be cultivating, but it's quite useful for testing 

4. Play the Word Guessing game as described below:

  • Construct a list of all words in the English language whose length matches the input length.
  • Print out how many guesses the user has remaining, along with any letters the player has guessed and the current blanked-out version of the word. If the user chose earlier to see the number of words remaining, print that out too.
  • Prompt the user for a single letter guess, re-prompting until the user enters a letter that she hasn't guessed yet. Make sure that the input is exactly one character long and that it's a letter of the alphabet.
  • Partition the words in the dictionary into groups by word category.
  • Choose a word category and remove all words from the word list that aren't in that category, and report the position of the letters (if any) to the user. If the word category doesn't contain any copies of the letter, subtract a remaining guess from the user.
  • If the player has run out of guesses, pick a word from the word list and display it as the word that the computer initially "chose."
  • If the player correctly guesses the word, congratulate them.
  • Ask if the user wants to play again and loop accordingly.

Attachment:- Assignment Files.rar

Reference no: EM131501963

Questions Cloud

Creating an annotated bibliography : Examine the steps needed to create an annotated bibliography and the types of material that should be included.
Effects and consequences of gun control : A well-regulated militia, being necessary to the security of a free state, the right of the people to keep and bear arms, shall not be infringed.
What are the difference of organized crime and terrorism : What are the differences and similarities of organized crime and terrorism?
Installed smoke management system : The property owner asks you what the firefighters smoke control station.
Build a program that bends the rules to trounce : 2807ICT Assignment. In this part of the  assignment, you will build a program that bends the rules to trounce its human opponent time and time again. In case you aren't familiar with the Word Guessing game
Multipurpose dry chemical portable fire extinguisher : Describe the inspection and testing for a multipurpose dry chemical portable fire extinguisher.
Is there any indication in your community : Is there any indication in your community, which drug organizations was responsible for bringing those drugs into the town?
Earth ozone layer and possible extinguishing agents : Describe how Halon (halogenated hydrocarbon) is harmful to the Earth's ozone layer and the possible extinguishing agents.
Evaluate the effect of expressed and implied terms : The parties entered an agreement whereby Scammell were to supply a van for £286 on Hire Purchase (HP) terms over 2 years.

Reviews

len1501963

5/20/2017 1:18:02 AM

You must actually write all Python code submitted in the PyLab environment. You must produce Word documents describing your code and the testing you have performed. This assignment can be done either individually or as a team of at most two students. The submission date is as specified in the Course Profile and the submission method will be communicated during semester.

Write a Review

Python Programming Questions & Answers

  Python program that reads in a series of positive integers

Write a Python program that reads in a series of positive integers and writes out theproduct of all the integers less than 25 and the sum of all the integers greater than or equal to 25. Use 0 as a sentinel value

  Create a cheat commands in the game so player can teleport

Create a cheat commands in the game so player can teleport to any location in the map - The first four tasks in this section can be completed by modifying only the code within the ProcessStatement() and Game() functions. This section typically requ..

  Write python code that will execute a list

Write python code that will execute a list of functions with supplied parameters and report the observed runtime for each function run. Assume that the input file has a list of strings like so:

  Implement core security features

What you will be implementing here is inspired by real world cases such as the Conficker work. To have any chance of defeating such a threat, you need to understand how they defend themselves.

  Write a python program that computes the mean, median, mode

How to write a python program that computes the mean, median, and mode?

  Write a program in python to draw a blue triangle

Write a program in Python to draw a blue triangle in a drawing window. Write a program in Python that moves the triangle in an animated movement. Write a program in Python to draw a simplified face.

  Write a program that asks for the user age

Write a program that asks for the user's age. Based on their response print "You can vote" (18 years old or older) or "You can't vote" and also whether or not he/she is a senior citizen (over 64)

  Write a program that asks the user for a letter

Write a program that asks the user for a letter - This function will take as input the original letter input by the user so that it can be included in the output sentence.

  Create an inheritance relationship between two classes

For this assignment you will create a simple class hierarchy. You will create an inheritance relationship between two classes -- a Friend class and a Person class - Friend will inherit Person

  Write a program in python to draw a simplified face

Write a program in Python to draw a blue triangle in a drawing window. Write a program in Python that moves the triangle in an animated movement. Write a program in Python to draw a simplified face.

  Programming exercise - routing of telephone

programming exercise - routing of telephone callsdescriptionsome telephone operators have submitted their price lists

  Create mini-python projects or programs

Your assignment is to create mini-Python projects or programs and to run them in the Python-IDLE environment

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