;ELC ;;; compiled by rms@mole.gnu.ai.mit.edu on Fri Jan 26 02:00:54 1996 ;;; from file /home/fsf/rms/e19/lisp/solitaire.el ;;; emacs version 19.30.90.1. ;;; bytecomp version FSF 2.10 ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19.29"))) (error "`solitaire.el' was compiled for Emacs 19.29 or later")) #@31 Keymap for playing solitaire. (defvar solitaire-mode-map nil (#$ . 476)) (byte-code "„¶Á ÂÃ\"ˆÄÅÆ#ˆÄÇÈ#ˆÄÉÊ#ˆÄËÌ#ˆÄÍÎ#ˆÏÐÑ$ˆÄÓÔ#ˆÄÕÖ#ˆÄׯ#ˆÄØÈ#ˆÄÙÊ#ˆÄÚÌ#ˆÄÛÜ#ˆÄÝÞ#ˆÄßà#ˆÄáâ#ˆÄãÆ#ˆÄäÈ#ˆÄåÊ#ˆÄæÌ#ˆÄçè#ˆÄéÜ#ˆÄêÞ#ˆÄëà#ˆÄìâ#ˆÄíÎ#ˆÄîÑ#ˆÄïð#ˆñòóô#‡" [solitaire-mode-map make-sparse-keymap suppress-keymap t define-key "" solitaire-right "" solitaire-left "" solitaire-up "" solitaire-down [return] solitaire-move substitute-key-definition undo solitaire-undo global-map " " solitaire-do-check "q" solitaire-quit [right] [left] [up] [down] [S-right] solitaire-move-right [S-left] solitaire-move-left [S-up] solitaire-move-up [S-down] solitaire-move-down [kp-6] [kp-4] [kp-8] [kp-2] [kp-5] solitaire-center-point [S-kp-6] [S-kp-4] [S-kp-8] [S-kp-2] [kp-enter] [kp-0] [115] solitaire-solve put solitaire-mode mode-class special] 5) #@290 Major mode for playing solitaire. To learn how to play solitaire, see the documentation for function `solitaire'. \ The usual mnemonic keys move the cursor around the board; in addition, \[solitaire-move] is a prefix character for actually moving a stone on the board. (defalias 'solitaire-mode #[nil "À ˆÁ\n!ˆÃÅÇÉÊ!‡" [kill-all-local-variables use-local-map solitaire-mode-map t truncate-lines solitaire-mode major-mode "Solitaire" mode-name run-hooks solitaire-mode-hook] 2 (#$ . 1342) nil]) #@46 Counter for the stones that are still there. (defvar solitaire-stones 0 (#$ . 1867)) #@22 Center of the board. (defvar solitaire-center nil (#$ . 1958)) #@33 Upper left corner of the board. (defvar solitaire-start nil (#$ . 2027)) (byte-code "ÀÁ!„ÂÁ BÀÄ!„ÂÄ B‡" [boundp solitaire-start-x nil current-load-list solitaire-start-y] 2) #@34 Lower right corner of the board. (defvar solitaire-end nil (#$ . 2216)) (byte-code "ÀÁ!„ÂÁ BÀÄ!„ÂÄ B‡" [boundp solitaire-end-x nil current-load-list solitaire-end-y] 2) #@200 *Non-nil means check for possible moves after each major change. This takes a while, so switch this on if you like to be informed when the game is over, or off, if you are working on a slow machine. (defvar solitaire-auto-eval t (#$ . -2401)) (byte-code "ÀÁ\nBÁ‡" [(solitaire-left solitaire-right solitaire-up solitaire-down) solitaire-valid-directions current-load-list] 2) #@1695 Play Solitaire. To play Solitaire, type \[solitaire]. \ Move around the board using the cursor keys. Move stones using \[solitaire-move] followed by a direction key. Undo moves using \[solitaire-undo]. Check for possible moves using \[solitaire-do-check]. (The variable solitaire-auto-eval controls whether to automatically check after each move or undo) What is Solitaire? I don't know who invented this game, but it seems to be rather old and it's origin seems be northern Africa. Here's how to play: Initially, the board will look similar to this: Le Solitaire ============ o o o o o o o o o o o o o o o o . o o o o o o o o o o o o o o o o Let's call the o's stones and the .'s holes. One stone fits into one hole. As you can see, all holes but one are occupied by stones. The aim of the game is to get rid of all but one stone, leaving that last one in the middle of the board if you're cool. A stone can be moved if there is another stone next to it, and a hole after that one. Thus there must be three fields in a row, either horizontally or vertically, up, down, left or right, which look like this: o o . Then the first stone is moved to the hole, jumping over the second, which therefore is taken away. The above thus `evaluates' to: . . o That's all. Here's the board after two moves: o o o . o o o o . o o o o o . o o o o o o o o o o o o o o o o o o Pick your favourite shortcuts: \{solitaire-mode-map} (defalias 'solitaire #[(arg) "ÀÁ!ˆÂ ˆÃÅÇ ˆÈ ˆdbˆÉÊ! `C\fÍÎ!‡" [switch-to-buffer "*Solitaire*" solitaire-mode t buffer-read-only 32 solitaire-stones solitaire-insert-board solitaire-build-modeline search-backward "." solitaire-center buffer-undo-list set-buffer-modified-p nil] 2 (#$ . 2786) "P"]) (defalias 'solitaire-build-modeline #[nil "ÀÁÂÃ\fWƒÅÆ\f\"‚ÇÈÉÊËÌͯ\nÏ ‡" ["" "---" mode-line-buffer-identification 1 solitaire-stones format "--> There are %d stones left <--" "------" global-mode-string " %[(" mode-name minor-mode-alist "%n" ")%]-%-" mode-line-format force-mode-line-update] 10]) (defalias 'solitaire-insert-board #[nil "À Ä  ÆVƒÇ‚ ÈVƒÉ‚Ê ÌVƒ)Í‚*ÎÐ  GÑ_ZÒZÓ¥Ô\"Ö ˆÐ ‰×VƒKØ‚LÙZGSÑ_ZÒZÓ¥Ú\"cˆ͘„i ×VƒwÛÜ\"cˆÛÝ\"cˆcˆ`ià !Ûâ ‰‰‰&cˆÛã ‰‰‰&cˆÛä ‰‰‰‰‰& cˆÛå ‰‰%cˆ`&Ûç ‰‰%cˆÛä ‰‰‰‰‰& cˆÛã ‰‰‰&cˆÛè ‰‰‰‰‰&cˆ`)i*à ‰+.‡" [nil buffer-read-only window-width w window-height h 26 " " 20 " " "" hsep 17 "\n\n" "\n" vsep make-string 6 7 2 32 indent erase-buffer 12 3 0 10 format "%sLe Solitaire\n" "%s============\n\n" solitaire-start solitaire-start-x solitaire-current-line solitaire-start-y " %s %so%so%so%s" "%s %s %so%so%so%s" "%so%so%so%so%so%so%so%s" "%so%so%so%s" solitaire-center ".%so%so%so%s" "%s %s %so%so%so%s %s " solitaire-end solitaire-end-x solitaire-end-y] 10]) (defalias 'solitaire-right #[nil "`ÁuˆgÂUƒÁuˆ‚gÃU„#gÂU„#gÄU…%b)‡" [start nil 32 0 10] 2 nil nil]) (defalias 'solitaire-left #[nil "`Á ˆgÂUƒÁ ˆ‚hÃU„#gÂU„#gÄU…%b)‡" [start backward-char 32 0 10] 2 nil nil]) (defalias 'solitaire-up #[nil "`iÂyˆÃ!ˆgÄUƒ Âyƒ Ã!ƒ nƒ hÅU„8gÆU„8gÇU„8gÄU…: b*‡" [c start -1 move-to-column 10 0 32 61] 2 nil nil]) (defalias 'solitaire-down #[nil "`iÂyˆÃ!ˆgÄUƒ Âyƒ Ã!ƒ lƒ gÅU„2gÆU„2gÄU…4 b*‡" [c start 1 move-to-column 10 0 32] 2 nil nil]) (defalias 'solitaire-center-point #[nil "b‡" [solitaire-center] 1 nil nil]) (defalias 'solitaire-move-right #[nil "ÀÁ!‡" [solitaire-move [right]] 2 nil nil]) (defalias 'solitaire-move-left #[nil "ÀÁ!‡" [solitaire-move [left]] 2 nil nil]) (defalias 'solitaire-move-up #[nil "ÀÁ!‡" [solitaire-move [up]] 2 nil nil]) (defalias 'solitaire-move-down #[nil "ÀÁ!‡" [solitaire-move [down]] 2 nil nil]) #@293 Check if a move is possible from current point in the specified direction. MOVESYMBOL specifies the direction. Returns either a string, indicating cause of contraindication, or a list containing three numbers: starting field, skipped field (from which a stone will be taken away) and target. (defalias 'solitaire-possible-move #[(movesymbol) "ŠÀÁ\nMˆ\n >ƒG`Á ˆ`Á ˆ` \fUƒ$Ç‚CfÈUƒ: fÈUƒ:\ffÉU„>Ê‚C \fE+‚HË*‡" [nil move movesymbol solitaire-valid-directions target skip start "Off Board!" 111 46 "Wrong move!" "Not a valid direction"] 3 (#$ . 6760)]) #@53 Pseudo-prefix command to move a stone in Solitaire. (defalias 'solitaire-move #[(dir) "ÀÁ\n \"!Å\f;ƒÇ\f!‚X\f@\fA@\fAA@ ‰\nbˆËÌ!ˆÍcˆ bˆËÌ!ˆÍcˆbˆËÌ!ˆÎcˆbˆSÐ ˆ…WÒ +*‡" [solitaire-possible-move lookup-key solitaire-mode-map dir class nil buffer-read-only error target skip start delete-char 1 46 111 solitaire-stones solitaire-build-modeline solitaire-auto-eval solitaire-do-check] 5 (#$ . 7331) "kMove where? "]) #@27 Undo a move in Solitaire. (defalias 'solitaire-undo #[(arg) "À !ˆ)ŠÄbˆÇÈ Ê#ƒ;i Yƒi\fXƒÍ YƒÍ Xƒ T‚ ))Ñ ˆ…JÓ ‡" [nil buffer-read-only undo arg 0 count solitaire-end search-backward "o" solitaire-start done solitaire-start-x solitaire-end-x solitaire-current-line solitaire-start-y solitaire-end-y solitaire-stones solitaire-build-modeline solitaire-auto-eval solitaire-do-check] 4 (#$ . 7769) "P"]) (defalias 'solitaire-check #[nil "ŠÁUƒ ‚B bˆÂÅÆÈ#ƒ@i Yƒi\nXƒË \fYƒË  XƒÎÏ\"ˆ‚\f))‡" [solitaire-stones 1 0 solitaire-end count search-backward "o" solitaire-start done solitaire-start-x solitaire-end-x solitaire-current-line solitaire-start-y solitaire-end-y mapcar #[(movesymbol) "À !<… \nT‰‡" [solitaire-possible-move movesymbol count] 2] solitaire-valid-directions] 4]) #@44 Check for any possible moves in Solitaire. (defalias 'solitaire-do-check #[(&optional arg) "À \nÃUƒÄÅ!‚+ ÆUƒÄÇ!‚+ ÃUƒ'ÄÈ!‚+ÄÉ \")‡" [solitaire-check moves solitaire-stones 1 message "Yeah! You made it! Only the King is left!" 0 "Sorry, no more possible moves." "There is one possible move." "There are %d possible moves."] 3 (#$ . 8599) "P"]) #@68 Return the vertical position of point. Seen in info on text lines. (defalias 'solitaire-current-line #[nil "Àe`\"iÁUƒ‚Á\\Ã\\‡" [count-lines 0 1 -1] 3 (#$ . 8957)]) #@25 Quit playing Solitaire. (defalias 'solitaire-quit #[nil "ÀÁ!‡" [kill-buffer "*Solitaire*"] 2 (#$ . 9132) nil]) #@93 Spoil solitaire by solving the game for you - nearly ... ... stops with five stones left ;) (defalias 'solitaire-solve #[nil "ÀÁÄ ˆÅÆ \"ˆ*Ç ‡" [[up up S-down up left left S-right up up left S-down up up right right S-left down down down S-up up S-down down down down S-up left left down S-right left left up up S-down right right right S-left left S-right right right right S-left right down down S-up down down left left S-right up up up S-down down S-up up up up S-down up right right S-left down right right down S-up left left left S-right right S-left down down left S-right S-up S-left S-left S-down S-right up S-right left left] nil solitaire-auto-eval allmoves solitaire-center-point mapcar #[(op) "Á>ƒ\nÂÃ!ˆÄÅ!!ˆÆ>…ÂÇ!‡" [op (S-left S-right S-up S-down) sit-for .2 execute-kbd-macro vector (S-left S-right S-up S-down) .4] 3] solitaire-do-check] 3 (#$ . 9249) nil]) (provide (quote solitaire))