IF Computer > MINERVA > Example Programs > Applications > JigsawPuzzle

JigsawPuzzle

MINERVA
ifcomputer logo
f
Expert Services on the Web

A 20-line solver. To play this game:

  1. stack four sheets of different colored paper
  2. cut picture into jigsaw puzzle
  3. do four puzzles so that adjoining pieces get different colors

Now matter how wild your scissor art is, there is always a solution to the puzzle. This -if my memory is correct- is guaranteed by some clever guys of the University of Illinois who solved the infamous 4 color problem and proved that 4 colors suffice.

The MINERVA program that computes the solution is brute force search, about 20 lines. The puzzle is given in 60 or so lines, the other programs are for drawing.

The program illustrates a fairly rich set of techniques

  • Use of exhaustive search to find one or all solutions
  • Use of declarations to describe the puzzle
  • Using blackboards to store results
  • Use of package, external, init directives
  • Use of predicate names with underscore prefix for privacy
  • Use of main/1 in several modules for testing purposes
  • Use of Java classes and their methods
  • Working many windows
  • using a GUI with 'action' and 'paint' events

Notes: The 'Show All Solutions' button will produce 192 new windows for this example; repeated use will quickly exhaust your Windowing resources.

Netscape 4.0 may not execute this example properly.

document: http://www.ifcomputer.co.jp/MINERVA/ExamplePrograms/Applications/JigsawPuzzle/print_en.html
published 2008/9/1 update 2001/3/21 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS