Mercurial > emacs
annotate lisp/play/mpuz.el @ 64737:bae6ce9731e6
Add missing 2005-06-28 entry for progmodes/compile.el.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Sat, 06 Aug 2005 00:48:18 +0000 |
parents | 34bd8e434dd7 |
children | fb2cad4cfb30 edf295560b5a |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
232
diff
changeset
|
1 ;;; mpuz.el --- multiplication puzzle for GNU Emacs |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
232
diff
changeset
|
2 |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1990, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
838 | 4 |
19963 | 5 ;; Author: Philippe Schnoebelen <phs@lsv.ens-cachan.fr> |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
6 ;; Overhauled: Daniel Pfeiffer <occitan@esperanto.org> |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
7 ;; Keywords: games |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
8 |
142 | 9 ;; This file is part of GNU Emacs. |
10 | |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
14 ;; any later version. |
142 | 15 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
19 ;; GNU General Public License for more details. |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
20 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
4400
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
142 | 25 |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1217
diff
changeset
|
26 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1217
diff
changeset
|
27 |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
28 ;; `M-x mpuz' generates a random multiplication puzzle. This is a |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
29 ;; multiplication example in which each digit has been consistently replaced |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
30 ;; with some letter. Your job is to reconstruct the original digits. Type |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
31 ;; `?' while the mode is active for detailed help. |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1217
diff
changeset
|
32 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
33 ;;; Code: |
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
34 |
21363 | 35 (defgroup mpuz nil |
36 "Multiplication puzzle." | |
37 :prefix "mpuz-" | |
38 :group 'games) | |
39 | |
142 | 40 (random t) ; randomize |
41 | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
42 (defcustom mpuz-silent 'error |
50861
0d21b78dd68e
(mpuz-silent): Don't quote nil and t in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
45113
diff
changeset
|
43 "*Set this to nil if you want dings on inputs. |
0d21b78dd68e
(mpuz-silent): Don't quote nil and t in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
45113
diff
changeset
|
44 t means never ding, and `error' means only ding on wrong input." |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
45 :type '(choice (const :tag "No" nil) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
46 (const :tag "Yes" t) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
47 (const :tag "If correct" error)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
48 :group 'mpuz) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
49 |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
50 (defcustom mpuz-solve-when-trivial t |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
51 "*Solve any row that can be trivially calculated from what you've found." |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
52 :type 'boolean |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
53 :group 'mpuz) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
54 |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
55 (defcustom mpuz-allow-double-multiplicator nil |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
56 "*Allow 2nd factors like 33 or 77." |
21363 | 57 :type 'boolean |
58 :group 'mpuz) | |
142 | 59 |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
60 (defface mpuz-unsolved |
43825
5f6458644514
Use defface instead of facemenu-get-face.
Eli Zaretskii <eliz@gnu.org>
parents:
43770
diff
changeset
|
61 '((((class color)) (:foreground "red1" :bold t)) |
5f6458644514
Use defface instead of facemenu-get-face.
Eli Zaretskii <eliz@gnu.org>
parents:
43770
diff
changeset
|
62 (t (:bold t))) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
63 "*Face to use for letters to be solved." |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
64 :group 'mpuz) |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
65 ;; backward-compatibility alias |
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
66 (put 'mpuz-unsolved-face 'face-alias 'mpuz-unsolved) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
67 |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
68 (defface mpuz-solved |
43825
5f6458644514
Use defface instead of facemenu-get-face.
Eli Zaretskii <eliz@gnu.org>
parents:
43770
diff
changeset
|
69 '((((class color)) (:foreground "green1" :bold t)) |
5f6458644514
Use defface instead of facemenu-get-face.
Eli Zaretskii <eliz@gnu.org>
parents:
43770
diff
changeset
|
70 (t (:bold t))) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
71 "*Face to use for solved digits." |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
72 :group 'mpuz) |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
73 ;; backward-compatibility alias |
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
74 (put 'mpuz-solved-face 'face-alias 'mpuz-solved) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
75 |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
76 (defface mpuz-trivial |
43825
5f6458644514
Use defface instead of facemenu-get-face.
Eli Zaretskii <eliz@gnu.org>
parents:
43770
diff
changeset
|
77 '((((class color)) (:foreground "blue" :bold t)) |
5f6458644514
Use defface instead of facemenu-get-face.
Eli Zaretskii <eliz@gnu.org>
parents:
43770
diff
changeset
|
78 (t (:bold t))) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
79 "*Face to use for trivial digits solved for you." |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
80 :group 'mpuz) |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
81 ;; backward-compatibility alias |
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
82 (put 'mpuz-trivial-face 'face-alias 'mpuz-trivial) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
83 |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
84 (defface mpuz-text |
43825
5f6458644514
Use defface instead of facemenu-get-face.
Eli Zaretskii <eliz@gnu.org>
parents:
43770
diff
changeset
|
85 '((t (:inherit variable-pitch))) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
86 "*Face to use for text on right." |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
87 :group 'mpuz) |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
88 ;; backward-compatibility alias |
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
89 (put 'mpuz-text-face 'face-alias 'mpuz-text) |
142 | 90 |
91 | |
92 ;; Mpuz mode and keymaps | |
93 ;;---------------------- | |
21363 | 94 (defcustom mpuz-mode-hook nil |
95 "Hook to run upon entry to mpuz." | |
96 :type 'hook | |
97 :group 'mpuz) | |
142 | 98 |
99 (defvar mpuz-mode-map nil | |
100 "Local keymap to use in Mult Puzzle.") | |
101 | |
102 (if mpuz-mode-map nil | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
103 (setq mpuz-mode-map (make-sparse-keymap)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
104 (define-key mpuz-mode-map "a" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
105 (define-key mpuz-mode-map "b" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
106 (define-key mpuz-mode-map "c" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
107 (define-key mpuz-mode-map "d" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
108 (define-key mpuz-mode-map "e" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
109 (define-key mpuz-mode-map "f" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
110 (define-key mpuz-mode-map "g" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
111 (define-key mpuz-mode-map "h" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
112 (define-key mpuz-mode-map "i" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
113 (define-key mpuz-mode-map "j" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
114 (define-key mpuz-mode-map "A" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
115 (define-key mpuz-mode-map "B" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
116 (define-key mpuz-mode-map "C" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
117 (define-key mpuz-mode-map "D" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
118 (define-key mpuz-mode-map "E" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
119 (define-key mpuz-mode-map "F" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
120 (define-key mpuz-mode-map "G" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
121 (define-key mpuz-mode-map "H" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
122 (define-key mpuz-mode-map "I" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
123 (define-key mpuz-mode-map "J" 'mpuz-try-letter) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
124 (define-key mpuz-mode-map "\C-g" 'mpuz-offer-abort) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
125 (define-key mpuz-mode-map "?" 'describe-mode)) |
142 | 126 |
127 (defun mpuz-mode () | |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
128 "Multiplication puzzle mode. |
142 | 129 |
232 | 130 You have to guess which letters stand for which digits in the |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
131 multiplication displayed inside the `*Mult Puzzle*' buffer. |
142 | 132 |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
133 You may enter a guess for a letter's value by typing first the letter, |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
134 then the digit. Thus, to guess that A=3, type `A 3'. |
142 | 135 |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
136 To leave the game to do other editing work, just switch buffers. |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
137 Then you may resume the game with M-x mpuz. |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
138 You may abort a game by typing \\<mpuz-mode-map>\\[mpuz-offer-abort]." |
142 | 139 (interactive) |
62770 | 140 (kill-all-local-variables) |
142 | 141 (setq major-mode 'mpuz-mode |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
142 mode-name "Mult Puzzle" |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
143 tab-width 30) |
142 | 144 (use-local-map mpuz-mode-map) |
62770 | 145 (run-mode-hooks 'mpuz-mode-hook)) |
142 | 146 |
147 | |
148 ;; Some variables for statistics | |
149 ;;------------------------------ | |
150 (defvar mpuz-nb-errors 0 | |
232 | 151 "Number of errors made in current game.") |
142 | 152 |
153 (defvar mpuz-nb-completed-games 0 | |
232 | 154 "Number of games completed.") |
142 | 155 |
156 (defvar mpuz-nb-cumulated-errors 0 | |
157 "Number of errors made in previous games.") | |
158 | |
159 | |
160 ;; Some variables for game tracking | |
161 ;;--------------------------------- | |
162 (defvar mpuz-in-progress nil | |
163 "True if a game is currently in progress.") | |
164 | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
165 (defvar mpuz-found-digits (make-bool-vector 10 nil) |
142 | 166 "A vector recording which digits have been decrypted.") |
167 | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
168 (defvar mpuz-trivial-digits (make-bool-vector 10 nil) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
169 "A vector recording which digits have been solved for you.") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
170 |
142 | 171 (defmacro mpuz-digit-solved-p (digit) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
172 `(or (aref mpuz-found-digits ,digit) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
173 (aref mpuz-trivial-digits ,digit))) |
142 | 174 |
175 | |
176 ;; A puzzle uses a permutation of [0..9] into itself. | |
177 ;; We use both the permutation and its inverse. | |
178 ;;--------------------------------------------------- | |
179 (defvar mpuz-digit-to-letter (make-vector 10 0) | |
180 "A permutation from [0..9] to [0..9].") | |
181 | |
182 (defvar mpuz-letter-to-digit (make-vector 10 0) | |
183 "The inverse of mpuz-digit-to-letter.") | |
184 | |
185 (defmacro mpuz-to-digit (letter) | |
186 (list 'aref 'mpuz-letter-to-digit letter)) | |
187 | |
188 (defmacro mpuz-to-letter (digit) | |
189 (list 'aref 'mpuz-digit-to-letter digit)) | |
190 | |
191 (defun mpuz-build-random-perm () | |
192 "Initialize puzzle coding with a random permutation." | |
193 (let ((letters (list 0 1 2 3 4 5 6 7 8 9)) ; new cons cells, because of delq | |
194 (index 10) | |
195 elem) | |
196 (while letters | |
4400 | 197 (setq elem (nth (random index) letters) |
142 | 198 letters (delq elem letters) |
199 index (1- index)) | |
200 (aset mpuz-digit-to-letter index elem) | |
201 (aset mpuz-letter-to-digit elem index)))) | |
202 | |
203 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
2451
diff
changeset
|
204 ;; A puzzle also uses a board displaying a multiplication. |
142 | 205 ;; Every digit appears in the board, crypted or not. |
206 ;;------------------------------------------------------ | |
207 (defvar mpuz-board (make-vector 10 nil) | |
4345
49e68bc65e26
* mpuz.el (mpuz-board): Doc fix.
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
208 "The board associates to any digit the list of squares where it appears.") |
142 | 209 |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
210 (defun mpuz-put-number-on-board (number row &rest l) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
211 "Put (last digit of) NUMBER on ROW and COLUMNS of the puzzle board." |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
212 (let (digit) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
213 (while l |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
214 (setq digit (% number 10) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
215 number (/ number 10)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
216 (aset mpuz-board digit `((,row . ,(car l)) ,@(aref mpuz-board digit))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
217 (setq l (cdr l))))) |
142 | 218 |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
219 (defun mpuz-check-all-solved (&optional row col) |
142 | 220 "Check whether all digits have been solved. Return t if yes." |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
221 (catch 'solved |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
222 (let (A B1 B2 C D E squares) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
223 (and mpuz-solve-when-trivial |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
224 (not row) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
225 (while |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
226 (cond ((or (and (setq B1 (or B1 (mpuz-check-all-solved 4 7)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
227 B2 (or B2 (mpuz-check-all-solved 4 9)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
228 E (or E (mpuz-check-all-solved 10)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
229 A (or A (mpuz-check-all-solved 2))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
230 B1 B2) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
231 (and E (or A (and B1 B2)))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
232 (mpuz-solve) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
233 (mpuz-paint-board) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
234 (throw 'solved t)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
235 ((and (setq D (or D (mpuz-check-all-solved 8)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
236 C (or C (mpuz-check-all-solved 6))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
237 D (not E)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
238 (mpuz-solve 10)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
239 ((and E (not (eq C D))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
240 (mpuz-solve (if D 6 8))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
241 ((and A (not (eq B2 C))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
242 (mpuz-solve (if C 4 6) (if C 9))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
243 ((and A (not (eq B1 D))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
244 (mpuz-solve (if D 4 8) (if D 7))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
245 ((and (not A) (or (and B2 C) (and B1 D))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
246 (mpuz-solve 2))))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
247 (mpuz-paint-board) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
248 (mapc (lambda (digit) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
249 (and (not (mpuz-digit-solved-p digit)) ; unsolved |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
250 (setq squares (aref mpuz-board digit)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
251 (if row |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
252 (if col |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
253 (member (cons row col) squares) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
254 (assq row squares)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
255 squares) ; and appearing in the puzzle! |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
256 (throw 'solved nil))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
257 [0 1 2 3 4 5 6 7 8 9])) |
142 | 258 t)) |
259 | |
260 | |
261 ;; To build a puzzle, we take two random numbers and multiply them. | |
262 ;; We also take a random permutation for encryption. | |
263 ;; The random numbers are only use to see which digit appears in which square | |
264 ;; of the board. Everything is stored in individual squares. | |
265 ;;--------------------------------------------------------------------------- | |
266 (defun mpuz-random-puzzle () | |
267 "Draw random values to be multiplied in a puzzle." | |
268 (mpuz-build-random-perm) | |
269 (fillarray mpuz-board nil) ; erase the board | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
270 ;; A,B,C,D & E, are the five rows of our multiplication. |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
271 ;; Choose random values, discarding cases with leading zeros in C or D. |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
272 (let* ((A (+ 112 (random 888))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
273 (min (1+ (/ 1000 A))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
274 (B1 (+ min (random (- 10 min)))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
275 B2 C D E) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
276 (while (if (= B1 (setq B2 (+ min (random (- 10 min))))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
277 (not mpuz-allow-double-multiplicator))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
278 (setq C (* A B2) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
279 D (* A B1) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
280 E (+ C (* D 10))) |
14040 | 281 ;; Individual digits are now put on their respective squares. |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
282 ;; [NB: A square is a pair (row . column) of the screen.] |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
283 (mpuz-put-number-on-board A 2 9 7 5) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
284 (mpuz-put-number-on-board (+ (* B1 10) B2) 4 9 7) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
285 (mpuz-put-number-on-board C 6 9 7 5 3) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
286 (mpuz-put-number-on-board D 8 7 5 3 1) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
287 (mpuz-put-number-on-board E 10 9 7 5 3 1))) |
142 | 288 |
289 ;; Display | |
290 ;;-------- | |
291 (defconst mpuz-framework | |
292 " | |
293 . . . | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
294 Number of errors (this game): 0 |
142 | 295 x . . |
296 ------- | |
297 . . . . | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
298 Number of completed games: 0 |
142 | 299 . . . . |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
300 --------- Average number of errors: 0.00 |
142 | 301 . . . . ." |
302 "The general picture of the puzzle screen, as a string.") | |
303 | |
304 (defun mpuz-create-buffer () | |
305 "Create (or recreate) the puzzle buffer. Return it." | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
306 (let ((buf (get-buffer-create "*Mult Puzzle*")) |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
307 (face '(face mpuz-text)) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
308 buffer-read-only) |
142 | 309 (save-excursion |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
310 (set-buffer buf) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
311 (erase-buffer) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
312 (insert mpuz-framework) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
313 (set-text-properties 13 42 face) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
314 (set-text-properties 79 105 face) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
315 (set-text-properties 128 153 face) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
316 (mpuz-paint-board) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
317 (mpuz-paint-errors) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
318 (mpuz-paint-statistics)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
319 buf)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
320 |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
321 (defun mpuz-paint-number (n &optional eol words) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
322 (end-of-line eol) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
323 (let (buffer-read-only) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
324 (delete-region (point) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
325 (progn (backward-word (or words 1)) (point))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
326 (insert n))) |
142 | 327 |
328 (defun mpuz-paint-errors () | |
329 "Paint error count on the puzzle screen." | |
330 (mpuz-switch-to-window) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
331 (goto-line 3) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
332 (mpuz-paint-number (prin1-to-string mpuz-nb-errors))) |
142 | 333 |
334 (defun mpuz-paint-statistics () | |
335 "Paint statistics about previous games on the puzzle screen." | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
336 (goto-line 7) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
337 (mpuz-paint-number (prin1-to-string mpuz-nb-completed-games)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
338 (mpuz-paint-number |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
339 (format "%.2f" |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
340 (if (zerop mpuz-nb-completed-games) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
341 0 |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
342 (/ (+ 0.0 mpuz-nb-cumulated-errors) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
343 mpuz-nb-completed-games))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
344 3 2)) |
142 | 345 |
346 (defun mpuz-paint-board () | |
347 "Paint board situation on the puzzle screen." | |
348 (mpuz-switch-to-window) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
349 (mapc 'mpuz-paint-digit [0 1 2 3 4 5 6 7 8 9]) |
142 | 350 (goto-char (point-min))) |
351 | |
352 (defun mpuz-paint-digit (digit) | |
353 "Paint all occurrences of DIGIT on the puzzle board." | |
354 (let ((char (if (mpuz-digit-solved-p digit) | |
355 (+ digit ?0) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
356 (+ (mpuz-to-letter digit) ?A))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
357 (face `(face |
63238
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
358 ,(cond ((aref mpuz-trivial-digits digit) 'mpuz-trivial) |
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
359 ((aref mpuz-found-digits digit) 'mpuz-solved) |
5592f504d53f
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-398
Miles Bader <miles@gnu.org>
parents:
62770
diff
changeset
|
360 ('mpuz-unsolved)))) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
361 buffer-read-only) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
362 (mapc (lambda (square) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
363 (goto-line (car square)) ; line before column! |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
364 (move-to-column (cdr square)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
365 (insert char) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
366 (set-text-properties (1- (point)) (point) face) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
367 (delete-char 1)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
368 (aref mpuz-board digit)))) |
142 | 369 |
370 (defun mpuz-get-buffer () | |
371 "Get the puzzle buffer if it exists." | |
372 (get-buffer "*Mult Puzzle*")) | |
373 | |
374 (defun mpuz-switch-to-window () | |
375 "Find or create the Mult-Puzzle buffer, and display it." | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
376 (let ((buf (mpuz-get-buffer))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
377 (or buf (setq buf (mpuz-create-buffer))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
378 (switch-to-buffer buf) |
45113
f929d5e6ced1
(mpuz-switch-to-window): Set buffer-read-only directly.
Richard M. Stallman <rms@gnu.org>
parents:
43825
diff
changeset
|
379 (setq buffer-read-only t) |
142 | 380 (mpuz-mode))) |
381 | |
382 | |
383 ;; Game control | |
384 ;;------------- | |
385 (defun mpuz-start-new-game () | |
386 "Start a new puzzle." | |
387 (message "Here we go...") | |
388 (setq mpuz-nb-errors 0 | |
389 mpuz-in-progress t) | |
390 (fillarray mpuz-found-digits nil) ; initialize mpuz-found-digits | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
391 (fillarray mpuz-trivial-digits nil) |
142 | 392 (mpuz-random-puzzle) |
393 (mpuz-switch-to-window) | |
394 (mpuz-paint-board) | |
395 (mpuz-paint-errors) | |
396 (mpuz-ask-for-try)) | |
397 | |
1217
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
398 ;;;###autoload |
d0b19afef0ae
Fix setup of mpuz-read-map not to depend on keymap format.
Richard M. Stallman <rms@gnu.org>
parents:
838
diff
changeset
|
399 (defun mpuz () |
142 | 400 "Multiplication puzzle with GNU Emacs." |
401 ;; Main entry point | |
402 (interactive) | |
403 (mpuz-switch-to-window) | |
404 (if mpuz-in-progress | |
405 (mpuz-offer-abort) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
406 (mpuz-start-new-game))) |
142 | 407 |
408 (defun mpuz-offer-abort () | |
409 "Ask if user wants to abort current puzzle." | |
410 (interactive) | |
411 (if (y-or-n-p "Abort game ") | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
412 (let ((buf (mpuz-get-buffer))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
413 (message "Mult Puzzle aborted.") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
414 (setq mpuz-in-progress nil |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
415 mpuz-nb-errors 0) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
416 (fillarray mpuz-board nil) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
417 (if buf (kill-buffer buf))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
418 (mpuz-ask-for-try))) |
142 | 419 |
420 (defun mpuz-ask-for-try () | |
421 "Ask for user proposal in puzzle." | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
422 (message "Your try?")) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
423 |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
424 (defun mpuz-ding (error) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
425 "Dings, unless global variable `mpuz-silent' forbids it." |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
426 (cond ((eq mpuz-silent t)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
427 ((not mpuz-silent) (ding t)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
428 (error (ding t)))) |
142 | 429 |
430 (defun mpuz-try-letter () | |
431 "Propose a digit for a letter in puzzle." | |
432 (interactive) | |
433 (if mpuz-in-progress | |
434 (let (letter-char digit digit-char message) | |
2451
a149f1464f40
(mpuz-try-letter): Use read-char to read digit.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
435 (setq letter-char (upcase last-command-char) |
142 | 436 digit (mpuz-to-digit (- letter-char ?A))) |
437 (cond ((mpuz-digit-solved-p digit) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
438 (message "%c already solved." letter-char) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
439 (mpuz-ding t)) |
142 | 440 ((null (aref mpuz-board digit)) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
441 (message "%c does not appear." letter-char) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
442 (mpuz-ding t)) |
2451
a149f1464f40
(mpuz-try-letter): Use read-char to read digit.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
443 ((progn (message "%c = " letter-char) |
142 | 444 ;; <char> has been entered. |
445 ;; Print "<char> =" and | |
446 ;; read <num> or = <num> | |
2451
a149f1464f40
(mpuz-try-letter): Use read-char to read digit.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
447 (setq digit-char (read-char)) |
a149f1464f40
(mpuz-try-letter): Use read-char to read digit.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
448 (if (eq digit-char ?=) |
a149f1464f40
(mpuz-try-letter): Use read-char to read digit.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
449 (setq digit-char (read-char))) |
142 | 450 (or (> digit-char ?9) (< digit-char ?0))) ; bad input |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
451 (message "%c = %c" letter-char digit-char) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
452 (mpuz-ding t)) |
142 | 453 (t |
454 (mpuz-try-proposal letter-char digit-char)))) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
455 (if (y-or-n-p "Start a new game ") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
456 (mpuz-start-new-game) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
457 (message "OK. I won't.")))) |
142 | 458 |
459 (defun mpuz-try-proposal (letter-char digit-char) | |
460 "Propose LETTER-CHAR as code for DIGIT-CHAR." | |
461 (let* ((letter (- letter-char ?A)) | |
462 (digit (- digit-char ?0)) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
463 (correct-digit (mpuz-to-digit letter)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
464 (game mpuz-nb-completed-games)) |
142 | 465 (cond ((mpuz-digit-solved-p correct-digit) |
24859
0291983fe62f
(mpuz-try-proposal): Fix message call.
Karl Heuer <kwzh@gnu.org>
parents:
21363
diff
changeset
|
466 (message "%c has already been found." (+ correct-digit ?0))) |
0291983fe62f
(mpuz-try-proposal): Fix message call.
Karl Heuer <kwzh@gnu.org>
parents:
21363
diff
changeset
|
467 ((mpuz-digit-solved-p digit) |
0291983fe62f
(mpuz-try-proposal): Fix message call.
Karl Heuer <kwzh@gnu.org>
parents:
21363
diff
changeset
|
468 (message "%c has already been placed." digit-char)) |
142 | 469 ((= digit correct-digit) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
470 (message "%c = %c correct!" letter-char digit-char) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
471 (mpuz-ding nil) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
472 (aset mpuz-found-digits digit t) ; Mark digit as solved |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
473 (and (mpuz-check-all-solved) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
474 (mpuz-close-game))) |
142 | 475 (t ;;; incorrect guess |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
476 (message "%c = %c incorrect!" letter-char digit-char) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
477 (mpuz-ding t) |
142 | 478 (setq mpuz-nb-errors (1+ mpuz-nb-errors)) |
479 (mpuz-paint-errors))))) | |
480 | |
481 (defun mpuz-close-game () | |
482 "Housecleaning when puzzle has been solved." | |
483 (setq mpuz-in-progress nil | |
484 mpuz-nb-cumulated-errors (+ mpuz-nb-cumulated-errors mpuz-nb-errors) | |
485 mpuz-nb-completed-games (1+ mpuz-nb-completed-games)) | |
486 (mpuz-paint-statistics) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
487 (let ((message (format "Puzzle solved with %d error%s. That's %s" |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
488 mpuz-nb-errors |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
489 (if (= mpuz-nb-errors 1) "" "s") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
490 (cond ((= mpuz-nb-errors 0) "perfect!") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
491 ((= mpuz-nb-errors 1) "very good!") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
492 ((= mpuz-nb-errors 2) "good.") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
493 ((= mpuz-nb-errors 3) "not bad.") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
494 ((= mpuz-nb-errors 4) "not too bad...") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
495 ((< mpuz-nb-errors 10) "bad!") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
496 ((< mpuz-nb-errors 15) "awful.") |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
497 (t "not serious."))))) |
142 | 498 (message message) |
499 (sit-for 4) | |
500 (if (y-or-n-p (concat message " Start a new game ")) | |
501 (mpuz-start-new-game) | |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
502 (message "Good Bye!")))) |
142 | 503 |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
504 (defun mpuz-solve (&optional row col) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
505 "Find solution for autosolving." |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
506 (mapc (lambda (digit) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
507 (or (mpuz-digit-solved-p digit) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
508 (if row |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
509 (not (if col |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
510 (member (cons row col) (aref mpuz-board digit)) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
511 (assq row (aref mpuz-board digit))))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
512 (aset mpuz-trivial-digits digit t))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
513 [0 1 2 3 4 5 6 7 8 9]) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
514 t) |
142 | 515 |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
516 (defun mpuz-show-solution (row) |
142 | 517 "Display solution for debugging purposes." |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
518 (interactive "P") |
142 | 519 (mpuz-switch-to-window) |
43770
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
520 (mpuz-solve (if row (* 2 (prefix-numeric-value row)))) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
521 (mpuz-paint-board) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
522 (if (mpuz-check-all-solved) |
a6103ef77add
(mpuz-unsolved-face, mpuz-solved-face)
Eli Zaretskii <eliz@gnu.org>
parents:
42206
diff
changeset
|
523 (mpuz-close-game))) |
142 | 524 |
18383 | 525 (provide 'mpuz) |
526 | |
52401 | 527 ;;; arch-tag: 2781d6ba-89e7-43b5-85c7-5d3a2e73feb1 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
232
diff
changeset
|
528 ;;; mpuz.el ends here |