mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Stop the Pattern grid generation from generating an entire row or
column of the same colour (at least when the dimensions are big enough to make this feasible). It's a little bit too easy otherwise! [originally from svn r5391]
This commit is contained in:
28
pattern.c
28
pattern.c
@ -417,6 +417,34 @@ static unsigned char *generate_soluble(random_state *rs, int w, int h)
|
||||
|
||||
generate(rs, w, h, grid);
|
||||
|
||||
/*
|
||||
* The game is a bit too easy if any row or column is
|
||||
* completely black or completely white. An exception is
|
||||
* made for rows/columns that are under 3 squares,
|
||||
* otherwise nothing will ever be successfully generated.
|
||||
*/
|
||||
ok = TRUE;
|
||||
if (w > 2) {
|
||||
for (i = 0; i < h; i++) {
|
||||
int colours = 0;
|
||||
for (j = 0; j < w; j++)
|
||||
colours |= (grid[i*w+j] == GRID_FULL ? 2 : 1);
|
||||
if (colours != 3)
|
||||
ok = FALSE;
|
||||
}
|
||||
}
|
||||
if (h > 2) {
|
||||
for (j = 0; j < w; j++) {
|
||||
int colours = 0;
|
||||
for (i = 0; i < h; i++)
|
||||
colours |= (grid[i*w+j] == GRID_FULL ? 2 : 1);
|
||||
if (colours != 3)
|
||||
ok = FALSE;
|
||||
}
|
||||
}
|
||||
if (!ok)
|
||||
continue;
|
||||
|
||||
memset(matrix, 0, w*h);
|
||||
|
||||
do {
|
||||
|
Reference in New Issue
Block a user