Black Box Game

Introduction

Create a Python version of the BLACK BOX game that appeared in the August 1977 issue of "Games and Puzzles".

The BLACK BOX is an 8-by-8 square contains several hidden atoms.

The object of the game is to locate the position of the atoms in the BLACK BOX by sending rays into the box and seeing where they exit.

Note: Rays are deflected, reflected, or absorbed by atoms.

Ray entry points are numbered 1 to 32 starting at the top of the left corner of the BLACK BOX and going counter clockwise. (See the BLACK BOX example.)

Note: Rays travel horizontally or vertically until they encounter an atom. (See the BLACK BOX example.)

How to Play The Game

  1. You first specify the number of atoms to randomly place in the BLACK BOX.
  2. You then enter rays one at a time.
  3. Each time you specify a ray entry point, Your are told where the ray exited or if it was absorbed.
  4. Enter a zero (0) to end the game and display the BLACK BOX and its hidden atoms.

Were you able to determine the location of the atoms in the BLACK BOX?

Ray Path Rules

  1. Rays that strike an atom directly are absorbed.
  2. Rays that come within one square of an atom are deflected 90° away from the atom.
  3. Rays aimed between two atoms one square apart are reflected.
  4. Rays that enter on either side of an atom on the edge of the BLACK BOX are reflected.
  5. Rays travel in a straight line unless they encounter an atom.

BLACK BOX Example

Ray Entry Points
image missing
Cell Numbers
image missing

Design Notes

1. Limit the number of atoms in the BLACK BOX to 1 to 5.
2. Occasionally an atom can be masked by the other atoms.
3. Entering bad data will generate an error message.
4. Example of one possible interaction with the BLACK BOX game.

Convert Cell Number to X,Y Coords

cell = 11 x = (cell - 1) % 8 y = int(cell/8) print(x,y)