Mystery Song Game

In this activity, you will use your mystery song block to create a game.

There are command block versions of two blocks you've already seen:

  1. If your project isn't open already, log in to Snap!, and open your "Song Player" project.
  2. I cant find the ask block :( I think it has to be in the song player project blocks microworld. -pf 3/3/22

    This needs to be fixed in all XML files, but for now, I fixed the starter file and added this takeNote box to help anyone who has already saved the problem project. --MF, 3/6/22
    I now realize it's missing the "say" block(s). I also think it’d be nice to have the “When flag clicked” block so a student can share a code-less version of the project (otherwise you can see the answer in the code on the left). -pf 3/6/22

  3. Create a script that plays your mystery song, asks the user what song they think it is, and then tells them whether they are right or wrong.

    Is your project missing the say (), ask () and wait and answer blocks?

    There was a mistake! If these blocks are not in your project, go back to the first activity, press and hold the shift key while you reload the page, open the project in exercise #2, choose "Save As..." from the Snap! File menu, and save with a new name (so you don't lose your prior work).

    I think this is a little tricky. How's the following for scaffolding? At the last focus group, we got the message that some kids do better with more scaffolding than we are giving and that teachers' CS goals for middle school prioritize engagement over formal CS content which will occur in HS if we hook them now. They were convincing, and I added a final hint here. --MF, 2/11/22

    Here you talk about SAY, but in the third hint the picture uses SAY FOR __ SECS. You should decide which. I think plain SAY is fine for this purpose. --bh 3/3/22

    Agreed. To resolve next year. --MF, 3/6/22

    You can use ask and wait to ask the user a question (and store their response), and you can use say () to tell the user something that isn't a question.

    Click for another hint.

    The script for your game needs to do three things:

    1. Play your mystery song
    2. Ask the user to guess the song
    3. Tell the player whether the guess is correct

    Click for a third hint.

    Use the if else command block to test whether the guess is correct with a predicate like (answer) = ('Stronger'). If the guess is correct, then use say to tell the user they are correct; if it's not correct, then use say to tell them that.

    Click for a fourth hint.

    Try making code that's something like this:
    partial script with the code:
ask ('What was that song?') and wait
if ((answer) = ('Twinkle Twinkle Little Star')) {
	say ('Correct!') for (2) secs
} else {
	say ('Try again!') for (2) secs
}

  4. Now Is a Good Time to Save

Cut for now. I believe some of this was here at Dan's request, so I'm not cutting without more attention. --MF, 3/6/22

I'm not sure what you expect them to do here. If the idea is that they nest another IF ELSE in the else clause of the first one, that's a whole new idea, and one students find hard, not appropriate for an ITIT. I'm not sure this is salvageable, but it might be with a serious rewriting. --bh 3/3/22

I assumed it was just using an or. Maybe should explicitly suggest using the or block. You can also say "to allow the user to be correct with different variations on the song title", which is different from having to implement a spell checker (a quite difficult task, as 61A students will attest this semester!). -pf 3/3/22

I made this a TIF for now. (And then I cut it.) ;) --MF, 3/6/22

  1. Use a second if else block and predicate (hexagonal testing function) to allow the user to be correct even with a different variation of the spelling of the song. For example, you might want the game to approve either "The Alphabet Song" or "Alphabet."
  2. If you created two mystery songs, you could make a new command block that randomly chooses which one to play by using random together with if else.
  3. I like this idea, but I don't see a way to do more than two mystery songs with the blocks they know at this point (e.g., not global or script variables---globals are taught later in this lab). Am I missing anything? --MF, 2/10/22

    I don't understand the question. How can they do even two songs? Presumably by putting the two song scripts in the slots of the IF ELSE. Well, if they can do that, they can nest two IF ELSE blocks, as in the ITIT above, and that gives them three slots for songs, etc. --bh 3/3/22

    I also don't know how to do this without using some variable to track which song they ended up picking and asking about, since we need that to happen before the if/else that checks the answer. Ah okay well I guess you can have the if condition be a random number between 1 and length of songs, and then inside the if/else clause, it plays the song and asks them for their guess, but then I bet they'll end up repeating all that ask-code and it'll be gross. I feel like doing this cleanly is hard. --pf 3/3/22

In this activity, you used the command if else to control what the game says to the player.