[Top][All Lists]

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

[elpa] master 6fc8c7e: Reimplement mines-end-p

From: Tino Calancha
Subject: [elpa] master 6fc8c7e: Reimplement mines-end-p
Date: Thu, 25 Jan 2018 18:41:05 -0500 (EST)

branch: master
commit 6fc8c7eeb713bb265023d1c0e9c05efa21c6a349
Author: tino calancha <address@hidden>
Commit: tino calancha <address@hidden>

    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
 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 <address@hidden>
 ;; 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

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