Classic Computer Magazine Archive ANTIC VOL. 5, NO. 11 / MARCH 1987


A jigsaw puzzle generator for your ST

by David J. Bohlke

ST Puzzler is a simulation which will generate a random jigsaw puzzle for you to solve. A scoring routine will allow you to compete against your own best score on each new puzzle. You also have the option of changing the puzzle pattern so that you can adjust the difficulty level of the game.

To begin you will need to type in the ST BASIC listing. Be sure to save a copy or two to disk before you run the program. It is also necessary to set the display to low resolution from the control panel. If you have a monochrome-only display, you can try placing random patterns in the puzzle, as described later.

When you run the game, the random puzzle to be solved will be displayed in the bottom-right corner of the screen. The left two-thirds of the screen will show an 8x6 grid in which you will place the pieces in the puzzle. The piece you will need to place in the puzzle each turn will be randomly selected; and shown in actual size in the upper-right corner of the display. Each of these pieces and the completed puzzle grid are nine times as large as the original puzzle that you will be completing.

There are four types of prompts which will be printed in the OUTPUT bar on the top of the screen. When the computer is selecting a piece for you to place in the grid, and plotting the piece in the upper right of the screen, the message "Selecting piece" will be displayed. Then it will be time for you to place the piece in the puzzle, and the prompt "Click to Grid" will be shown. To place the piece, use the mouse to move the pointer to the location in the grid you think the piece belongs, relative to the original puzzle from the lower right of the screen, then click the left mouse button.

If you are accurate in your selection, the message "CORRECT" will be shown; and if you miss the appropriate grid square the message "INCORRECT" will be printed. Each of the four prompts will also indicate your current score. The "CORRECT" signal also displays the number of right and wrong pieces you have attempted. When your placement is accurate, the piece will be put in the large grid that you pointed to with the mouse. When you are wrong, the piece to place will be erased, and a new random piece will be chosen.

The scoring routine considers the number of right and wrong placements, and a timing factor. The timing counter begins when the piece to place in the upper right corner is completed, and ends when you click the mouse to pick your square. You can only click the mouse when the prompt "Click to Grid" is displayed. The maximum score is a perfect 4800, with any effort over 4000 exceptional.

Each puzzle is made up of random ellipse segments. Currently, the pieces are filled with the pattern labeled (2,7) on page C-21 of the ST BASIC Source book. These numbers are engaged using the color statement in program line number 240. Notice the order used in the statement is 7,2. Using other patterns here is one way that you can increase or decrease the difficulty level of the jigsaw puzzle. If you do not have a color display, you might try using a rnd * 24 to pick a random pattern for each different ellipse drawn in the puzzle.

I really enjoyed writing Puzzler and experimenting with the different color combinations and patterns. After you are accustomed to play, you might try altering the elliptical shapes to boxes, circles, lines, or triangles. If jigsaw puzzles are one of your hobbies, you now have billions of options to enjoy.