Add SAFE state to indicate un-probed safe tile
This commit is contained in:
parent
3d4cfc7a0c
commit
49417b4840
3
main.c
3
main.c
@ -68,7 +68,8 @@ static update_res_t update(state_t *state, int *x_out, int *y_out)
|
||||
|
||||
for (int y = 0; y < HEIGHT; ++y) {
|
||||
for (int x = 0; x < WIDTH; ++x) {
|
||||
if (state->field[x][y] == UNKNOWN || state->field[x][y] == MINE)
|
||||
if (state->field[x][y] == UNKNOWN || state->field[x][y] == MINE
|
||||
|| state->field[x][y] == SAFE)
|
||||
continue;
|
||||
|
||||
const int mines = countadj(state->field, x, y, MINE);
|
||||
|
14
puzz.c
14
puzz.c
@ -106,8 +106,18 @@ status_t check(puzz_t puzz)
|
||||
{
|
||||
for (int y = 0; y < HEIGHT; ++y) {
|
||||
for (int x = 0; x < WIDTH; ++x) {
|
||||
if (puzz[x][y] != UNKNOWN && puzz[x][y] != soln[x][y])
|
||||
return INCORRECT;
|
||||
switch (puzz[x][y]) {
|
||||
case UNKNOWN:
|
||||
continue;
|
||||
case SAFE:
|
||||
if (soln[x][y] == MINE)
|
||||
return INCORRECT;
|
||||
break;
|
||||
default:
|
||||
if (puzz[x][y] != soln[x][y])
|
||||
return INCORRECT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user