// A simple ascii game of hangman. include 'lib' array of string words = ( "spider", "investigate", "wonder", "library", "sparrow", "fiction", "experience", "flowers", "beetle", "muffin", "television", "refrigerator", "waterfall", "museum", "butterfly", "juice", "computer", "picture", "astronomy", "charcoal", "springtime", "archive", "musical", "jewelry", "flight", "comfortable", "kangaroo", "willow", "melody", "underneath", "related", ); /* Pick our word randomly from list. */ randInit(); string word = words[lib.randomIx(words.size)]; // This is a comment. int maxWrong = 11; /* Print out instructions. */ print("Let's play hangman. You can get " + maxWrong + " letters wrong:"); /* Keep track of the parts of word we've guessed and # of guesses. */ array[word.size] of bit guessed; int wrongCount = 0; string guesses = ""; /* The main game loop. */ for (;;) { /* Create a string that is dashes where we haven't guessed the * word yet. */ string s = word.dupe(); for (int i=0; i= maxWrong) { print("Sorry, after " + maxWrong + " wrong guesses you are hung on " + word + "!"); break; } } }