- gettimeofday (&tv, NULL);
- tv_stop = tv;
- tv_stop.tv_sec += GAME_LENGTH;
- remaining = GAME_LENGTH;
- do {
- minutes = remaining / 60;
- seconds = remaining % 60;
- sprintf (prompt, "%02d:%02d ", minutes, seconds);
- response = readline (prompt);
- add_history (response);
- chomp (response);
- if (strlen (response) == 0) {
- board_print (&board);
- } else {
- trie_t *t;
- t = trie_find (solution, response);
- if (t && (t->flags & TRIE_FLAGS_IS_WORD)) {
- if (t->flags & TRIE_FLAGS_SEEN)
- printf ("(repeat)\n");
- else
- t->flags |= TRIE_FLAGS_SEEN;
- } else {
- t = trie_find (dict.trie, response);
- if (t && (t->flags & TRIE_FLAGS_IS_WORD))
- printf ("(a good word, but it's not in the puzzle)\n");
- else
- printf ("*** %s is not a word\n", response);
- }
- }
- free (response);
- gettimeofday (&tv, NULL);
- remaining = floor (0.5 + (tv_stop.tv_sec - tv.tv_sec) + (tv_stop.tv_usec - tv.tv_usec) / 1000000.0);
- minutes = remaining / 60;
- } while (remaining > 0);
-
- printf ("\nWords you found:\n");
- string_init (&word);
- found = trie_print_seen (solution, &word);
- string_fini (&word);
- printf ("\n");
-
- printf ("\nWords you missed:\n");
- string_init (&word);
- missed = trie_print_unseen (solution, &word);
- string_fini (&word);
- printf ("\n");
-
- printf ("\nYou found %d of %d words (%.2f%%)\n",
- found, found + missed,
- 100 * (double) found / (found + missed));