comparison lisp/games/blackbox.el @ 72:b9518feda344 r20-0b31

Import from CVS: tag r20-0b31
author cvs
date Mon, 13 Aug 2007 09:03:46 +0200
parents 131b0175ea99
children 54cc21c15cbb
comparison
equal deleted inserted replaced
71:bae944334fa4 72:b9518feda344
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of 17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details. 19 ;; General Public License for more details.
20 20
21 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING. If not, write to the 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ;; Boston, MA 02111-1307, USA. 24 ;; 02111-1307, USA.
25 25
26 ;;; Synched up with: FSF 19.28. 26 ;;; Synched up with: FSF 19.34.
27 27
28 ;;; Commentary: 28 ;;; Commentary:
29 29
30 ; by F. Thomas May <uw-nsr!uw-warp!tom@beaver.cs.washington.edu> 30 ;; by F. Thomas May <uw-nsr!uw-warp!tom@beaver.cs.washington.edu>
31 ; doc comment by Root Boy Jim <rbj@dsys.icst.nbs.gov>, 27 Apr 89 31 ;; doc comment by Root Boy Jim <rbj@dsys.icst.nbs.gov>, 27 Apr 89
32 ; interface improvements by ESR, Dec 5 1991. 32 ;; interface improvements by ESR, Dec 5 1991.
33 33
34 ; The object of the game is to find four hidden balls by shooting rays 34 ;; The object of the game is to find four hidden balls by shooting rays
35 ; into the black box. There are four possibilities: 1) the ray will 35 ;; into the black box. There are four possibilities: 1) the ray will
36 ; pass thru the box undisturbed, 2) it will hit a ball and be absorbed, 36 ;; pass thru the box undisturbed, 2) it will hit a ball and be absorbed,
37 ; 3) it will be deflected and exit the box, or 4) be deflected immediately, 37 ;; 3) it will be deflected and exit the box, or 4) be deflected immediately,
38 ; not even being allowed entry into the box. 38 ;; not even being allowed entry into the box.
39 ; 39
40 ; The strange part is the method of deflection. It seems that rays will 40 ;; The strange part is the method of deflection. It seems that rays will
41 ; not pass next to a ball, and change direction at right angles to avoid it. 41 ;; not pass next to a ball, and change direction at right angles to avoid it.
42 ; 42 ;;
43 ; R 3 43 ;; R 3
44 ; 1 - - - - - - - - 1 44 ;; 1 - - - - - - - - 1
45 ; - - - - - - - - 45 ;; - - - - - - - -
46 ; - O - - - - - - 3 46 ;; - O - - - - - - 3
47 ; 2 - - - - O - O - 47 ;; 2 - - - - O - O -
48 ; 4 - - - - - - - - 48 ;; 4 - - - - - - - -
49 ; 5 - - - - - - - - 5 49 ;; 5 - - - - - - - - 5
50 ; - - - - - - - - R 50 ;; - - - - - - - - R
51 ; H - - - - - - - O 51 ;; H - - - - - - - O
52 ; 2 H 4 H 52 ;; 2 H 4 H
53 ; 53 ;;
54 ; Rays which enter and exit are numbered. You can see that rays 1 & 5 pass 54 ;; Rays which enter and exit are numbered. You can see that rays 1 & 5 pass
55 ; thru the box undisturbed. Ray 2 is deflected by the northwesternmost 55 ;; thru the box undisturbed. Ray 2 is deflected by the northwesternmost
56 ; ball. Likewise rays 3 and 4. Rays which hit balls and are absorbed are 56 ;; ball. Likewise rays 3 and 4. Rays which hit balls and are absorbed are
57 ; marked with H. The bottom of the left and the right of the bottom hit 57 ;; marked with H. The bottom of the left and the right of the bottom hit
58 ; the southeastern ball directly. Rays may also hit balls after being 58 ;; the southeastern ball directly. Rays may also hit balls after being
59 ; reflected. Consider the H on the bottom next to the 4. It bounces off 59 ;; reflected. Consider the H on the bottom next to the 4. It bounces off
60 ; the NW-ern most ball and hits the central ball. A ray shot from above 60 ;; the NW-ern most ball and hits the central ball. A ray shot from above
61 ; the right side 5 would hit the SE-ern most ball. The R beneath the 5 61 ;; the right side 5 would hit the SE-ern most ball. The R beneath the 5
62 ; is because the ball is returned instantly. It is not allowed into 62 ;; is because the ball is returned instantly. It is not allowed into
63 ; the box if it would reflect immediately. The R on the top is a more 63 ;; the box if it would reflect immediately. The R on the top is a more
64 ; leisurely return. Both central balls would tend to deflect it east 64 ;; leisurely return. Both central balls would tend to deflect it east
65 ; or west, but it cannot go either way, so it just retreats. 65 ;; or west, but it cannot go either way, so it just retreats.
66 ; 66
67 ; At the end of the game, if you've placed guesses for as many balls as 67 ;; At the end of the game, if you've placed guesses for as many balls as
68 ; there are in the box, the true board position will be revealed. Each 68 ;; there are in the box, the true board position will be revealed. Each
69 ; `x' is an incorrect guess of yours; `o' is the true location of a ball. 69 ;; `x' is an incorrect guess of yours;; `o' is the true location of a ball.
70 70
71 ;;; Code: 71 ;;; Code:
72 72
73 (defvar blackbox-mode-map nil "") 73 (defvar blackbox-mode-map nil "")
74 74
234 (interactive "P") 234 (interactive "P")
235 (switch-to-buffer "*Blackbox*") 235 (switch-to-buffer "*Blackbox*")
236 (blackbox-mode) 236 (blackbox-mode)
237 (setq buffer-read-only t) 237 (setq buffer-read-only t)
238 (buffer-disable-undo (current-buffer)) 238 (buffer-disable-undo (current-buffer))
239 ;; XEmacs makes some local variables here and FSF doesn't.
239 (make-local-variable 'bb-board) 240 (make-local-variable 'bb-board)
240 (setq bb-board (bb-init-board (or num 4))) 241 (setq bb-board (bb-init-board (or num 4)))
241 (make-local-variable 'bb-balls-placed) 242 (make-local-variable 'bb-balls-placed)
242 (setq bb-balls-placed nil) 243 (setq bb-balls-placed nil)
243 (make-local-variable 'bb-x) 244 (make-local-variable 'bb-x)
432 (cond 433 (cond
433 ((equal item (car list)) (cdr list)) 434 ((equal item (car list)) (cdr list))
434 (t (cons (car list) (bb-delete item (cdr list)))))) 435 (t (cons (car list) (bb-delete item (cdr list))))))
435 436
436 ;;; blackbox.el ends here 437 ;;; blackbox.el ends here
437
438