Light Up
Simon Tatham's Portable Puzzle Collection is a nice collection of puzzle games that should be interesting to solve automatically. I installed the Android version of the collection and played a little with Light Up.
You have a grid of squares. Some are filled in black; some of the black squares are numbered. Your aim is to ‘light up’ all the empty squares by placing light bulbs in some of them.
Each light bulb illuminates the square it is on, plus all squares in line with it horizontally or vertically unless a black square is blocking the way.
To win the game, you must satisfy the following conditions:
- All non-black squares are lit.
- No light is lit by another light.
- All numbered black squares have exactly that number of lights adjacent to them (in the four squares above, below, and to the side).
Non-numbered black squares may have any number of lights adjacent to them.
First thing, board representation and some diagrams code to obtain a graphical rendition.
import Diagrams.Prelude import Diagrams.Backend.SVG.CmdLine data Square = Empty | Box | Light | Lamp | Num Integer type Board = [[Square]] board :: Board board = [[Empty, Box, Light, Empty, Box, Empty, Empty], [Empty, Empty, Light, Empty, Box, Empty, Num 0], [Box, Num 2, Lamp, Light, Light, Light, Light], [Empty, Empty, Light, Empty, Empty, Empty, Empty], [Empty, Empty, Light, Empty, Empty, Num 1, Num 1], [Num 2, Empty, Box, Empty, Empty, Empty, Empty], [Empty, Empty, Num 1, Empty, Empty, Num 0, Empty]] squareSize = 30 drawSquare Empty = square squareSize drawSquare Box = square squareSize # fc black drawSquare Light = square squareSize # fc yellow drawSquare Lamp = circle (squareSize * 0.3) # fc white <> square squareSize # fc yellow drawSquare (Num n) = text (show n) # fc white # fontSize (Local 16) <> square squareSize # fc black drawBoard :: Board -> Diagram B R2 drawBoard b = vcat . map (alignR . hcat) . (map . map) drawSquare $ board sketch = drawBoard board main = mainWith sketch