Function Repository Resource:

LightsOutGame

Source Notebook

Start a Lights Out game

Contributed by: Aster Ctor

ResourceFunction["LightsOutGame"][n]

starts an n×n game of Lights Out.

ResourceFunction["LightsOutGame"][n,m]

starts an n×m game.

Details and Options

White indicates a lit light; black indicates a light that is extinguished.
Turn off all the lights to win.
The algorithm avoids the generation of games with no solution.
The solution of higher-rank games can be extremely complicated, but the algorithm guarantees at least one solution.

Examples

Basic Examples (1) 

Start a game with two rows and two columns:

In[1]:=
ResourceFunction["LightsOutGame"][2]
Out[1]=

Scope (1) 

Start a game with two rows and three columns:

In[2]:=
ResourceFunction["LightsOutGame"][2, 3]
Out[2]=

Options (2) 

Mode (2) 

The game has two modes. Normal mode is initially all white:

In[3]:=
ResourceFunction["LightsOutGame"][3, Mode -> Normal]
Out[3]=

By contrast, random mode starts with a random collection of white and black squares:

In[4]:=
ResourceFunction["LightsOutGame"][3, 3, Mode -> Random]
Out[4]=

Publisher

Aster Ctor (MoeNet)

Version History

  • 1.0.0 – 04 November 2019

Related Resources

License Information