+static void
+rack_new_game (rack_t *rack)
+{
+ int i, bottom;
+ char word[MAX_TILES + 1];
+ int length = MAX_TILES;
+ int count;
+
+ /* 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--;
+ }
+ }