;ELC ;;; Compiled ;;; in Emacs version 27.1 ;;; with all optimizations. ;;; This file uses dynamic docstrings, first added in Emacs 19.29. ;;; This file does not contain utf-8 non-ASCII characters, ;;; and so can be loaded in Emacs versions earlier than 23. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (byte-code "\300\301\302\303\304\305\306\307&\210\310\311\312\313\314\315\304\301&\210\310\316\317\320\314\315\304\301&\210\310\321\322\323\314\315\304\301&\210\310\324\325\326\314\327\304\301&\210\310\330\331\332\314\333\304\301&\210\310\334\302\335\314\336\304\301&\207" [custom-declare-group 5x5 nil "5x5 - Silly little puzzle game." :group games :prefix "5x5-" custom-declare-variable 5x5-grid-size 5 "Size of the playing area." :type integer 5x5-x-scale 4 "X scaling factor for drawing the grid." 5x5-y-scale 3 "Y scaling factor for drawing the grid." 5x5-animate-delay 0.01 "Delay in seconds when animating a solution crack." number 5x5-hassle-me t "Should 5x5 ask you when you want to do a destructive operation?" boolean 5x5-mode-hook "Hook run on starting 5x5." hook] 8) #@70 Define VAR to VALUE with documentation DOC and make it buffer local. (defalias '5x5-defvar-local '(macro . #[(var value doc) "\303\304 \nF\305\306DDE\207" [var value doc progn defvar make-variable-buffer-local quote] 5 (#$ . 1195)])) #@20 5x5 grid contents. (defvar 5x5-grid nil (#$ . 1437)) (make-variable-buffer-local '5x5-grid) #@23 X position of cursor. (defvar 5x5-x-pos 2 (#$ . 1535)) (make-variable-buffer-local '5x5-x-pos) #@23 Y position of cursor. (defvar 5x5-y-pos 2 (#$ . 1636)) (make-variable-buffer-local '5x5-y-pos) #@13 Moves made. (defvar 5x5-moves 0 (#$ . 1737)) (make-variable-buffer-local '5x5-moves) #@26 Are we in cracking mode? (defvar 5x5-cracking nil (#$ . 1828)) (make-variable-buffer-local '5x5-cracking) #@30 Name of the 5x5 play buffer. (defvar 5x5-buffer-name "*5x5*" (#$ . 1940)) #@32 Local keymap for the 5x5 game. (defvar 5x5-mode-map (byte-code "\301 \302\303\"\210\304\305\306#\210\304\307\310#\210\304\311\310#\210\304\312\313#\210\304\314\315#\210\304\316\317#\210\304\320\321#\210\304\322\321#\210\304\323\324#\210\304\325\326#\210\304\327\313#\210\304\330\315#\210\304\331\317#\210\304\332\321#\210\304\333\324#\210\304\334\326#\210\304\335\336#\210\304\337\340#\210\304\341\342#\210\304\343\344#\210\304\345\346#\210\304\347\350#\210\304\351\352#\210\304\353\354#\210\304\355\356#\210\304\357\360#\210\304\361\362#\210\304\363\364#\210)\207" [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 "s" 5x5-solve-suggest "<" 5x5-solve-rotate-left ">" 5x5-solve-rotate-right "q" 5x5-quit-game] 4) (#$ . 2020)) #@450 List that is the output of an arithmetic solver. This list L is such that L = (M S_1 S_2 ... S_N) M is the move count when the solve output was stored. S_1 ... S_N are all the solutions ordered from least to greatest number of strokes. S_1 is the solution to be displayed. Each solution S_1, ..., S_N is a list (STROKE-COUNT GRID) where STROKE-COUNT is the number of strokes to achieve the solution and GRID is the grid of positions to click. (defvar 5x5-solver-output nil (#$ . 3275)) (make-variable-buffer-local '5x5-solver-output) #@11 5x5 menu. (defvar 5x5-mode-menu nil (#$ . 3821)) (easy-menu-do-define '5x5-mode-menu 5x5-mode-map "5x5 menu." '("5x5" ["New game" 5x5-new-game t] ["Random game" 5x5-randomize t] ["Quit game" 5x5-quit-game t] "---" ["Use Calc solver" 5x5-solve-suggest t] ["Rotate left list of Calc solutions" 5x5-solve-rotate-left t] ["Rotate right list of Calc solutions" 5x5-solve-rotate-right 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])) (defvar 5x5-mode-hook nil) (byte-code "\300\301N\204\f\302\300\301\303#\210\304\305!\204\302\305\306\307#\210\300\207" [5x5-mode-hook variable-documentation put "Hook run after entering 5x5 mode.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" boundp 5x5-mode-map definition-name 5x5-mode] 4) (defvar 5x5-mode-map (make-sparse-keymap)) (byte-code "\301\302N\204\303\301\302\304\305!#\210\306\307!\204\303\307\310\311#\210\312\313 !\210\307\302N\204-\303\307\302\304\314!#\210\306\300!\204B\303\300\310\311#\210\315\316\300\317\"\210!\210\300\302N\204P\303\300\302\304\320!#\210\303\311\321\322#\207" [5x5-mode-abbrev-table 5x5-mode-map variable-documentation put purecopy "Keymap for `5x5-mode'." boundp 5x5-mode-syntax-table definition-name 5x5-mode (lambda (#1=#:def-tmp-var) (defvar 5x5-mode-syntax-table #1#)) make-syntax-table "Syntax table for `5x5-mode'." (lambda (#1#) (defvar 5x5-mode-abbrev-table #1#)) define-abbrev-table nil "Abbrev table for `5x5-mode'." derived-mode-parent special-mode] 5) #@214 A mode for playing `5x5'. In addition to any hooks its parent mode `special-mode' might have run, this mode runs the hook `5x5-mode-hook', as the final or penultimate step during initialization. \{5x5-mode-map} (defalias '5x5-mode #[nil "\306\300!\210\307\310 \210\311\312\310\313N\203\314\311\313\310\313N#\210\315 !\204'\316 \317 \"\210\320\f!\211\2036 \321 =\203<\322\f\323 \"\210)\324\325\"\204V=\204V\326\325C#\210\327 !\210\330\f!\210\307\211\331 \210)\332\333!\207" [delay-mode-hooks major-mode mode-name 5x5-mode-map 5x5-mode-syntax-table parent make-local-variable t special-mode 5x5-mode "5x5" mode-class put keymap-parent set-keymap-parent current-local-map char-table-parent standard-syntax-table set-char-table-parent syntax-table abbrev-table-get :parents abbrev-table-put use-local-map set-syntax-table buffer-disable-undo run-mode-hooks 5x5-mode-hook 5x5-mode-abbrev-table local-abbrev-table buffer-read-only truncate-lines] 6 (#$ . 5509) nil]) #@873 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] Solve with Calc \[5x5-solve-suggest] Rotate left Calc Solutions \[5x5-solve-rotate-left] Rotate right Calc Solutions \[5x5-solve-rotate-right] Quit current game \[5x5-quit-game] (defalias '5x5 #[(&optional size) "\305\306 !\210\307 \210\310\n!\203\n\f\203 \f\311HGU\204!\312 \210\313\fC!\210\314 \207" [5x5-cracking 5x5-buffer-name size 5x5-grid-size 5x5-grid nil switch-to-buffer 5x5-mode natnump 0 5x5-new-game 5x5-draw-grid 5x5-position-cursor] 3 (#$ . 6508) "P"]) #@28 Start a new game of `5x5'. (defalias '5x5-new-game #[nil "\306\307!\203\f\310\311!\202 \312\205*\313\245\313\245\314\315\316 \n #\317\320\fC!\210\321 \207" [5x5-grid-size 5x5-x-pos 5x5-y-pos 5x5-moves 5x5-grid 5x5-solver-output called-interactively-p interactive 5x5-y-or-n-p "Start a new game? " t 2 0 5x5-make-move 5x5-make-new-grid nil 5x5-draw-grid 5x5-position-cursor] 4 (#$ . 7683) nil]) #@33 Quit the current game of `5x5'. (defalias '5x5-quit-game #[nil "\301!\207" [5x5-buffer-name kill-buffer] 2 (#$ . 8093) nil]) #@47 Create and return a new `5x5' grid structure. (defalias '5x5-make-new-grid #[nil "\304\305\"\306\n W\203 \n\304\305\"I\210\nT\211\202\n* )\207" [5x5-grid-size grid y --dotimes-limit-- make-vector nil 0] 6 (#$ . 8225)]) #@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 (#$ . 8460)]) #@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 (#$ . 8593)]) #@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 (#$ . 8733)]) #@26 Make a new copy of GRID. (defalias '5x5-copy-grid #[(grid) "\306  \307\n W\2031 \307\f W\203)\310\n\f\311 \n\f#$\210\fT\211\202*\nT\211\202*)\207" [copy 5x5-grid-size y --dotimes-limit-- x grid 5x5-make-new-grid 0 5x5-set-cell 5x5-cell] 9 (#$ . 8888)]) #@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 (#$ . 9162)]) #@38 Get the "on-value" for grid row ROW. (defalias '5x5-row-value #[(row) "\305 S\305\nX\203\" \fH\203\306\202\305\\T\211\202 +\207" [y 5x5-grid-size #1=#:--cl-var-- #2=#:--cl-var-- row 0 1] 4 (#$ . 9441)]) #@35 Get the "on-value" for grid GRID. (defalias '5x5-grid-value #[(grid) "\305 S\305\nX\203 \306\fH!\\T\211\202 +\207" [y 5x5-grid-size #1=#:--cl-var-- #2=#:--cl-var-- grid 0 5x5-row-value] 5 (#$ . 9665)]) #@34 Draw the top/bottom of the grid. (defalias '5x5-draw-grid-end #[nil "\304c\210\305 \nW\203\306\307 \310\"\261\210 T\211\202*\311c\207" [5x5-grid-size x --dotimes-limit-- 5x5-x-scale "+" 0 "-" make-string 45 "-+ "] 5 (#$ . 9885)]) #@47 Draw the grids GRIDS into the current buffer. (defalias '5x5-draw-grid #[(grids) "\306\307\310 \210\n\307\211\203\f@\311 \210\fA\211\204*\312c\210` \313 ! !W\203\245\"\313#!#!W\203\233\n\307\211\203\216\f@ \313$!$!W\203\203$\313U\203c\314\202d\315\316%\317  $#\203u\320\202v\321\"\261\210$T\211$\202R*\322c\210\fA\211\204G*\312c\210#T\211#\2029* T\211 \202**&\203?&@'U\203<\212b\210\323\"\324\245T!\210&A@A( \313 ! !W\2038\212%T\324\245Tu\210 \313$!$!W\203*\317( $#\203\325%\324\"\313U\203\326c\210``\324\\|\210\327u\210\202\330\331\332\"\210\333\332!\210\334u\210%Tu\210$T\211$\202\346+\"y\210 T\211 \202\317,\202?\307&\n\307\211\203T\f@\311 \210\fA\211\204G*\312c\210\335\336\337\n@!'#c*\207" [grid-org inhibit-read-only grids grid --dolist-tail-- 5x5-grid-size t nil erase-buffer 5x5-draw-grid-end "\n" 0 "| " " " make-string 5x5-cell 35 46 " | " beginning-of-line 2 mod "()" -2 insert-char 79 1 delete-char -1 format "On: %d Moves: %d" 5x5-grid-value y --dotimes-limit-- 5x5-y-scale lines x 5x5-x-scale 5x5-solver-output 5x5-moves solution-grid] 8 (#$ . 10130)]) #@34 Position the cursor on the grid. (defalias '5x5-position-cursor #[nil "eb\210 _Ty\210\304`\n _\nT\305$b\207" [5x5-y-pos 5x5-y-scale 5x5-x-pos 5x5-x-scale + 1] 5 (#$ . 11302)]) #@46 Keep track of how many moves have been made. (defalias '5x5-made-move #[nil "T\211\207" [5x5-moves] 2 (#$ . 11485)]) #@21 Make a random grid. (defalias '5x5-make-random-grid #[(&optional move) "\206\306K\307 \n\310 \fW\203;\n\310 \fW\2033\311\312!\310U\203, #\210 T\211\202* T\211\202* )\207" [move grid 5x5-grid-size y --dotimes-limit-- x 5x5-flip-cell 5x5-make-new-grid 0 random 2] 5 (#$ . 11610)]) #@46 Attempt to crack 5x5 using random solutions. (defalias '5x5-crack-randomly #[nil "\300\301!\207" [5x5-crack 5x5-make-random-solution] 2 (#$ . 11916) 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 (#$ . 12077) 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 (#$ . 12255) nil]) #@82 Attempt to crack 5x5 by xoring the current and best solution. Mutate the result. (defalias '5x5-crack-xor-mutate #[nil "\300\301!\207" [5x5-crack 5x5-make-xor-with-mutation] 2 (#$ . 12424) nil]) #@319 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 (#$ . 12626) "aBreeder function: "]) #@25 Make a random solution. (defalias '5x5-make-random-solution #[(&rest _ignore) "\300 \207" [5x5-make-random-grid] 1 (#$ . 13384)]) #@30 Mutate the current solution. (defalias '5x5-make-mutate-current #[(current _best) "\301!\207" [current 5x5-mutate-solution] 2 (#$ . 13520)]) #@27 Mutate the best solution. (defalias '5x5-make-mutate-best #[(_current best) "\301!\207" [best 5x5-mutate-solution] 2 (#$ . 13668)]) #@55 Xor current and best solution then mutate the result. (defalias '5x5-make-xor-with-mutation #[(current best) "\306  \307\n W\203H \307\f W\203@\310\n\f\311 \n\f#\311 \n\f#\204/\262\2027\211?\2055\266\202$\210\fT\211\202*\nT\211\202*\312!)\207" [xored 5x5-grid-size y --dotimes-limit-- x current 5x5-make-new-grid 0 5x5-set-cell 5x5-cell 5x5-mutate-solution best] 10 (#$ . 13807)]) #@37 Randomly flip bits in the solution. (defalias '5x5-mutate-solution #[(solution) "\305 \nW\203;\305 \nW\2033\306\211_\307\245!\211_\307\245\307\245U\203,\310\f #\210 T\211\202* T\211\202*\f\207" [5x5-grid-size y --dotimes-limit-- x solution 0 random 2 5x5-flip-cell] 5 (#$ . 14216)]) #@114 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\n W\203K \310\f W\203C\n\f\311\n\f#\203*\312 \210\313E!\210\314 \210\315!\210\fT\211\202*\nT\211\202\n+\207" [inhibit-quit 5x5-grid-size y --dotimes-limit-- x 5x5-y-pos 5x5-new-game t 0 5x5-cell 5x5-flip-current 5x5-draw-grid 5x5-position-cursor sit-for 5x5-x-pos solution 5x5-grid best 5x5-animate-delay] 5 (#$ . 14524)]) #@131 Convert GRID to an equivalent Calc matrix of (mod X 2) forms where X is 1 for setting a position, and 0 for unsetting a position. (defalias '5x5-grid-to-vec #[(grid) "\301\302\303\"B\207" [grid vec mapcar #[(y) "\301\302\303\"B\207" [y vec mapcar #[(x) "\203\301\207\302\207" [x (mod 1 2) (mod 0 2)] 1]] 4]] 4 (#$ . 15062)]) #@108 Convert a grid matrix GRID-MATRIX in Calc format to a grid in 5x5 format. See function `5x5-grid-to-vec'. (defalias '5x5-vec-to-grid #[(grid-matrix) "\301\302\303\304A\"\"\207" [grid-matrix apply vector mapcar #[(x) "\301\302\303\304A\"\"\207" [x apply vector mapcar #[(y) "A@\301U?\207" [y 0] 2]] 5]] 5 (#$ . 15399)]) (byte-code "\300\301\302\"\210\300\303\304\"\207" [defalias 5x5-log-init #[nil "\300\207" [nil] 1] 5x5-log #[(name value) "\207" [value] 1]] 3) #@465 Return a list of solutions for GRID. Given some grid GRID, the returned a list of solution LIST is sorted from least Hamming weight to greatest one. LIST = (SOLUTION-1 ... SOLUTION-N) Each solution SOLUTION-I is a cons cell (HW . G) where HW is the Hamming weight of the solution --- ie the number of strokes to achieve it --- and G is the grid of positions to click in order to complete the 5x5. Solutions are sorted from least to greatest Hamming weight. (defalias '5x5-solver #[(grid) "\306\307!\210\310\311\n\211_\312\313\314\f!\315\"\316\317 \315#2\320 2\"*343*5\321\314 \322 )6\n\3237878W\203\301\n\3239898W\203\267\3247_9\\:\3256:\211\326$\2107\323V\203t\3256:\nZ:\326$\2107T\nW\203\210\3256:\n\\:\326$\2109\323V\203\232\3256:S:\326$\2109T\nW\203\255\3256:T:\326$\210)9T\2119\202I*7T\2117\202;*6)!343*;\n\324U\203\331\327\202\334\330\331!<\332\333\315 \"!=\334=\337\340>!343*?\341\342?\342;>\"\"343*@\343\342?5\"343*A\344\345\315<#B\344\315< #C\344\345\315