Mercurial > hg > xemacs-beta
comparison lisp/games/blackbox.el @ 4:b82b59fe008d r19-15b3
Import from CVS: tag r19-15b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:56 +0200 |
parents | 376386a54a3c |
children | 461c7ba8286a |
comparison
equal
deleted
inserted
replaced
3:30df88044ec6 | 4:b82b59fe008d |
---|---|
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 Free | 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
23 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
24 | 24 ;; 02111-1307, USA. |
25 ;;; Synched up with: FSF 19.28. | 25 |
26 ;;; Synched up with: FSF 19.34. | |
26 | 27 |
27 ;;; Commentary: | 28 ;;; Commentary: |
28 | 29 |
29 ; 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> |
30 ; 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 |
31 ; interface improvements by ESR, Dec 5 1991. | 32 ;; interface improvements by ESR, Dec 5 1991. |
32 | 33 |
33 ; 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 |
34 ; 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 |
35 ; 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, |
36 ; 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, |
37 ; not even being allowed entry into the box. | 38 ;; not even being allowed entry into the box. |
38 ; | 39 |
39 ; 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 |
40 ; 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. |
41 ; | 42 ;; |
42 ; R 3 | 43 ;; R 3 |
43 ; 1 - - - - - - - - 1 | 44 ;; 1 - - - - - - - - 1 |
44 ; - - - - - - - - | 45 ;; - - - - - - - - |
45 ; - O - - - - - - 3 | 46 ;; - O - - - - - - 3 |
46 ; 2 - - - - O - O - | 47 ;; 2 - - - - O - O - |
47 ; 4 - - - - - - - - | 48 ;; 4 - - - - - - - - |
48 ; 5 - - - - - - - - 5 | 49 ;; 5 - - - - - - - - 5 |
49 ; - - - - - - - - R | 50 ;; - - - - - - - - R |
50 ; H - - - - - - - O | 51 ;; H - - - - - - - O |
51 ; 2 H 4 H | 52 ;; 2 H 4 H |
52 ; | 53 ;; |
53 ; 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 |
54 ; thru the box undisturbed. Ray 2 is deflected by the northwesternmost | 55 ;; thru the box undisturbed. Ray 2 is deflected by the northwesternmost |
55 ; 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 |
56 ; 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 |
57 ; the southeastern ball directly. Rays may also hit balls after being | 58 ;; the southeastern ball directly. Rays may also hit balls after being |
58 ; 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 |
59 ; 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 |
60 ; 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 |
61 ; 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 |
62 ; 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 |
63 ; leisurely return. Both central balls would tend to deflect it east | 64 ;; leisurely return. Both central balls would tend to deflect it east |
64 ; 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. |
65 ; | 66 |
66 ; 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 |
67 ; 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 |
68 ; `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. |
69 | 70 |
70 ;;; Code: | 71 ;;; Code: |
71 | 72 |
72 (defvar blackbox-mode-map nil "") | 73 (defvar blackbox-mode-map nil "") |
73 | 74 |
233 (interactive "P") | 234 (interactive "P") |
234 (switch-to-buffer "*Blackbox*") | 235 (switch-to-buffer "*Blackbox*") |
235 (blackbox-mode) | 236 (blackbox-mode) |
236 (setq buffer-read-only t) | 237 (setq buffer-read-only t) |
237 (buffer-disable-undo (current-buffer)) | 238 (buffer-disable-undo (current-buffer)) |
239 ;; XEmacs makes some local variables here and FSF doesn't. | |
238 (make-local-variable 'bb-board) | 240 (make-local-variable 'bb-board) |
239 (setq bb-board (bb-init-board (or num 4))) | 241 (setq bb-board (bb-init-board (or num 4))) |
240 (make-local-variable 'bb-balls-placed) | 242 (make-local-variable 'bb-balls-placed) |
241 (setq bb-balls-placed nil) | 243 (setq bb-balls-placed nil) |
242 (make-local-variable 'bb-x) | 244 (make-local-variable 'bb-x) |
431 (cond | 433 (cond |
432 ((equal item (car list)) (cdr list)) | 434 ((equal item (car list)) (cdr list)) |
433 (t (cons (car list) (bb-delete item (cdr list)))))) | 435 (t (cons (car list) (bb-delete item (cdr list)))))) |
434 | 436 |
435 ;;; blackbox.el ends here | 437 ;;; blackbox.el ends here |
436 | |
437 |