+ obscure_entry = dict_lookup (obscure, word);
+ if (DICT_ENTRY_IS_WORD (obscure_entry))
+ *entry |= RACK_DICT_ENTRY_OBSCURE;
+}
+
+static void
+_at_least_one_is_not_obscure (void *closure, char *word, dict_entry_t *entry)
+{
+ int *result = closure;
+
+ if ((*entry & RACK_DICT_ENTRY_OBSCURE) == 0)
+ *result = 1;
+}
+
+static void
+rack_new_game (rack_t *rack)
+{
+ int i, bottom;
+ char word[MAX_TILES + 1];
+ int length = MAX_TILES;
+ int has_full_length_non_obscure_word;
+
+ /* We'll shuffle as many times as necessary until we can find a
+ * sequence of <length> letters with at least one full-length
+ * word. */
+ while (1) {
+ bag_shuffle (&rack->bag);
+
+ /* In this game, we're not interested in blank tiles, so first
+ * find any blanks and sort them to the bottom of the bag. */
+ i = 0;
+ bottom = BAG_SIZE - 1;
+ for (i = 0; i < bottom; i++) {
+ if (rack->bag.tiles[i] == '?') {
+ rack->bag.tiles[i] = rack->bag.tiles[bottom];
+ rack->bag.tiles[bottom] = '?';
+ bottom--;
+ /* Re-examine ith element */
+ i--;
+ }
+ }
+
+ /* Look at each successive run of tiles in the bag until
+ * finding one that has at least one non-obscure word using
+ * all of its leters. */
+ for (i = 0; i + length <= bottom + 1; i++) {
+ memcpy (word, &rack->bag.tiles[i], length);
+ word[length] = '\0';
+ dict_fini (&rack->solution);
+ dict_init (&rack->solution);
+ subanagram_expand (word, &rack->dict, &rack->solution);
+ dict_for_each (&rack->solution,
+ _flag_obscure_word, &rack->obscure);
+ has_full_length_non_obscure_word = 0;
+ dict_for_each_of_length (&rack->solution,
+ _at_least_one_is_not_obscure,
+ &has_full_length_non_obscure_word,
+ length, length);
+ if (has_full_length_non_obscure_word)
+ goto DONE;
+ i++;
+ }
+ }
+
+ DONE:
+ rack->solution_total = dict_count (&rack->solution);
+ goo_canvas_item_simple_changed (GOO_CANVAS_ITEM_SIMPLE (rack->solution_item), FALSE);