The structure AQueens computes a circular lazy stream of solutions to the problem using a general depth-first search. For each adjacent pair of solutions, another search enumerates the legal ways of moving the queens from one solution to the next and picks an `interesting' one (in this case, the one with the most diagonal moves, but that's easily tweaked).
The second part of the applet is the structure AQueensApplet which declares the applet and sets up a concurrent thread which actually does the animation. This is fairly imperative code and makes heavy use of MLj's Java extensions -- it was based on an MLj transcription of some code from Java in a Nutshell by David Flanagan.
|MLj home||Comments to: email@example.com|