;ELC ;;; compiled by kwzh@hal.gnu.ai.mit.edu on Tue May 2 20:13:49 1995 ;;; from file /gd/gnu/emacs/19.0/lisp/blackbox.el ;;; emacs version 19.28.90.69. ;;; 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"))) (error "`/gd/gnu/emacs/19.0/lisp/blackbox.el' was compiled for Emacs 19")) #@2  (defvar blackbox-mode-map nil (#$ . 484)) (byte-code "„`Á ÂÃ\"ˆÄÅÆ#ˆÄÇÆ#ˆÄÈÉ#ˆÄÊÉ#ˆÄËÌ#ˆÄÍÌ#ˆÄÎÏ#ˆÄÐÏ#ˆÄÑÒ#ˆÄÓÔ#ˆÄÕÖ#ˆÄ×Ö#ˆÄØÙ#ˆÄÚÙ#ˆÛÜÝÞ#‡" [blackbox-mode-map make-keymap suppress-keymap t define-key "" bb-right [right] "" bb-left [left] "" bb-up [up] "" bb-down [down] "" bb-eol "" bb-bol " " bb-romp [insert] " " bb-done [kp-enter] put blackbox-mode mode-class special] 4) #@372 Major mode for playing blackbox. To learn how to play blackbox, see the documentation for function `blackbox'. The usual mnemonic keys move the cursor around the box. \\[bb-bol] and \[bb-eol] move to the beginning and end of line, respectively. \[bb-romp] -- send in a ray from point, or toggle a ball at point \[bb-done] -- end game and get score  (defalias 'blackbox-mode #[nil "À ˆÁ\n!ˆÃÅlj‡" [kill-all-local-variables use-local-map blackbox-mode-map t truncate-lines blackbox-mode major-mode "Blackbox" mode-name] 2 (#$ . 892) nil]) #@5066 Play blackbox. Optional prefix argument is the number of balls; the default is 4. What is blackbox? Blackbox is a game of hide and seek played on an 8 by 8 grid (the Blackbox). Your opponent (Emacs, in this case) has hidden several balls (usually 4) within this box. By shooting rays into the box and observing where they emerge it is possible to deduce the positions of the hidden balls. The fewer rays you use to find the balls, the lower your score. Overview of play: \To play blackbox, type \[blackbox]. An optional prefix argument specifies the number of balls to be hidden in the box; the default is four. The cursor can be moved around the box with the standard cursor movement keys. To shoot a ray, move the cursor to the edge of the box and press SPC. The result will be determined and the playfield updated. You may place or remove balls in the box by moving the cursor into the box and pressing \[bb-romp]. When you think the configuration of balls you have placed is correct, press \[bb-done]. You will be informed whether you are correct or not, and be given your score. Your score is the number of letters and numbers around the outside of the box plus five for each incorrectly placed ball. If you placed any balls incorrectly, they will be indicated with `x', and their actual positions indicated with `o'. Details: There are three possible outcomes for each ray you send into the box: Detour: the ray is deflected and emerges somewhere other than where you sent it in. On the playfield, detours are denoted by matching pairs of numbers -- one where the ray went in, and the other where it came out. Reflection: the ray is reflected and emerges in the same place it was sent in. On the playfield, reflections are denoted by the letter `R'. Hit: the ray strikes a ball directly and is absorbed. It does not emerge from the box. On the playfield, hits are denoted by the letter `H'. The rules for how balls deflect rays are simple and are best shown by example. As a ray approaches a ball it is deflected ninety degrees. Rays can be deflected multiple times. In the diagrams below, the dashes represent empty box locations and the letter `O' represents a ball. The entrance and exit points of each ray are marked with numbers as described under "Detour" above. Note that the entrance and exit points are always interchangeable. `*' denotes the path taken by the ray. Note carefully the relative positions of the ball and the ninety degree deflection it causes. 1 - * - - - - - - - - - - - - - - - - - - - - - - - * - - - - - - - - - - - - - - - - - - - - - - 1 * * - - - - - - - - - - - - - - - O - - - - O - - - O - - - - - - - O - - - - - - - * * * * - - - - - - - - - - - - - * * * * * 2 3 * * * - - * - - - - - - - - - - - - - * - - - - - - - O - * - - - - - - - - - - - - - * - - - - - - - - * * - - - - - - - - - - - - - * - - - - - - - - * - O - 2 3 As mentioned above, a reflection occurs when a ray emerges from the same point it was sent in. This can happen in several ways: - - - - - - - - - - - - - - - - - - - - - - - - - - - - O - - - - - O - O - - - - - - - - - - - R * * * * - - - - - - - * - - - - O - - - - - - - - - - - O - - - - - - * - - - - R - - - - - - - - - - - - - - - - - - - * - - - - - - - - - - - - - - - - - - - - - - - * - - - - - - - - - - - - - - - - - - - - R * * * * - - - - - - - - - - - - - - - - - - - - - - - - O - - - - - - - - - - - In the first example, the ray is deflected downwards by the upper ball, then left by the lower ball, and finally retraces its path to its point of origin. The second example is similar. The third example is a bit anomalous but can be rationalized by realizing the ray never gets a chance to get into the box. Alternatively, the ray can be thought of as being deflected downwards and immediately emerging from the box. A hit occurs when a ray runs straight into a ball: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - O - - - - - - - - - - - - - - - O - - - H * * * * - - - - - - - - - - - - H * * * * O - - - - - - * - - - - - - - - - - - - - - - - O - - - - - - O - - - - H * * * O - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Be sure to compare the second example of a hit with the first example of a reflection. (defalias 'blackbox #[(num) "ÀÁ!ˆÂ ˆÃÅp!ˆÆ†È! Ê Ì ÌÏÏÒ ˆÓ B!‡" [switch-to-buffer "*Blackbox*" blackbox-mode t buffer-read-only buffer-disable-undo bb-init-board num 4 bb-board nil bb-balls-placed -1 bb-x bb-y 0 bb-score bb-detour-count bb-insert-board bb-goto] 3 (#$ . 1464) "P"]) (defalias 'bb-init-board #[(num-balls) "ÀÁ!ˆÂ‰ S‰ÆYƒ'ÀÇ!ÀÇ!BÈ \f\"„ \fB‚\f*‡" [random t nil pos board num-balls 0 8 bb-member] 3]) (defalias 'bb-insert-board #[nil "À‰à ˆÄcˆÅ\nS‰ÆYƒÇcˆ‚\fÄcˆÈÉ\nG\"c*‡" [nil buffer-read-only i erase-buffer " \n" 8 0 " - - - - - - - - \n" format "\nThere are %d balls in the box" bb-board] 3]) (defalias 'bb-right #[nil "ÁU?…ÂuˆT‰‡" [bb-x 8 2] 2 nil nil]) (defalias 'bb-left #[nil "ÁU?…ÂÃ!ˆS‰‡" [bb-x -1 backward-char 2] 2 nil nil]) (defalias 'bb-up #[nil "ÁU?…ÂÃ!ˆS‰‡" [bb-y -1 previous-line 1] 2 nil nil]) (defalias 'bb-down #[nil "ÁU?…ÂÃ!ˆT‰‡" [bb-y 8 next-line 1] 2 nil nil]) (defalias 'bb-eol #[nil "À B!‡" [8 bb-x bb-goto bb-y] 3 nil nil]) (defalias 'bb-bol #[nil "À B!‡" [-1 bb-x bb-goto bb-y] 3 nil nil]) (defalias 'bb-romp #[nil "ÁU„\fÂUƒ ÁU†( ÂU†(Ä \"ƒ$Å \"‡Æ \"‡" [bb-x -1 8 bb-y bb-outside-box bb-trace-ray bb-place-ball] 3 nil nil]) (defalias 'bb-place-ball #[(x y) " BÃ\n\f\"ƒÅ\n\f\"ÆÇ!‚\n\fBÆÈ!)‡" [x y coord bb-member bb-balls-placed bb-delete bb-update-board "-" "O"] 3]) (defalias 'bb-trace-ray #[(x y) "ÀÁ\n‰ÃUƒ Ä‚\nÅUƒÂƉÃUƒ$Ä‚0ÅUƒ/Â0Æ%‰É=ƒFÊË!ˆ\fT‰\f‚€\nBšƒ]ÊÍ!ˆ\fT‰\f‚€TÊÏÐ\"!ˆŠÑ!ˆÊÏÐ\"!ˆ)\fÒ\\‰\f)‡" [bb-trace-ray-2 t x -1 1 8 0 y result hit bb-update-board "H" bb-score "R" bb-detour-count format "%d" bb-goto 2] 8]) (defalias 'bb-trace-ray-2 #[(first x dx y dy) "„Á\n \"ƒ\n B‡Ä\n \\ \\B\"ƒ ȇÄ\n \\\\  \\\\B\"ƒ?ÉÊ\n[ [%‡Ä\n [\\\\  [\\\\B\"ƒ^ÉÊ\n %‡ÉÊ\n \\ \\%‡" [first bb-outside-box x y bb-member dx dy bb-board hit bb-trace-ray-2 nil] 6]) #@35 Finish the game and report score. (defalias 'bb-done #[nil "À\nG GU„,ÄÅ GÆUƒÇ‚È G GÆUƒ%É‚&Ê\nG%‚YË\n \"‰ÌUƒ@ÄÍ\"ˆ‚VÄÏ ‰ÆUƒMÉ‚NÊ Ð_\\$ˆÑÒ!)‡" [nil bogus-balls bb-balls-placed bb-board message "There %s %d hidden ball%s; you have placed %d." 1 "is" "are" "" "s" bb-show-bogus-balls 0 "Right! Your score is %d." bb-score "Oops! You missed %d ball%s. Your score is %d." 5 bb-goto (-1 . -1)] 8 (#$ . 8496) nil]) (defalias 'bb-show-bogus-balls #[(balls-placed board) "À \nÃ#ˆÀ\n Ä#‡" [bb-show-bogus-balls-2 balls-placed board "x" "o"] 4]) (defalias 'bb-show-bogus-balls-2 #[(list-1 list-2 c) "„Á‡Â@ \"ƒÄA #‡Æ@!ˆÇ !ˆÄA #T‡" [list-1 0 bb-member list-2 bb-show-bogus-balls-2 c bb-goto bb-update-board] 4]) (defalias 'bb-outside-box #[(x y) "ÁU†ÂU† ÁU† ÂU‡" [x -1 8 y] 2]) (defalias 'bb-goto #[(pos) "@Á_AÂ_Ã\\\\b‡" [pos 2 22 26] 3]) (defalias 'bb-update-board #[(c) "À GS!ˆÄ G!ˆ cˆÂÅ!)‡" [nil buffer-read-only backward-char c delete-char 1] 2]) #@47 Returns non-nil if ELT is an element of LIST. (defalias 'bb-member #[(elt list) "ÀÁÂÃ\f\"B!‡" [eval or mapcar #[(x) " š‡" [x elt] 2] list] 5 (#$ . 9482)]) #@44 Deletes ITEM from LIST and returns a copy. (defalias 'bb-delete #[(item list) " @šƒ\n A‡ @ A\"B‡" [item list bb-delete] 4 (#$ . 9644)])