chiark / gitweb /
Filling: fix assertion failure in 3x1 game generation.
authorSimon Tatham <anakin@pobox.com>
Sun, 14 Mar 2021 22:05:23 +0000 (22:05 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 29 Mar 2021 19:57:42 +0000 (20:57 +0100)
This would come up on the game id "3x1#12345", for example. The
failing assertion was (s->board[f] != EMPTY) in expand(), called in
turn from learn_expand_or_one().

It looks as if the problem was that the #define SENTINEL was set too
small. It was intended to be a value that can't coincide with the true
size of any region - and it was set to precisely the area of the whole
board. But on a 3x1 grid, that _can_ coincide with the size of a
region! So a board entry was set to a real region size, and then
mistaken for SENTINEL by another part of the code.

Easy fix: set SENTINEL to be sz+1. Now it really can't coincide with a
region area.

filling.c

index 3231384084cee1e5c1a4e27004dea690cbbd77ca..a62161a25b12d577064da273c15debcc03a29fed 100644 (file)
--- a/filling.c
+++ b/filling.c
@@ -310,7 +310,7 @@ static void print_board(int *board, int w, int h) {
 static game_state *new_game(midend *, const game_params *, const char *);
 static void free_game(game_state *);
 
-#define SENTINEL sz
+#define SENTINEL (sz+1)
 
 static bool mark_region(int *board, int w, int h, int i, int n, int m) {
     int j;