Pearls (Masyu)


ALT="Your browser understands the <APPLET> tag, but isn't running the applet, for some reason." Your browser is completely ignoring the <APPLET> tag!
Trouble with the Applet?
Instructions

This Game is Hard.

I was turned on to this puzzle by Erich Friedman's paper[1] on the computational complexity of the problem (it's NP-complete, so you can feel good about doing something "hard" every time you solve a puzzle).

The Rules

  1. The objective is to draw straight lines through all the dots to form a single connected path that does not cross itself and begins and ends at the same point.

  2. Your path must turn on a black dot, but cannot turn directly before or after the dot.

  3. On the other hand, your path cannot turn on a white dot - it must pass straight through it. However, your path must turn directly before and/or after a white dot.


The Applet

Click on a grid square and drag the mouse horizontally or vertically to another square to draw a line. When you release the button, the light blue line will turn to a darker blue - the line has been drawn. You can draw only a single vertical or horizontal line at once. To erase a line, just draw back over the part of the line that you would like to erase.

The applet will let you know when there is something wrong with your drawing. For example, remember that your lines cannot cross. If you ever do accidentally intersect a line, the corresponding grid square will turn red. Erase one of the offending lines to appease the program and correct your error.

You have to keep the dots happy. Untouched dots are black - consider them to be content. If you see a red dot, it's sad, because, depending on the color, you have failed to obey either rule (2) or (3) above. Satisfying the rules for drawing over a dot will make the dot happy. Happy dots are green (of course).

Remember that to win you need a single path with no intersections (corners are of course OK) that is a cycle (starts and ends at the same point).

If you become bored of the current puzzle, you can change it by selecting a new one from the list and pressing the "New Game" button. Likewise, you can press the "New Game" button to restart your current puzzle.

Send me your puzzles!

Making puzzles is easy! If you'd like to add some of your own creations, send them to me please! Take a look at the text files in the puzzles directory to get an idea of the format for creating your own puzzle files.

Method #1

  • First line contains the name,
  • Second line contains the number of rows,
  • Third line contains the number of columns,
  • And the remaining lines specify one dot per line, where a dot is described by it's x and y coordinates (which start at zero!) and it's color (Black or White).
    The order of the dots doesn't matter.

For example, a 15 row by 12 column puzzle called "My Simple Puzzle" with a black dot at x=0, y=3 and a white dot at x=1, y=4 could be specified as
My Simple Puzzle
15
12
0 3 B
1 4 W

You can add comments to your files by preceding them with a '#' sign. eg:
My Simple Puzzle    # Comments here: Created on Feb 20 2003
15                  # By John Buckwheat
12
0 3 B               # The first dot.
1 4 W               # The second dot.

Method #2

This is probably the easier method
  • First line contains the name,
  • The remaining lines are a grid representation of the board populated with black and white dots.
    Black dots are represented by a 'B', white dots by a 'W', and empty cells by a '.'

For example, the "Tiny Puzzle" is encoded like this:

Tiny Puzzle # Name (first row!)

# Column    
# 0 1 2 3 4 
  B . . . . 
  . . . W . 
  . . . . W 
  . W W . . 
  . . B . . 

Notice that empty lines and whitespace are ignored and comments are allowed after a '#'.

Here is a template file if you'd like one.

Have fun!

[1] E. Friedman, "Pearl Puzzles are NP-complete", preprint.

Want to drop me a note? Do so: Send me an email!
<-- Back