Introduction
Moonlight is an excellent puzzle game created by Naoki Inaba which we discovered in a 2022 Guardian puzzle supplement by Alex Bellos.
The puzzle is a square grid of cells. At the start of a game most of the cells are empty but some contain circular moons, the majority of which have both black and white segments, the white areas being the faces of the moon that are illuminated. The illumination comes from stars drawn as yellow circles which can light up unobstructed moons in their row and column. At the start these stars are not shown. Also missing are clouds, drawn as black squares. These block the light from any star in the same row or column. Moons also block the light.
The object of the game is to place one star and one cloud in each row and column of the grid in order to satisfy the lighting of the moons. Potentially any cell without a moon can be a star or a cloud. This potential is denoted by yellow and black buttons which we call star_open and cloud_open buttons. The buttons are used to delete or restore the corresponding potential. At the end of a game they will all have been deleted or replaced by stars or clouds.
The program contains 500 puzzles roughly sorted in order of difficulty, 200 of size 6 x 6, 200 7 x 7 and 100 8 x 8.
Moonlight Example

A screenshot from moonlight. It shows the 6 x 6 grid of a simple puzzle after the player has made a start by placing two stars and one cloud. The star on the bottom row could not be anywhere else! Similarly there were only two choices for a star on the next row and one of these positions would have incorrectly illuminated the unlit side of a moon in the row above. So again, no real choice. The moon in the top right corner is lit from below so there can be no clouds between it and the star, so the cloud for that column must be in the bottom corner. A cell highlighted with a yellow box shows the current cursor position and it looks like the player has realised that that cell cannot contain a cloud, and is about to delete the cloud_open button. Notice that the rows and columns with set stars and clouds have been cleared of the corresponding buttons. This happens automatically when the shapes are set.
Playing
The program starts with a randomly selected puzzle displayed. The object of the game is to place one star and one cloud in each row and column of the grid in order to satisfy the lighting of the moons. Potentially any cell without a moon can be a star or a cloud. While they remain visible this potential is denoted by the yellow and black buttons. We call these star_open and cloud_open buttons. A right click on either button will remove it, its absence indicating that the player has decided that the cell cannot be a star or a cloud. A left click will reinstate a button. A left click in the centre of a cell will set a star, a right click a cloud. A middle click in a star or cloud will remove it.
If a star or a cloud is set, or the last star_open or cloud_open button in a row or column is deleted the game will automatically delete any other affected buttons in the orthogonal strips, setting stars or clouds accordingly. This convenience is diminished by the concomitant functionality that when errors are automatically corrected some innocent indicator buttons may be restored!
In the toolbar the jigsaw symbol contains a menu, the next symbol starts a new game (left click a random puzzle, right click the next in sequence); the wand requests a hint, a second click on the wand will perform the hint operation; the thumb checks if the puzzle contains any errors and a second click will clear the errors; the sad smiley shows the solution; the entrybox shows the current puzzle number and can be used to select a new puzzle number; the number next to the puzzle number is the puzzle difficulty score. The clock ticks every 5 seconds but will be replaced by the algorithm code if a hint is requested. A left click on the hint button will request a hint. While the hint is active (shown by the wand icon leaning leftwards) clicking on the wand with the middle mouse button will cause a pop-up to appear containing a short explanation of the hint. Hints are shown by highlighting a cell whose solution can be deduced by the current state of the puzzle. A further left click on the wand will set that solution.
If an error is found, either by the player clicking on the thumb icon or by asking for a hint, the thumb will turn down and the individual errors are shown by colouring the incorrect shapes or buttons red. A click on the thumb will unset the errors as well as other buttons in their row and column.
The menu revealed by clicking on the puzzle icon gives access to the online help and options to set the puzzle size and some of the puzzle colours.
Moonlight Worked Example
A video from moonlight showing the solving of a simple puzzle. The player starts by using the puzzle number box to enter a new puzzle number. She quickly sets the no-choice star on the bottom row and the almost no choice on the row above and recognises that the cloud for the righthand column cannot be between the star and the moon at the top. Next, there cannot be cloud between the star in the right column and the moon to its left. Then she deletes a cloud_open next to a lit side of a moon and star_open which can only be blocked, a cloud_open next to a lit side, a star_open next to an unlit side, and so on. Notice the automatic setting of consequences where appropriate. In the end the puzzle is finished and the clock flashes, then stops.
Hard Guardian Puzzle

This is the hard example from the Guardian's puzzle supplement. Notice that there are many strips where either there is no moon, or, given the positions and illumination of the moons, the choices for the possible location of the stars is very wide. On our simple difficulty rating it gets a value of 102. The hardest puzzle in our game has a rating of 105.
Algorithms
The algorithms used by Moonlight are explained using examples. When the player requests a hint the program displays a yellow surround in a cell whose answer can be deduced from the current state of the puzzle. Below we show one hint example for each algorithm.
Alg_0

Use the moon's illumination to set their immediate neighbours star and cloud status values: the cell next to the unlit side of a moon cannot be a star, the cell next to the lit side of a moon cannot be a cloud.
Here the adjacent moon is lit from below so the hint cell cannot contain a cloud.
Alg_1

If there is only one star_open or cloud_open in a strip it means any star_opens or cloud_opens in the orthogonal strips can be unset. Note this algorithm does not set the remaining star_opens and cloud_opens as stars or clouds.
Here there is only one cloud_open in the fourth column which means that cell must be the cloud for that row and so the highlighted cell cannot be a cloud.
Alg_2

If a moon is lit from a side no cloud can come between it and the nearest star.
Here the highlighted cell cannot be a cloud as it would block the light from the star on the row.
Alg_3

If a moon is lit from a side no star can exist on the opposite side.
Here a moon in the top row is lit from the left so there can be no star to its right.
Alg_4

If a moon is not lit from a side and has open stars on this side there must be a cloud on this unlit side between it and all the open stars. So no cloud can be beyond or level with the furthest open star.
Here the top of the second column has a moon which is not lit from below, so there must be a cloud between it and the star. Hence the highlighted cell cannot be a cloud.
Alg_5

If a moon is not lit from a side and has open stars on this side there must be a cloud or a blocking object on this unlit side between it and all the open stars. Hence there cannot be a cloud on the other side of the moon.
Here the star in the right hand column must be blocked from the moon two columns to its left and so no cloud can exist anywhere else on that row.
Alg_6

If a moon is lit from a side and no cloud can exist on the other side, no star can exist on the edge of the lit side.
Here a moon in the second column is lit from below and does not have a cloud above it, so the highlighted cell cannot be a star. Obviously, in this case, there are simpler reasons to decide that this cell cannot be a star.
Alg_7

If a moon is not lit from a side an open star cannot be nearest.
Here the moon to the right of the highlighted cell is not lit
from the left so that cell cannot be a star.
Alg_8

If a moon is not lit from a side the nearest object cannot be a star. There must be another moon or a cloud between its unlit side and the nearest star. If it is a cloud all other cloud_opens can be deleted.
Here the lowest moon in the right hand column is not lit from below, so the open cloud between it and the star must indeed be a cloud, and hence the highlighted cell cannot contain a cloud.
Alg_9

If, in a strip, there is either a single star_open or a set star between a lit and an unlit face, then all cloud_opens not between these two moons can be deleted.
Here there is a horizontal strip with a set star between a lit face and an unlit face. Obviously the cloud_open between the two moons must be a cloud and so the other cloud_opens can be deleted.