GHOST is a spelling game played by bored school kids on long car/bus rides. The purpose of the game it to accumulate letters that spell some word without ever actually finishing a word.Before the game begins, players agree on the order in which they will play. Plays proceed from one player to the next, returning then to the first player until the game is completed. Each player must, in turn, 1) extend the current "word", 2) bluff, or 3) challenge.
- The most common play is to extend the current sequence of letters by adding a single letter, so that the resulting sequence of letters forms the beginning of some word. For example, the first player might call "P", thinking (secretly) of the word "part". The second player might call "L", thinking of the word "play". The third player might call "E", thinking of the word "please".
A player loses if they actually complete a valid English word of 4 or more letters. For example, if there were only three players, after "PLE" the first player might try to extend the word by calling "A", thinking of the word "plead". This would, however, be a losing play because "plea" is a valid word.
- A player who cannot think of a valid letter to extend the current sequence may opt to "bluff" by calling out an arbitrary letter, hoping that the next player will not notice.
- Finally, if a player believes, on his turn, that the preceding player was bluffing or that the preceding player completed a word, he may challenge the preceding player. If all players agree that the current sequence completes a word (of at least 4 letters), the preceding player loses. If the preceding player cannot name a word that can be formed from the current sequence, the preceding player loses. If the current sequence is not a valid word and the preceding player is able to name a possible word beginning with the sequence, the challenger loses.
Write a program to serve as a player in a game of GHOST. Note that a skillful player will, on her turn, not only worry about coming up with a legal extension to the current sequence of letters, but will also think about all the words that could be formed from an extension and whether, comparing the number of letters in those words to the number of players, consider whether a possible extension could result in her getting stuck on a future turn with no legal extension that does not end a word, thus losing the game.