branch: master
commit 6fc8c7eeb713bb265023d1c0e9c05efa21c6a349
Author: tino calancha <tino.calan...@gmail.com>
Commit: tino calancha <tino.calan...@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' .
    
    Bump version to v1.6
    * mines.el (mines-end-p): End game if the number of uncovered
    cells equals `mines-number-mines'.
    
    Problem reported by Rolf Ade here
    https://github.com/calancha/Minesweeper/issues/2
---
 packages/mines/mines.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/packages/mines/mines.el b/packages/mines/mines.el
index b82fa71..00604ea 100644
--- a/packages/mines/mines.el
+++ b/packages/mines/mines.el
@@ -5,7 +5,7 @@
 ;; Author: Tino Calancha <tino.calan...@gmail.com>
 ;; Created: 2017-10-28
 ;; Keywords: games
-;; Version: 1.5
+;; Version: 1.6
 ;; Package-Requires: ((emacs "24.4") (cl-lib "0.5"))
 ;; url: https://github.com/calancha/Minesweeper
 
@@ -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