# Introduction

Masyu is game played on a rectangular grid in which some of the vertices contain black or white circles. An example puzzle and its solution is shown below, followed by a worked example.

The object of the game is to find the unique path which passes through the grid to join up all the circles without intersecting itself and while obeying the rules for crossing the black and white circles.

## Rules

The path crossing a white circle must pass straight through but it must turn at the previous, or the next vertex, or both.

The path crossing a black circle must turn through 90 degrees within the circle and extend in straight lines for at least two vertices both before and after the circle.

## Playing

Edges are added using a left mouse click and are removed using right mouse clicks. The jigsaw symbol is a menu for configuring the game. A left click on the PZL masyu symbol next to it starts a new game by loading a randomly selected puzzle. A right click on this symbol will load the next puzzle. A click on the wand requests a hint. The hint is shown using an orange blob. Given the current state of the grid, it can be deduced that the hint vertex is one for which only one extension is possible. If the player can work out which is the correct extending edge they can add it using a left click. Otherwise a further click on the hint button will cause the edge to be revealed.

If a hint is requested when the grid contains errors, no hint will be given, the thumb icon turns down and the incorrect edges are displayed. They can be removed using right clicks or by a single click on the thumb icon. At any time clicking the thumb checks the current grid for errors, a second click will remove them. The sad smiley will display the solution. The entry box contains the current puzzle number and can be used to enter puzzle numbers. The number to its right is the puzzle difficulty score. To its right is a clock. If a hint is displayed a two letter code for the hint will replace the text of the clock until the hint is applied. The game contains 1000 puzzles ordered by their difficulty score, easiest first.

## Masyu Worked Example

A video from masyu showing a puzzle being solved. The player makes good progress but also uses the hint button frequently. At one point several mistakes are made and the player removes the incorrect edges with right mouse clicks. The thumb button is clicked periodically to check for mistakes. Eventually the puzzle is completed and the clock flashes.

## Algorithms

The algorithms used by Masyu are explained using examples. When the hint button (Wand) is pressed the program analyses the state of the puzzle and draws an orange blob over a vertex which can be extended. The two-letter abreviation for the algorithm employed is written in place of the time and the wand flips to the left.

## White Continuation (WC)

Paths through white circles must pass straight through. If the path from a white circle extends in only one direction, it must also extend in the opposite direction. Here the path must extend down.

## White Parallel (WP)

Paths through white circles must pass straight through but turn at the preceeding or following vertex. If an unsolved white circle is next to a solved white circle, the path through the unsolved white circle must be parallel to the path through the solved one. Here the path must be vertical.

## Black Extension (BE)

Paths through black circles must extend in a straight line for at least 2 vertices. If a path from a black circle has only reached the next vertex, it can be extended one more vertex in the same direction.

## Black Blocked (BB)

Paths through black circles must turn 90 degrees within the black circle and extend in a straight line for at least two vertices either side. If the path from a black circle is blocked in a particular direction the path must extend in the opposite direction. Blocking means, either it is too close to an edge, or it would illegally intersect another path. Here the path cannot extend left so it must go right.

## White Blocked (WB)

The path through white circles must pass straight through. If the path cannot pass straight through a white circle for at least one vertex on either side it must take the perpendicular direction. Here the path is blocked to the right so must be vertical.

## White Turn (WT)

Paths through white circles must pass straight through but turn at the preceeding or following vertex. If White circle has two colinear edges on one side it must have a turn one vertex along in the opposite direction. Here the path must turn upwards.

## White Two (W2)

Paths through white circles must pass straight through but turn at the preceeding or following vertex. The path through a pair of adjacent white circles must either pass directly between the two or both must be crossed in the direction perpendicular to their alignment. If one path is impossible, it must be the other. Here the correct path is horizontal.

## Black Perpendicular (BP)

Paths through black circles must turn 90 degrees within the black circle and extend in a straight line for at least two vertices either side. When a Black circle has an edge in only one direction and one of the perpendicular directions is blocked we know the path must extend in the other. Here the path cannot turn left as it would make a closed loop, so it goes right.

## One Way (OW)

If an end without a circle has only one way to extend because all other paths are blocked, it must be the way. Here the path can only extend to the left.

## Dead End (DE))

If the path can only extend in one direction because all other directions lead to dead ends, that must be the way it goes. Here, progess downwards would lead to a dead end, so the correct path is up.

## Black White (BW)

Paths through white circles must pass straight through but turn at the preceeding or following vertex. Paths through black circles must turn 90 degrees within the black circle and extend in a straight line for at least two vertices either side. The combined effect of these two rules means that the path through a black circle with two white circles diagonally adjacent on the same side cannot pass between the two white circles but must go in the opposite direction. Otherwise the path through the white circles would be unable to turn. Here the path must be to the right.