Marek Hlavac’s Hangman

I was going to post a different article today, but changed my mind after I received an e-mail form Marek Hlavac with a link to the game called Hangman, an adaptation of the classic paper and pencil game which he wrote using Stata.

I tried the game… lost my first 2 and won my next 3. It was a good break from work.

To play the game, you need two files: a Stata do-file ( and a Stata database of words to be guessed and their categories (hangman_data.dta). You may download these files here, where a Youtube demo is also available (view it in full screen for the texts to be readable).

If there is a way to incorporate sounds in it, it would be more fun.

Holidays are near (actually Christmas season started September here in the Philippines)… take a break… play Hangman. Merry Christmas!

8 Responses

  1. (Apologies for taking the discussion off-topic a bit, but) After posting the link to -dice- in my previous comment, I noticed from a -net describe- of the source site that they also have at least 2 other ‘teaching’ games listed there:

    a coin tossing demo

    Card playing simulation using buttons to shuffle cards, draw cards without replacement, draw cards with replacement, or play blackjack. After hitting the “Blackjack” button player may “Hit” or “Stand.”

    -card- sounds similar to my game, but I couldn’t get it to run. I got the error “control not allowed” r(101).
    I’ve received this same error before with user programs that use the -window control- commands (I use Stata 11 MP for Mac OSX) like -winshow- -winset- and -diablo- (found via -findit- and described here: ( My guess is that the -window control- commands once existed but have since been renamed or removed (?)

  2. Sorry, forgot to mention that you can get the program -dice- via:

    findit dice


    net install dice, ///
    from( ///
    replace all

  3. Very cool game, Marek. Based on Nick Cox’s response, I think the program -dice- probably qualifies as a game for Stata as well.

    Also, this post reminds me of a -blackjack- game I once wrote for Stata. I’m still new to Stata programming (and this was one of my first experiments with an adofile), so this game still has some bugs. Also, visually, my game is all over the place (Marek’s use of to subprograms to display the stages of the hangman is a great idea — it could have saved me a lot of copy/pasting of code to make my ‘cards’ for -blackjack-), but I still like to kill time with it every once and a while.
    I posted it to my site for those who come here with an interest in games for Stata:

  4. On the larger question of games in Stata, as usual much pivots on your definition of game.

    It’s salutary that the philosopher Ludwig Wittgenstein used the example of defining a game as a serious illustration of how tricky a definition can be.

    If to qualify as a game an activity must be frivolous, Hangman certainly seems to qualify.

    If a game can be something you play with for instruction (and possibly amusement) there are other examples in Stata, e.g. -chaos- and -irrepro- from SSC.

  5. @nick cox, oh great! it’s working already. thanks! :)

  6. runiform() is the name of the uniform random number generator as from Stata 10.1. Try using the name uniform() instead.

    This is _nothing_ to do with Mac as compared with other platforms.

  7. how come i can’t run the game using my MAC? this is the error that it is giving me “Unknown function runiform()”. any help? :)

  8. loveet! =D i really enjoyed it! quite nerdy, but fun! =D

Leave a Reply