Skip to main content Link Menu Expand (external link) Copy Copied

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:

  1. You will be able to enter nonsensical words,
  2. You will not be able to correct mistakes (i.e., backspace will not work),
  3. You will be able enter the same word several times, and
  4. You won’t keep score.

We will remove these restrictions in a later assignment.

Restrictions

  1. You must not use substring or explode in this homework.

  2. You must use either BSL or ISL.

  3. You may only use the 2htdp/image and htdp/universe libraries.

  4. You must work on this homework with your assigned partner.

Directions

  1. 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.

  2. 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).

  3. 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.

  4. 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.

  5. 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.

  6. 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)))
    
  7. Revise your program to show the list of words that the player has found so far.