| A 20-line solver. To play this game:
- stack four sheets of different colored paper
- cut picture into jigsaw puzzle
- 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.
|