Mercurial > emacs
comparison lisp/play/life.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 0d8b17d428b5 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; life.el --- John Horton Conway's `Life' game for GNU Emacs | 1 ;;; life.el --- John Horton Conway's `Life' game for GNU Emacs |
2 | 2 |
3 ;; Copyright (C) 1988, 2001 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1988, 2001, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: Kyle Jones <kyleuunet.uu.net> | 6 ;; Author: Kyle Jones <kyleuunet.uu.net> |
7 ;; Maintainer: FSF | |
6 ;; Keywords: games | 8 ;; Keywords: games |
7 | 9 |
8 ;; This file is part of GNU Emacs. | 10 ;; This file is part of GNU Emacs. |
9 | 11 |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 ;; GNU General Public License for more details. | 20 ;; GNU General Public License for more details. |
19 | 21 |
20 ;; You should have received a copy of the GNU General Public License | 22 ;; You should have received a copy of the GNU General Public License |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02111-1307, USA. | 25 ;; Boston, MA 02110-1301, USA. |
24 | 26 |
25 ;;; Commentary: | 27 ;;; Commentary: |
26 | 28 |
27 ;; A demonstrator for John Horton Conway's "Life" cellular automaton | 29 ;; A demonstrator for John Horton Conway's "Life" cellular automaton |
28 ;; in Emacs Lisp. Picks a random one of a set of interesting Life | 30 ;; in Emacs Lisp. Picks a random one of a set of interesting Life |
29 ;; patterns and evolves it according to the familiar rules. | 31 ;; patterns and evolves it according to the familiar rules. |
30 | 32 |
31 ;;; Code: | 33 ;;; Code: |
32 | 34 |
33 (defconst life-patterns | 35 (defvar life-patterns |
34 [("@@@" " @@" "@@@") | 36 [("@@@" " @@" "@@@") |
35 ("@@@ @@@" "@@ @@ " "@@@ @@@") | 37 ("@@@ @@@" "@@ @@ " "@@@ @@@") |
36 ("@@@ @@@" "@@ @@" "@@@ @@@") | 38 ("@@@ @@@" "@@ @@" "@@@ @@@") |
37 ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") | 39 ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@") |
38 ("@@@@@@@@@@") | 40 ("@@@@@@@@@@") |
78 (defmacro life-increment (variable) (list 'setq variable (list '1+ variable))) | 80 (defmacro life-increment (variable) (list 'setq variable (list '1+ variable))) |
79 | 81 |
80 | 82 |
81 ;; list of numbers that tell how many characters to move to get to | 83 ;; list of numbers that tell how many characters to move to get to |
82 ;; each of a cell's eight neighbors. | 84 ;; each of a cell's eight neighbors. |
83 (defconst life-neighbor-deltas nil) | 85 (defvar life-neighbor-deltas nil) |
84 | 86 |
85 ;; window display always starts here. Easier to deal with than | 87 ;; window display always starts here. Easier to deal with than |
86 ;; (scroll-up) and (scroll-down) when trying to center the display. | 88 ;; (scroll-up) and (scroll-down) when trying to center the display. |
87 (defconst life-window-start nil) | 89 (defvar life-window-start nil) |
88 | 90 |
89 ;; For mode line | 91 ;; For mode line |
90 (defconst life-current-generation nil) | 92 (defvar life-current-generation nil) |
91 ;; Sadly, mode-line-format won't display numbers. | 93 ;; Sadly, mode-line-format won't display numbers. |
92 (defconst life-generation-string nil) | 94 (defvar life-generation-string nil) |
93 | 95 |
94 (defvar life-initialized nil | 96 (defvar life-initialized nil |
95 "Non-nil if `life' has been run at least once.") | 97 "Non-nil if `life' has been run at least once.") |
96 | 98 |
97 ;;;###autoload | 99 ;;;###autoload |
277 (put 'life-extinct 'error-conditions '(life-extinct quit)) | 279 (put 'life-extinct 'error-conditions '(life-extinct quit)) |
278 (put 'life-extinct 'error-message "All life has perished") | 280 (put 'life-extinct 'error-message "All life has perished") |
279 | 281 |
280 (provide 'life) | 282 (provide 'life) |
281 | 283 |
284 ;;; arch-tag: e9373544-755e-42f5-a9a1-4d4c422bb97a | |
282 ;;; life.el ends here | 285 ;;; life.el ends here |