For this assignment, you will write a program that simulates playing a board game with 4 players. The players each have 8 tiles with which to construct words. The object of the game is to see who can construct the most words with their tiles. If two (or more) players can construct an equal number of words, then randomly select a winner from the players who have tied on the most words. Write a program that simulates the game.

The file GameTiles.txt contains all of the tiles needed for the game. The file lists a letter and then how many tiles exist that contain that letter. Read the information from the file into a dictionary. Use the information from that dictionary to "deal" a tile to each player (one at a time: first deal a tile to player1, then to player2, then to player3, then to player4. Then repeat that process until all players have 8 tiles each). The eight tile represents the players "hand". Remember, you cannot deal out more tiles than exists in the dictionary. For example, there is only one 'X' tile, thus only one person could possibly have this tile in their hand.

Next you need to find all of the words that can be made with the 8 tiles for each player. Because the same tasks will be done for each player's hand, you should create a function to perform this task. The function can call other functions if you like. The CROSSWD.TXT file contains all of the official words that can be created by the players. You will also need to a dictionary containing all letters and their point values:

scores = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, "l": 1, "o": 1, "n": 1, "q": 11, "p": 3, "s": 1, "r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, "x": 8, "z": 10}

Find all of the valid words that can be made from the CROSSWD.TXT file using only the tiles available in each players hand. Make sure you are consistent about capitalization. Make sure you handle repeat letters: once a letter from the rack has been used, it can't be used again. Finally, write the code to determine the scores for each valid word, using the scores dictionary from above. Then display each player's hand and list of words (with each word's score). An example input and output for a player is as follows:

Player 1's hand: ZAEFIEEC
Word Scores and Words

1: feeze - 17 points
2: feaze - 17 points
3: faze - 16 points
4: fiz - 15 points
5: fez - 15 points
6: zee - 12 points
7: fice - 9 points
8: face - 9 points
9: cafe - 9 points
10: fie - 6 points
11: fee - 6 points
12: if - 5 points
13: ice - 5 points
14: fa - 5 points
15: ef - 5 points
16: cee - 5 points
17: ace - 5 points
18: ai - 2 points
19: ae - 2 points

Lastly, you need to determine and congratulate the winner. The player who was able to contruct the most words wins. If there is a tie, then randomly select a winner from the players who tied. Hint: consider using lists to keep track of wining players.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.