lights_out_game


lights_out_game, a C++ code which sets up the Lights Out game and allows a user to try to solve it, using opengl() for graphics display.

The Lights Out game is played on a rectangular board of squares, each representing a light that may be on or off. Clicking the mouse on a light switches it from on to off and vice versa. However, when you switch a light, you also switch the lights to the immediate left, right, above and below. (There is no "wrap around" however, in this basic version of the game.)

You start the game by specifying the width and height of the board to be used, and the number of moves the program should make in setting up the inital board. Specifying 10 moves, for instance, means that the program, starting from a board with all lights off, will randomly switch a light and its neighbors 10 times.

Usage:

lights_out_game width height moves
where

Licensing:

The information on this web page is distributed under the MIT license.

Languages:

lights_out_game is available in a C version and a C++ version and a MATLAB version.

Related Data and Programs:

opengl_test, a C++ code which uses opengl() to display graphic images on the screen;

Reference:

  1. Marlow Anderson, Todd Feil,
    Turning Lights Out With Linear Algebra,
    Mathematics Magazine,
    Volume 71, Number 4, October 1998, pages 300-303.
  2. Edward Angel,
    Interactive Computer Graphics, a Top-Down Approach with OpenGL,
    Addison-Wesley, 2000,
    ISBN: 0-201-38597-X,
    LC: T385.A514.
  3. Oscar Martin-Sanchez,
    Two Analyses of Lights Out,
    Mathematics Magazine,
    Volume 74, Number 4, October 2001, pages 295-304.

Source Code:


Last revised on 10 November 2024.