[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/mines 34d088c 34/43: Reimplement mines-end-p

From: Stefan Monnier
Subject: [elpa] externals/mines 34d088c 34/43: Reimplement mines-end-p
Date: Mon, 30 Nov 2020 18:44:19 -0500 (EST)

branch: externals/mines
commit 34d088c92427af72567113305a4ab7f46a03067a
Author: tino calancha <tino.calancha@gmail.com>
Commit: tino calancha <tino.calancha@gmail.com>

    Reimplement mines-end-p
    `mines-end-p' sometimes fails to detect a completed game.
    The current implemention checks for a sufficient but not
    necessary condition for the game to be completed.
    Assuming a board with N cells, with M of those cells
    (N > M) containing a mine; if the user already have
    uncovered N - M mine-free cells, then the game
    is completed.  That means is necessary and sufficient
    to check that
    M = 'number of uncovered cells' .
    * mines.el (mines-end-p): End game if the number of uncovered
    cells equals `mines-number-mines'.
    Problem reported by Rolf Ade here
 mines.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mines.el b/mines.el
index b82fa71..6ac8015 100644
--- a/mines.el
+++ b/mines.el
@@ -709,7 +709,7 @@ call this command again, the cell is unflagged."
 (defun mines-end-p ()
   "Return non-nil when the game is completed."
-  (equal mines-mine-positions (mines--find-pos nil mines-state)))
+  (= mines-number-mines (length (mines--find-pos nil mines-state))))
 (defun mines-first-move-p ()
   "Return non-nil if any cell has been revealed yet."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]