- for (i=0; i < 17; i++) {
- found[i] = 0;
- possible[i] = 0;
- }
- _count_possible (dict_root (&solution), 0, possible);
- found_total = 0;
- possible_total = 0;
- for (i=0; i < 17; i++)
- possible_total += possible[i];
-
- board_print (&board);
- just_saw_board = TRUE;
-
- 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);
- if (strlen (response) == 0) {
- if (! just_saw_board) {
- board_print (&board);
- just_saw_board = TRUE;
- } else {
- for (i = 2; i <= 17; i++)
- if (possible[i])
- printf ("%d: (%d/%d) ", i, found[i], possible[i]);
- printf ("total: (%d/%d = %.2f%%)\n",
- found_total, possible_total,
- 100 * (double) found_total / possible_total);
- }
- } else {
- dict_entry_t *entry;
- just_saw_board = FALSE;
- if (response[strlen (response) - 1] == '\n')
- response[strlen (response) - 1] = '\0';
- entry = dict_lookup (&solution, response);
- if (DICT_ENTRY_IS_WORD (entry)) {
- if (*entry & GRID_WORD_SEEN) {
- printf ("(repeat)\n");
- } else {
- *entry |= GRID_WORD_SEEN;
- found [strlen (response)]++;
- found_total++;
- }
- } else {
- entry = dict_lookup (&dict, response);
- if (DICT_ENTRY_IS_WORD (entry))
- 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);
-
- board_print (&board);
-
- printf ("Words you found:\n");
- dict_print_by_length_if (&solution, seen_predicate);
-
- printf ("\nWords you missed:\n");
- dict_print_by_length_if (&solution, unseen_predicate);
- printf ("\n");
-
- printf ("You found %d of %d words (%.2f%%)\n",
- found_total, possible_total,
- 100 * (double) found_total / possible_total);