aboutsummaryrefslogtreecommitdiff
path: root/flood.c
diff options
context:
space:
mode:
authorChris Boyle <chris@boyle.name>2016-12-21 20:01:25 +0000
committerBen Harris <bjh21@bjh21.me.uk>2022-12-16 23:55:15 +0000
commitf967bfa87b6ea08434501558e0c41184fdce333d (patch)
tree5266db8461a2499e8280f01f44de6c8f948263f4 /flood.c
parent0d43753ff2e02f54dd35e6872be3dafa14d2ea7d (diff)
downloadpuzzles-f967bfa87b6ea08434501558e0c41184fdce333d.zip
puzzles-f967bfa87b6ea08434501558e0c41184fdce333d.tar.gz
puzzles-f967bfa87b6ea08434501558e0c41184fdce333d.tar.bz2
puzzles-f967bfa87b6ea08434501558e0c41184fdce333d.tar.xz
Prevent starting in a solved state in Fifteen & Flood
(cherry picked from Android port, commit cb38abdc71780bd9b393b90514396c338306fa69)
Diffstat (limited to 'flood.c')
-rw-r--r--flood.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/flood.c b/flood.c
index 80f2ff6..eeca88b 100644
--- a/flood.c
+++ b/flood.c
@@ -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.