CSc 8710 Deductive Databases and Logic Programming
Fall 2008
Programming Assignment # 4
Due: November 1st, 2008

Write a Prolog program to draw Hilbert Curves, which are defined as follows:

There are four kinds of Hilbert curves which we shall name A-curves, B-curves, C-curves and D-curves. Each of these curves come in various sizes and are defined (recursively) as follows:
tex2html_wrap_inline295 , and tex2html_wrap_inline297 all occupy no space (i.e. they are empty curves). These are curves of size zero. Curves of bigger sizes are defined as follows:

picture16

Write the program so that it will draw tex2html_wrap_inline339 where N is a parameter.
Notes on the Implementation

  1. The main predicate should be named hilbertC(N).
  2. The curve will be plotted in a MxM matrix with 2 "o" characters per segment.
  3. Begin drawing the C-curves by starting at the lower left corner.
  4. It will be useful if you write predicates for drawing the various segments (drawNorth, drawSouth, drawWest, drawEast) and predicates for each of the four types of curves (aCurve, bCurve, cCurve, dCurve).
Here are some sample runs:
?- hilbertC(1).

ooo
  o
ooo


Yes
?- hilbertC(2).

o ooooo
o o   o
ooo ooo
    o  
ooo ooo
o o   o
o ooooo


Yes
?- hilbertC(3).

ooo ooooo ooooo
  o o   o o   o
ooo ooo ooo ooo
o     o     o  
o ooo o ooo ooo
o o o o o o   o
ooo ooo o ooooo
        o      
ooo ooo o ooooo
o o o o o o   o
o ooo o ooo ooo
o     o     o  
ooo ooo ooo ooo
  o o   o o   o
ooo ooooo ooooo


Yes