Prevent starting in a solved state in Fifteen & Flood

(cherry picked from Android port, commit
cb38abdc71780bd9b393b90514396c338306fa69)
This commit is contained in:
Chris Boyle
2016-12-21 20:01:25 +00:00
committed by Ben Harris
parent 0d43753ff2
commit f967bfa87b
2 changed files with 78 additions and 69 deletions

View File

@ -552,8 +552,10 @@ static char *new_game_desc(const game_params *params, random_state *rs,
/*
* Invent a random grid.
*/
for (i = 0; i < wh; i++)
scratch->grid[i] = random_upto(rs, params->colours);
do {
for (i = 0; i < wh; i++)
scratch->grid[i] = random_upto(rs, params->colours);
} while (completed(w, h, scratch->grid));
/*
* Run the solver, and count how many moves it uses.