Mini Spelling Bee
Spelling Bee is a vocabulary game hosted by the New York Times. The project for this class is to build a program similar to Spelling Bee over the course of several homework assignments. Before reading any further, you should quickly play the New York Times’ Spelling Bee to understand the rules of the game.
Your first version of Spelling Bee, which you will design for this assignment, will make several simplifications:
- You will be able to enter nonsensical words,
- You will not be able to correct mistakes (i.e., backspace will not work),
- You will be able enter the same word several times, and
- You won’t keep score.
We will remove these restrictions in a later assignment.
Restrictions
-
You must not use
substring
orexplode
in this homework. -
You must use either BSL or ISL.
-
You may only use the
2htdp/image
andhtdp/universe
libraries. -
You must work on this homework with your assigned partner.
Directions
-
Design data called
Letters
that holds the letters that are available for your simplified Spelling Bee. Note that one of the letters is distinguished as the required letter (i.e., the letter displayed at the center).While there must be a distinguished center letter, your data definition must also support arbitrary many other letters.
-
Design a function called
letters->image
` to display the letters. The required letter must be distinguished in some way (e.g., by position, color, font, etc). -
A game of Spelling Bee must track the available letters and the partial word that the player has entered. Design data called
World
that holds this data. -
Design a function called
world->image
that displays a world. You can produce any image that you like, but it should clearly show both the available letters and the partial word. -
In a game of Spelling Bee, the player can either enter a letter to add to the current word, or press the “Enter” key to complete the word. Design a function with the following signature:
key-pressed : World KeyEvent -> World
When the key is an available letter,
key-pressed
should produce a new world that adds that letter to the end of the current word. If the key is not an available letter, it should produce the previous world. If the key is the special string"\r"
(which stands for the Enter key), it should produce a new world with the empty string for the current word, as long as the current word contains the center letter. If the player presses any other key, produce the previous world unchanged. In other words, your program should not produce an error if the player presses the “wrong” key. -
At this point, you have enough in place to play a basic game. Use the following world program to play spelling bee.
;; play : World -> World ;; ;; Uses big-bang to play a game of Spelling Bee, given Letters. (define (play w) (big-bang w (to-draw world->image) (on-key key-pressed)))
-
Revise your program to show the list of words that the player has found so far.