;ELC   
;;; Compiled by pot@pot.cnuce.cnr.it on Tue Mar 18 15:49:29 2003
;;; from file /home/pot/gnu/emacs-pretest.new/lisp/play/5x5.el
;;; in Emacs version 21.3
;;; with bytecomp version 2.85.4.1
;;; with all optimizations.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.
(if (and (boundp 'emacs-version)
	 (< (aref emacs-version (1- (length emacs-version))) ?A)
	 (or (and (boundp 'epoch::version) epoch::version)
	     (string-lessp emacs-version "19.29")))
    (error "`5x5.el' was compiled for Emacs 19.29 or later"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(byte-code "\300\301!\204 \301\302M\210\303\304M\210\305\306\307\310\311\312\313\314&\207" [fboundp defgroup (macro . #[(&rest rest) "\300\207" [nil] 1]) defcustom (macro . #[(symbol init docstring &rest rest) "\303	\nF\207" [symbol init docstring defvar] 4]) custom-declare-group 5x5 nil "5x5 - Silly little puzzle game." :group games :prefix "5x5-"] 8)
#@28 *Size of the playing area.
(custom-declare-variable '5x5-grid-size '5 '(#$ . -971) :type 'integer :group '5x5)
#@41 *X scaling factor for drawing the grid.
(custom-declare-variable '5x5-x-scale '4 '(#$ . -1088) :type 'integer :group '5x5)
#@41 *Y scaling factor for drawing the grid.
(custom-declare-variable '5x5-y-scale '3 '(#$ . -1217) :type 'integer :group '5x5)
#@52 *Delay in seconds when animating a solution crack.
(custom-declare-variable '5x5-animate-delay '0.01 '(#$ . -1346) :type 'number :group '5x5)
#@66 *Should 5x5 ask you when you want to do a destructive operation?
(custom-declare-variable '5x5-hassle-me 't '(#$ . -1494) :type 'boolean :group '5x5)
#@28 *Hook run on starting 5x5.
(custom-declare-variable '5x5-mode-hook 'nil '(#$ . -1650) :type 'hook :group '5x5)
#@20 5x5 grid contents.
(defvar 5x5-grid nil (#$ . 1767))
#@23 X position of cursor.
(defvar 5x5-x-pos 2 (#$ . 1826))
#@23 Y position of cursor.
(defvar 5x5-y-pos 2 (#$ . 1887))
#@13 Moves made.
(defvar 5x5-moves 0 (#$ . 1948))
#@26 Are we in cracking mode?
(defvar 5x5-cracking nil (#$ . 1999))
#@30 Name of the 5x5 play buffer.
(defvar 5x5-buffer-name "*5x5*" (#$ . 2068))
#@32 Local keymap for the 5x5 game.
(defvar 5x5-mode-map nil (#$ . 2148))
(byte-code "\204\245 \302 \303	\304\"\210\305	\306\307#\210\305	\310\311#\210\305	\312\311#\210\305	\313\314#\210\305	\315\316#\210\305	\317\320#\210\305	\321\322#\210\305	\323\322#\210\305	\324\325#\210\305	\326\327#\210\305	\330\314#\210\305	\331\316#\210\305	\332\320#\210\305	\333\322#\210\305	\334\325#\210\305	\335\327#\210\305	\336\337#\210\305	\340\341#\210\305	\342\343#\210\305	\344\345#\210\305	\346\347#\210\305	\350\351#\210\305	\352\353#\210\305	\354\355#\210\305	\356\357#\210	)\302\207" [5x5-mode-map map make-sparse-keymap suppress-keymap t define-key "?" describe-mode "" 5x5-flip-current " " [up] 5x5-up [down] 5x5-down [left] 5x5-left [tab] 5x5-right [right] [(control a)] 5x5-bol [(control e)] 5x5-eol [(control p)] [(control n)] [(control b)] [(control f)] [home] [end] [prior] 5x5-first [next] 5x5-last "r" 5x5-randomize [(control c) (control r)] 5x5-crack-randomly [(control c) (control c)] 5x5-crack-mutating-current [(control c) (control b)] 5x5-crack-mutating-best [(control c) (control x)] 5x5-crack-xor-mutate "n" 5x5-new-game "q" 5x5-quit-game] 4)
#@11 5x5 menu.
(defvar 5x5-mode-menu nil (#$ . 3305))
(byte-code "\301\302\303\304$\210\305\306\307\310#\207" [5x5-mode-map easy-menu-do-define 5x5-mode-menu "5x5 menu." ("5x5" ["New game" 5x5-new-game t] ["Random game" 5x5-randomize t] ["Quit game" 5x5-quit-game t] "---" ["Crack randomly" 5x5-crack-randomly t] ["Crack mutating current" 5x5-crack-mutating-current t] ["Crack mutating best" 5x5-crack-mutating-best t] ["Crack with xor mutate" 5x5-crack-xor-mutate t]) put 5x5-mode mode-class special] 5)
#@79 A mode for playing `5x5'

The key bindings for 5x5-mode are:

\{5x5-mode-map}
(defalias '5x5-mode #[nil "\305 \210\306!\210\307\310\311\312!\210\313\313\314p!\207" [5x5-mode-map major-mode mode-name buffer-read-only truncate-lines kill-all-local-variables use-local-map 5x5-mode "5x5" run-hooks 5x5-mode-hook t buffer-disable-undo] 2 (#$ . 3812)])
#@731 Play 5x5.

The object of 5x5 is very simple, by moving around the grid and flipping
squares you must fill the grid.

5x5 keyboard bindings are:
\<5x5-mode-map>
Flip                      \[5x5-flip-current] 
Move up                   \[5x5-up]           
Move down                 \[5x5-down]         
Move left                 \[5x5-left]         
Move right                \[5x5-right]        
Start new game            \[5x5-new-game]
New game with random grid \[5x5-randomize]
Random cracker            \[5x5-crack-randomly]
Mutate current cracker    \[5x5-crack-mutating-current]
Mutate best cracker       \[5x5-crack-mutating-best]
Mutate xor cracker        \[5x5-crack-xor-mutate]
Quit current game         \[5x5-quit-game]
(defalias '5x5 #[(&optional size) "\305	\203 	\306!\210\f\203 \n\f\307HGU\204 \310 \210\311\fC!\210\312 \210\313 \207" [5x5-cracking size 5x5-grid-size 5x5-buffer-name 5x5-grid nil switch-to-buffer 0 5x5-new-game 5x5-draw-grid 5x5-position-cursor 5x5-mode] 3 (#$ . 4172) "P"])
#@28 Start a new game of `5x5'.
(defalias '5x5-new-game #[nil "t\203\n \305\306!\202 \307\205* \310\245\310\245\311\312\313 \n	#t\205* \314\fC!\210\315 \207" [5x5-grid-size 5x5-x-pos 5x5-y-pos 5x5-moves 5x5-grid 5x5-y-or-n-p "Start a new game? " t 2 0 5x5-make-move 5x5-make-new-grid 5x5-draw-grid 5x5-position-cursor] 4 (#$ . 5191) nil])
#@33 Quit the current game of `5x5'.
(defalias '5x5-quit-game #[nil "\301!\207" [5x5-buffer-name kill-buffer] 2 (#$ . 5538) nil])
#@47 Create and return a new `5x5' grid structure.
(defalias '5x5-make-new-grid #[nil "\304\305\"\306S\nX\203 	\n\304\305\"I\210\nT\211\202 *	)\207" [5x5-grid-size grid y #1=#:G97269 make-vector nil 0] 6 (#$ . 5670)])
#@55 Return the value of the cell in GRID at location X,Y.
(defalias '5x5-cell #[(grid y x) "	H\nH\207" [grid y x] 2 (#$ . 5899)])
#@45 Set the value of cell X,Y in GRID to VALUE.
(defalias '5x5-set-cell #[(grid y x value) "	H\nI\207" [grid y x value] 3 (#$ . 6032)])
#@37 Flip the value of cell X,Y in GRID.
(defalias '5x5-flip-cell #[(grid y x) "\303	\n\304	\n#?$\207" [grid y x 5x5-set-cell 5x5-cell] 8 (#$ . 6172)])
#@26 Make a new copy of GRID.
(defalias '5x5-copy-grid #[(grid) "\306 \307\nS	X\2034 \307\nS\fX\203, \310	\f\311\n	\f#$\210\fT\211\202 *	T\211\202	 *)\207" [copy y 5x5-grid-size #1=#:G97270 x #2=#:G97271 5x5-make-new-grid 0 5x5-set-cell 5x5-cell grid] 10 (#$ . 6327)])
#@48 Make a move on GRID at row ROW and column COL.
(defalias '5x5-make-move #[(grid row col) "\304	\n#\210	\305V\203 \304	S\n#\210	SW\203! \304	T\n#\210\n\305V\203. \304	\nS#\210\nSW\203< \304	\nT#\210\207" [grid row col 5x5-grid-size 5x5-flip-cell 0] 4 (#$ . 6610)])
#@38 Get the "on-value" for grid row ROW.
(defalias '5x5-row-value #[(row) "\305	S\305\nX\203\" \fH\203 \306\202 \305\\T\211\202 +\207" [y 5x5-grid-size #1=#:G97272 #2=#:G97273 row 0 1] 4 (#$ . 6889)])
#@35 Get the "on-value" for grid GRID.
(defalias '5x5-grid-value #[(grid) "\305	S\305\nX\203 \306\fH!\\T\211\202 +\207" [y 5x5-grid-size #1=#:G97274 #2=#:G97275 grid 0 5x5-row-value] 5 (#$ . 7105)])
#@33 Draw the top/bottom of the grid
(defalias '5x5-draw-grid-end #[nil "\304c\210\305	S\nX\203 \306\307\310\"\261\210T\211\202	 *\311c\207" [x 5x5-grid-size #1=#:G97276 5x5-x-scale "+" 0 "-" make-string 45 "-+ "] 5 (#$ . 7317)])
#@47 Draw the grids GRIDS into the current buffer.
(defalias '5x5-draw-grid #[(grids) "\306\307 \210	\306\n:\203 \n@\310 \210\nA\211\202\n *\311c\210\312S\fX\203\246 \312SX\203\236 	\306:\203\221 @\312SX\203\204 \313!\203e \314\202f \315\316\317\f#\203v \320\202w \321\"\261\210T\211\202T *\322c\210A\211\202C *\311c\210T\211\2026 *\fT\211\202& *	\306:\203\302 @\310 \210A\211\202\256 *\311c\210\323\324\325	@!#c)\207" [buffer-read-only grids #1=#:G97277 grid y 5x5-grid-size nil erase-buffer 5x5-draw-grid-end "\n" 0 zerop "| " " " make-string 5x5-cell 35 46 " | " format "On: %d  Moves: %d" 5x5-grid-value #2=#:G97278 lines 5x5-y-scale #3=#:G97280 #4=#:G97281 x #5=#:G97282 5x5-x-scale #6=#:G97279 5x5-moves] 11 (#$ . 7556)])
#@34 Position the cursor on the grid.
(defalias '5x5-position-cursor #[nil "\304	_\305\\!\210`\n_\\\nT\\\306\\b\207" [5x5-y-pos 5x5-y-scale 5x5-x-pos 5x5-x-scale goto-line 2 1] 3 (#$ . 8359)])
#@46 Keep track of how many moves have been made.
(defalias '5x5-made-move #[nil "T\211\207" [5x5-moves] 2 (#$ . 8555)])
#@21 Make a random grid.
(defalias '5x5-make-random-grid #[nil "\306 \307\nS	X\2036 \307\nS\fX\203. \310\311\312!!\203' \313	\f#\210\fT\211\202 *	T\211\202	 *)\207" [grid y 5x5-grid-size #1=#:G97283 x #2=#:G97284 5x5-make-new-grid 0 zerop random 2 5x5-flip-cell] 6 (#$ . 8679)])
#@46 Attempt to crack 5x5 using random solutions.
(defalias '5x5-crack-randomly #[nil "\300\301!\207" [5x5-crack 5x5-make-random-solution] 2 (#$ . 8971) nil])
#@56 Attempt to crack 5x5 by mutating the current solution.
(defalias '5x5-crack-mutating-current #[nil "\300\301!\207" [5x5-crack 5x5-make-mutate-current] 2 (#$ . 9131) nil])
#@53 Attempt to crack 5x5 by mutating the best solution.
(defalias '5x5-crack-mutating-best #[nil "\300\301!\207" [5x5-crack 5x5-make-mutate-best] 2 (#$ . 9308) nil])
#@89 Attempt to crack 5x5 by xor the current and best solution and then
mutating the result.
(defalias '5x5-crack-xor-mutate #[nil "\300\301!\207" [5x5-crack 5x5-make-xor-with-mutation] 2 (#$ . 9476) nil])
#@318 Attempt to find a solution for 5x5.

5x5-crack takes the argument BREEDER which should be a function that takes
two parameters, the first will be a grid vector array that is the current
solution and the second will be the best solution so far. The function
should return a grid vector array that is the new solution.
(defalias '5x5-crack #[(breeder) "\306 \210\307\310 \211\311 \311 \211_\312!W\203C \313 \204C \314\n	\"\312\f!\312!V\2036 \n\f\315\n!\315	!\"\202 -\316\211\207" [5x5-cracking best-solution current-solution best-result current-result 5x5-grid-size 5x5 t 5x5-make-random-grid 5x5-make-new-grid 5x5-grid-value input-pending-p 5x5-play-solution 5x5-copy-grid nil target breeder] 5 (#$ . 9684) "aBreeder function: "])
#@25 Make a random solution.
(defalias '5x5-make-random-solution #[(&rest ignore) "\300 \207" [5x5-make-random-grid] 1 (#$ . 10440)])
#@30 Mutate the current solution.
(defalias '5x5-make-mutate-current #[(current best) "\301!\207" [current 5x5-mutate-solution] 2 (#$ . 10575)])
#@27 Mutate the best solution.
(defalias '5x5-make-mutate-best #[(current best) "\301!\207" [best 5x5-mutate-solution] 2 (#$ . 10722)])
#@55 xor current and best solution then mutate the result.
(defalias '5x5-make-xor-with-mutation #[(current best) "\306 \307\nS	X\203< \307\nS\fX\2034 \310	\f\311\312\f	\f#\312	\f#\"$\210\fT\211\202 *	T\211\202	 *\313!)\207" [xored y 5x5-grid-size #1=#:G97285 x #2=#:G97286 5x5-make-new-grid 0 5x5-set-cell 5x5-xor 5x5-cell 5x5-mutate-solution current best] 12 (#$ . 10860)])
#@37 Randomly flip bits in the solution.
(defalias '5x5-mutate-solution #[(solution) "\306	S\nX\203= \306	S\fX\2035 \307	\211_\310\245!	\211_\310\245\310\245U\203. \311#\210T\211\202 *T\211\202 *\207" [y 5x5-grid-size #1=#:G97287 x #2=#:G97288 solution 0 random 2 5x5-flip-cell] 6 (#$ . 11252)])
#@113 Play a solution on an empty grid. This destroys the current game in
progress because it is an animated attempt.
(defalias '5x5-play-solution #[(solution best) "\306 \210\307\310\nS	X\203N \310\nS\fX\203F 	\f\311	\f#\203- \312 \210\313E!\210\314 \210\315!\210\fT\211\202 *	T\211\202 +\207" [inhibit-quit y 5x5-grid-size #1=#:G97289 x #2=#:G97290 5x5-new-game t 0 5x5-cell 5x5-flip-current 5x5-draw-grid 5x5-position-cursor sit-for 5x5-y-pos 5x5-x-pos solution 5x5-grid best 5x5-animate-delay] 6 (#$ . 11566)])
#@45 Make a move on the current cursor location.
(defalias '5x5-flip-current #[nil "\305	\n#\306 \210\204 \307C!\210\310 \210\311!\f\211_U\205% \312 \210\313\314!\207" [5x5-grid 5x5-y-pos 5x5-x-pos 5x5-cracking 5x5-grid-size 5x5-make-move 5x5-made-move 5x5-draw-grid 5x5-position-cursor 5x5-grid-value beep message "You win!"] 4 (#$ . 12108) nil])
#@10 Move up.
(defalias '5x5-up #[nil "\301!?\205\f S\302 \207" [5x5-y-pos zerop 5x5-position-cursor] 2 (#$ . 12463) nil])
#@12 Move down.
(defalias '5x5-down #[nil "	SU?\205 T\302 \207" [5x5-y-pos 5x5-grid-size 5x5-position-cursor] 2 (#$ . 12590) nil])
#@12 Move left.
(defalias '5x5-left #[nil "\301!?\205\f S\302 \207" [5x5-x-pos zerop 5x5-position-cursor] 2 (#$ . 12726) nil])
#@13 Move right.
(defalias '5x5-right #[nil "	SU?\205 T\302 \207" [5x5-x-pos 5x5-grid-size 5x5-position-cursor] 2 (#$ . 12857) nil])
#@28 Move to beginning of line.
(defalias '5x5-bol #[nil "\301\302 \207" [5x5-x-pos 0 5x5-position-cursor] 1 (#$ . 12995) nil])
#@22 Move to end of line.
(defalias '5x5-eol #[nil "S\302 \207" [5x5-grid-size 5x5-x-pos 5x5-position-cursor] 1 (#$ . 13125) nil])
#@25 Move to the first cell.
(defalias '5x5-first #[nil "\302\302\303 \207" [5x5-x-pos 5x5-y-pos 0 5x5-position-cursor] 1 (#$ . 13259) nil])
#@24 Move to the last cell.
(defalias '5x5-last #[nil "SS\303 \207" [5x5-grid-size 5x5-x-pos 5x5-y-pos 5x5-position-cursor] 1 (#$ . 13403) nil])
#@21 Randomize the grid.
(defalias '5x5-randomize #[nil "\306\307!\205 \310\245\310\245\311\312 \204 \313\fC!\210\314 \207" [5x5-grid-size 5x5-x-pos 5x5-y-pos 5x5-moves 5x5-grid 5x5-cracking 5x5-y-or-n-p "Start a new game with a random grid? " 2 0 5x5-make-random-grid 5x5-draw-grid 5x5-position-cursor] 2 (#$ . 13553) nil])
#@34 Boolean exclusive-or of X and Y.
(defalias '5x5-xor #[(x y) "\204 	\205 \205 	?\207" [x y] 1 (#$ . 13888)])
#@68 5x5 wrapper for y-or-n-p which respects the 5x5-hassle-me setting.
(defalias '5x5-y-or-n-p #[(prompt) "\203 \302	!\207\303\207" [5x5-hassle-me prompt y-or-n-p t] 2 (#$ . 14007)])
(provide '5x5)
