(in-package :csp)
;;===================================================
;;  First example:
;;  Using CSP for solving a crossword
;;
;;
;;  The present example is taken from the "Encyclopedia of AI",
;;  S.Shapyro et al.
;;  In this case is enough to compute arc consistency in order
;;  to fill the schema.
(in-package :csp)
(ensure-loaded "cw" :force t)
(ensure-loaded "cwgraph" :force t)
;; The file "cwgraph" contains routines 
;;
;;

(setq schema1 (make-array '(8 7) :initial-contents
'((* * * * * * *)
  (* _ _ _ _ _ *)
  (* _ _ _ * _ *)
  (* _ _ _ _ _ *)
  (* _ * _ _ _ *)
  (* _ _ _ _ _ *)
  (* _ * _ _ _ *)
  (* * * * * * *))))

;;here we define the variable-domain function to interface with csp

(defun VARIABLE-DOMAIN (domain)
  '( "start" "eel" "rabbi" "cadre" "ear" "ran" "exist"
"tea" "albeit" "nay" "thy" "aldrin" 
"thirty" "tomato" "treaty" "twenty" "twisty"
"sachem" "sacred" "sadden" "sawyer" "screed" "screen" "seamen" "seater"
 "secret" "seller" "selves" "semper" "series" "shaken" "shaven" "shovel"
 "shriek" "sicken" "signet" "silken" "silver" "simmer" "simper" "sinter"
 "sister" "skater" "slater" "sloven" "soccer" "socket" "sodden" "soften"
 "solder" "somber" "sonnet" "sorrel" "soviet" "spayed" "spleen" "spoken"
 "stamen" "stater" "stayed" "stereo" "stolen" "street" "sudden" "suffer"
 "sullen" "sunder" "sundew" "sunken" "sunset" "surrey" "survey" "system"
"tab" "tad" "tag" "tam" "tan" "tao" "tap" "tar" "tat" "tau" "tax" "ted"
 "tee" "ten" "tic" "tid" "tie" "til" "tin" "tip" "tit" "toe" "tog" "ton" "too"
 "top" "tor" "tot" "tow" "toy" "try" "t's" "tub" "tug" "tum" "tun" "two""also" "apse" "base" "bash" "bask" "bass" "Bess" "best" "Bose" "boss" "bush"
 "buss" "bust" "busy" "case" "cash" "cask" "cast" "cosh" "cost" "cosy" "cusp"
 "cyst" "dash" "desk" "disc" "dish" "disk" "dose" "dusk" "dust" "ease" "east"
 "easy" "else" "fast" "fest" "fish" "Fisk" "fist" "Foss" "fuse" "fuss" "gash"
 "gasp" "gist" "gosh" "gush" "gust" "hash" "hasp" "hast" "Hess" "hiss" "hose"
 "host" "hush" "ipso" "jess" "jest" "Jose" "joss" "just" "kiss" "lase" "lash"
 "lass" "last" "less" "lest" "Lisa" "Lise" "lisp" "list" "lose" "loss" "lost"
 "lush" "lust" "mash" "mask" "mass" "mast" "mesa" "mesh" "mess" "miss" "mist"
 "moss" "most" "muse" "mush" "musk" "must" "Nash" "Ness" "nest" "nose" "oust"
 "Paso" "pass" "past" "pest" "piss" "pose" "posh" "post" "posy" "push" "rasa"
 "rash" "rasp" "rest" "rise" "risk" "Rosa" "rose" "Ross" "rosy" "ruse" "rush"
 "rusk" "Russ" "rust" "sash" "task" "Tass" "Tess" "test" "toss" "tusk" "Ursa"
 "vase" "vast" "vest" "visa" "vise" "Voss" "wash" "wasp" "wast" "west" "wise"
 "wish" "wisp" "Yost" "zest") )


(defun DOMAIN-DEPENDENT-SHOW-SOLUTION(s)	
   (let ((ds (g-show-schema schema1)))
	(push ds *open-windows*)
     	(fill-schema schema1 s  ds)))

(construct-network-from-crossw schema1)
