% case "$1" in % -* ) % OPTION=$1 % shift % ;; % * ) % OPTION="-all" % esac % case "$1" in % "" ) % MONTH=0 % ;; % [0-9] | 1[0-2] ) % MONTH=$1 % ;; % * ) % echo "month number \"$1\" must be between 1 and 12" % exit 1 % ;; % esac % case "$2" in % "" ) % DAY=0 % ;; % [0-9] | [12][0-9] | 3[01] ) % DAY=$2 % ;; % * ) % echo "day number \"$2\" must be between 1 and 31" % exit 1 % ;; % esac % case $OPTION in % -all ) -- Search for all solutions by generating the entire LTS "solution.bcg" = generation of "puzzle.lnt" at MAIN [PLACE, PRINT] ($MONTH, $DAY); % ;; % -one ) -- Search for one solution using Evaluator "solution.bcg" = "puzzle.lnt" at MAIN [PLACE, PRINT] ($MONTH, $DAY) |= using dfs -- Heuristics: search first for placing piece A (6 cells) near -- the left bottom corner of the grid < { PLACE !"A" ?M:Nat ?N:Nat ... where (M >= 5) and (N <= 4) } | { PLACE !"A" ?M:Nat ?N:Nat ... where (M < 5) or (N > 4) } > < true* . 'PRINT.*' > true; % ;; % -all-tgv ) -- Search for all solutions using TGV % lnt.open -main "MAIN [PLACE, PRINT] ($MONTH, $DAY)" puzzle.lnt \ % tgv -all -io puzzle.io -self tp.aut solution.bcg % SVL_RECORD_FOR_SWEEP tgv puzzle.o % ;; % -one-tgv ) -- Search for one solution using TGV % lnt.open -main "MAIN [PLACE, PRINT] ($MONTH, $DAY)" puzzle.lnt \ % tgv -io puzzle.io -self tp.aut solution.bcg % SVL_RECORD_FOR_SWEEP tgv puzzle.o % ;; % * ) % echo "invalid option \"$OPTION\"" % exit 1 % esac % if [ "$OPTION" != "-all" ] % then % SVL_INFO solution.bcg % fi -- Display solutions graphically % sh ./show_solutions solution.bcg $MONTH $DAY % "$CADP"/src/com/cadp_postscript solution.ps % SVL_RECORD_FOR_CLEAN solution.bcg solution.ps