Games · Project
Build Lights in Python
A puzzle on a five-by-five grid: a click switches a light and its neighbours, and the goal is to turn every light off.
You write: The whole program, from a description: the grid, the switching rule, the picture, the move count and the end.
Loading the game…
What to build
A grid of lights, five rows of five. Some are on. Clicking a light switches it, and the lights directly above, below, left and right of it: on becomes off, and off becomes on. A light at an edge has fewer neighbours. The puzzle is solved when every light is off, and after that clicks do nothing. Show the number of moves.
Start with the plus shape in the starter: one click solves it, which makes a first test. Then try a harder start of your own.
Not sure where to start?
This game is part of “Build a Game”, a lesson of Build with Python. The lesson builds up to it, and the course before it starts from zero. Both are free.
Read the lessonSee the courseMore games
- Hit the Target: A first click game: every click lands a dot, green inside the target and red outside.
- Tic-Tac-Toe: A two-player Tic-Tac-Toe you can play in the page: turns, a win in any line, and a draw.
- Four in a Row: A game for two: counters drop down the columns of a board, and four in a line wins.
- Pairs: A memory game: sixteen face-down cards hide eight pairs, and a turn flips two.