i’ve got a secret

I said before Hangman is about lists. One of those lists is a list of blank letters that represent the word the player is trying to guess. The easiest way to deal with this is to write a custom block that generates a list of as many blanks as there are letters in the word.

In programming, there are always several right ways, however, there are usually many more wrong ones. Here is one idea of what that custom block to make a list of blanks might look like.

Someone could also build a word of blanks and then use this block from the Import Tools to turn it into a list.

However you build the custom block to make your list of blanks, to say three blanks the script would look like this:

In Hangman, the list of <length> blanks block would the beginning of my display word, before any letters were guessed. If the word were cat it would be three letters. Or run.

To code it, I’d make a variable to store that list. and then replace the blanks with letters as they were guessed correctly.The list variable would belong to all sprites so the host could do the work of checking it and the assistant could do the work of saying it.

planning and implementation

One of the hardest lessons to learn is that it’s easier to work from a plan than to wing it. Most things that most people do most of the time don’t require a lot of planning or forethought because they’re repetitive tasks that have been done before. For example, I don’t make a plan to drive to my grocery store because I know the route, I know what I’m likely to encounter, etc.

The truth is, the first time, I didn’t know.  And when you’re creating a project, it’s the first time. When I go to a new place for the first time, I use Google to map it, I figure out how long it will take to get there so I can leave at the right time, I maybe even use the street view to see what the landmarks might be.  A planning worksheet is an equivalent for a software project.  It’s a way to break down the problem of how do I get from nothing to a solution in steps.

Depending on the complexity, a planning sheet will have different kinds of information but since Hangman is my current project, I’m going to frame this topic from that perspective.  There is a worksheet that was thoughtfully provided, but what if there hadn’t been?  What kinds of things would need to be on it?

Well, looking at the rubric, Hangman has to be able to do a lot of things. 

So any planning sheet has to account for that. Since this is Snap, there will be sprites and the stage.  Every script will belong to either a sprite or the stage so sprite ownership is something that needs to be part of the planning sheet.  Also, information will need to be stored. That means variables will be there, too.  I’ll need a column for pseudocode and a column for issues or pitfalls or whatever I want to call the potential snags I’ll run into.  This is not what the planning sheet looks like that was handed out.  
This is a matrix with two examples filled in. Kinda like a spreadsheet.  The first column is the rubric item and the rest are the columns I identified that I, as the project coder, would need to cut the project down to size.  Other people might see the project with different frameworks and have different columns.

The important thing is to have a plan.  And a planning sheet gives you a good place to create one. The better you plan, the less actual work you have to do (at least that’s the theory).  And in my experience, I’ve found it true often enough that I make it a habit to plan many facets of my life, not only my programming projects.

it’s all about the lists

Fundamentally, Hangman is a game of lists.  You have the alphabet, the list of letters that make up a secret word and a list of letters that have been guessed.

This is why it was chosen as the project for the list unit in our curriculum. Snap has a lot of blocks to deal with lists but if you use the import Tools, you get access to even more.  My favorites are andThe first one turns a word into a list and the second one turns a list into a sentence.  Both are useful for Hangman.