From f39a17cdae0c4c5986f8b3f12146910300727b63 Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 27 Oct 2023 17:52:17 +0200 Subject: [PATCH] add compile time flag 'FLAGALL_ON_CHOORD' when choording on an open cell, which has exactly the amount of closed cells around it as it has mines next to it, flag all of them. this is inspired by Lucas Nunes' Antimine. --- mines.c | 21 +++++++++++++++++++++ mines.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/mines.c b/mines.c index 68c01ec..837cbf9 100644 --- a/mines.c +++ b/mines.c @@ -284,6 +284,13 @@ int wait_mouse_up (int l, int c) { return ((l2 == l) && (c2 == c)); } +void flagall_square (int line, int col) { + AROUND(line,col) + if (AR_CELL.f != FLAG) { + flag_square(ROW, COL); + } +} + int choord_square (int line, int col) { AROUND(line,col) if (AR_CELL.f != FLAG) { @@ -358,6 +365,10 @@ int do_uncover (int* is_newgame, int actor) { if (uncover_square (g.p[0], g.p[1])) return GAME_LOST; } else if (get_neighbours (g.p[0], g.p[1], 1) == 0) { if (choord_square (g.p[0], g.p[1])) return GAME_LOST; +#ifdef FLAGALL_ON_CHOORD + } else if (HI_CELL.n == closed_neighbours(g.p[0], g.p[1])) { + flagall_square(g.p[0], g.p[1]); +#endif } else if (actor != MOUSE) { show_stomp(1, g.p[0], g.p[1]); @@ -676,6 +687,16 @@ int get_neighbours (int line, int col, int reduced_mode) { return count; } +int closed_neighbours (int line, int col) { + /* counts closed cells surrounding a square */ + + int count = 0; + AROUND(line, col) { + count += !AR_CELL.o; + } + return count; +} + void interactive_resize(void) { unsigned char buf[3]; int old_w = f.w; diff --git a/mines.h b/mines.h index f4e86ce..dc4a162 100644 --- a/mines.h +++ b/mines.h @@ -83,9 +83,11 @@ void show_minefield (int); void show_stomp (int, int, int); void wait_keypress (int); int get_neighbours (int, int, int); +int closed_neighbours (int, int); int uncover_square (int, int); void flag_square (int, int); void quesm_square (int, int); +void flagall_square (int, int); int choord_square (int, int); int do_uncover (int*, int); int grand_opening (int*); -- 2.39.3