Prog 5 Scramble

Updates shown in blue. Even more updates shown in green. Even even more shown in ? color.

Write a program that plays a game similar to Scrabble. You play against the computer and have to create words that are played on a 10 by 10 playing board. Each player receives 7 letter tiles, and as those tiles are played they are replenished from a set of 98 original tiles, until there are no more tiles left. The first word is placed anywhere on the board by the human player, and subsequent to that all words must be connected by only the first letter of the word to some letter already on the board. E

ach letter is worth only 1 point.

Playing the game looks like the following:

Welcome to the game of scramble, where you try to build English words on a board. The board itself is two dimensional, with rows marked by letters, and columns marked by numbers. A combination of row and column uniquely identify each square.

Each word you create (after the first one) must start with an existing letter on the board, and the subsequent letters must be played into blank squares. Words must be created out of the tiles you have in your "hand".

When a new word has letters adjacent to existing letters, you do not need to create valid words with those adjacent letters. One point is given per letter played. The winner is the player with the most points.

For each move you need to enter a row, a column, a move direction (a or d), and the word to be played at that spot. You may also enter 'X' to exit or 'H' for help. Input can be either upper or lower case.

E.g. "E3 d rap" puts the word "rap" starting at row E, column 3, going downwards.

Alternatively "E3 a rap" would put the word "rap" starting at row E, column 3, going across.

Please press the return key to continue...

 1 2 3 4 5 6 7 8 9 10  A . . . . . . . . . .  B . . . . . . . . . .  C . . . . . . . . . .  D . . . . . . . . . .  E . . . . . . . . . .  F . . . . . . . . . .  G . . . . . . . . . .  H . . . . . . . . . .  I . . . . . . . . . .  J . . . . . . . . . .                 Player             Computer     Tiles: A A V P P R R      I Q T C A R N    Scores:       0                  0    Enter row, column, move direction (a or d), and word.  You may also enter 'P' to pass, 'X' to exit or 'H' for help. --> b2 d rap    Best computer word found was: ARCTAN, played across starting at C2    1 2 3 4 5 6 7 8 9 10  A . . . . . . . . . .  B . R . . . . . . . .  C . A R C T A N . . .  D . P . . . . . . . .  E . . . . . . . . . .  F . . . . . . . . . .  G . . . . . . . . . .  H . . . . . . . . . .  I . . . . . . . . . .  J . . . . . . . . . .                 Player             Computer     Tiles: E A V A P E R      I Q R E E D N    Scores:       3                  6   

In the example shown above the human player chooses the word "rap" as the first move, starting at b2 and moving downwards. The computer then generates all permutations of it’s seven letter tiles (I Q T C A R N), prepended by each letter on the board. Each of these permutations is looked up in the dictionary, and the best (longest) word is remembered. In this case the best computer generated word was "arctan", which connects in to the "a" in "rap." Note that all words (after the first) must connect by only the first letter to a letter already on the board.

One point is given for each letter in a word that is played. Note that although the computer only puts down 5 of the 6 letters in "arctan," it gets six points, since the connecting "a" from "rap" also counts. Note what the board looks like a few turns later, after the human chooses

C5 d taper

and the computer responds with

B2 a render

1 2 3 4 5 6 7 8 9 10  A . . . . . . . . ..  B . R E N D E R . . .  C . A R C T A N . . .  D . P . . A . . . . .  E . . . . P . . . . .  F . . . . E . . . . .  G . . . . R . . . . .  H . . . . . . . . . .  I . . . . . . . . . .  J . . . . . . . . . . 

When the computer played "taper" going across starting ab b3, its letters end up adjacent to the letters in "arctan." The resulting adjacent letters do not need to form new words, as we see here.  Similarly the last letter of a word can be the starting letter of a new word, and the resulting longer word formed by the two individual words together need not be in the dictionary.  Thus in the diagram above the word "PEN" could be placed starting at D2 going downwards, but "RAPPEN" need not be in the dictionary.

Note that due to the use of the dictionary file as-is, it is not possible to type in plurals for a word unless they are already in the dictionary. There are also some abbreviations and names in the dictionary file that you would not necessarily expect when playing scrabble.

Recommendations

Notes:

Approximation of Grading Criteria (out of 55 points for execution)

Keep in mind for the following assignment (Program #6):

(You can totally ignore this section for now if you want to.)

The next (and last) program will likely look the same as this one when executing, but have differences "under the hood." It will probably include: