Giter VIP home page Giter VIP logo

lights-out2's Introduction

Lights Out solver

A Python solver of the Lights Out game for a square board of arbitrary size n.

The solver works by inverting the adjacency matrix of a grid graph of the size of the board. The matrix is defined over the Galois Field GF(2), and the inversion is performed in this field using Gauss-Jordan elimination.

For some board sizes n (eg., n=5) the adjacency matrix is rank deficient. This means that for those sizes some initial configurations have no solution and some other configurations have several solutions. The solver determines if a given configuration is solvable. In that case, it finds the simplest solution, ie., the solution with the minimum number of movements. To do this, it computes a base of the right null space of the adjacency matrix.

Usage

The module lightsout.py implements the solver. The class lightsout.LighsOut offers a simple interface to the module. See the function lightsout.main for an example.

You can also try the Lights Out solver with a simple GUI using the script lightsoutgui.py. Execute the script with:

$ python lightsoutgui.py 5

The first parameter indicates the board size. If omitted, it defaults to 5.

Screenshot

https://github.com/pmneila/Lights-Out/raw/master/screenshot.png

The initial setup of the board is given by red and green lights. The dark marks indicate the keys the player must press to turn the green lights red.

lights-out2's People

Contributors

pmneila avatar kitizz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.