chiark / gitweb /
Minor improvement to initial loop generation.
authorSimon Tatham <anakin@pobox.com>
Sun, 11 Sep 2005 18:05:23 +0000 (18:05 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 11 Sep 2005 18:05:23 +0000 (18:05 +0000)
[originally from svn r6292]

loopy.c

diff --git a/loopy.c b/loopy.c
index f4d3e6ac6baa377d412a2f7d651bb8ee9f411ae8..42e7856f6319446b725d914108677c0a48b3263a 100644 (file)
--- a/loopy.c
+++ b/loopy.c
@@ -764,7 +764,16 @@ static char *new_fullyclued_board(game_params *params, random_state *rs)
         square = (struct square *)index234(lightable_squares_sorted, 0);
         assert(square);
 
-        if (square->score <= 0)
+       /*
+        * We never want to _decrease_ the loop's perimeter. Making
+        * moves that leave the perimeter the same is occasionally
+        * useful: if it were _never_ done then the user would be
+        * able to deduce illicitly that any degree-zero vertex was
+        * on the outside of the loop. So we do it sometimes but
+        * not always.
+        */
+        if (square->score < 0 || (square->score == 0 &&
+                                 random_upto(rs, 2) == 0))
             break;
 
         print_tree(lightable_squares_sorted);