C  Single-stepping Sudoku

The solve function is kind of boring, because it just waits silently for so long before producing an answer. We can, however, design a new solving function that shows how our solving algorithm is proceeding.

So, the goal of this portion of the exercise is to design a function that draws an claim-table, showing the state of the variables:

;; claims->image : claim-table --> image
(define (claims->image claim-table) ...)

but this function needs a large number of helper functions.

The overall strategy for designing this function is to find all of the claims that are true and draw big, black numbers in their corresponding places on a Sudoku puzzle. Then, find all of the variables that are maybes and draw smaller, orange numbers that show where they are. Here is an example:

(claims->image 
 (mostly-unknown-table 
  (list (make-claim 1 1 1) 
        (make-claim 2 5 2)
        (make-claim 3 9 3)
        (make-claim 5 2 4) 
        (make-claim 6 6 5)
        (make-claim 4 7 6)
        (make-claim 9 3 7) 
        (make-claim 8 8 8)
        (make-claim 7 6 9))

So, we can split this up into a few jobs. First, design a single image that forms the backdrop for the Sudoku board. Its size should be big enough to hold all of the big black letters or all of the small orange letters, whichever takes up more space.

Second, design a function that takes a true claim and overlays the corresponding number into the proper place in a board.

;; overlay-true : image claim -> image
;; to draw a big black digit in the right place on the board
(define (overlay-true board claim) ...)

Third, design a function that takes an unknown claim and overlays the corresponding number into the proper place.

;; overlay-unknown : image claim -> image
;; to draw a small orange digit in the right place on the board
(define (overlay-maybe board claim) ...)

Fourth, build functions that, using vector->list, extract the true and unknown axioms from an at-table. Finally combine these functions to complete claims->image. (Of course, the functions above require helper functions.)

Once you have defined a function that renders images, define a new version of solve called solve/images that behaves just like solve, except that around the recursive call in solve/images put with-image from the teachpack. This new construct with-image accepts two arguments. The first should be an image and the second can be anything. When the little man encounters with-image, he shows the image in a window and then continues with the second argument. So, if your solve function has a recursive call that looks like this: (solve new-table), the solve/images function would have a recursive call with with-image and otherwise be the same:

(define (solve claim-table)
  ... (solve new-table) ...)

(define (solve/images claim-table)
  ... (with-image (table->image new-table)
                  (solve/images new-table)) ...)