如何在我的板上以适当的坐标打印一个对象(字符 # 对象 I)?
(deftemplate cenario
(slot min-line)
(slot max-line)
(slot min-column)
(slot max-column))
(deftemplate line
(slot index))
(deftemplate column
(slot index))
(deftemplate coordinate
(slot line)
(slot column))
(deftemplate object
(multislot coordinate))
(deffacts cenario
(cenario
(min-line 1)
(max-line 24)
(min-column 1)
(max-column 12)))
(deffacts line
(line (index 1))
(line (index 2))
(line (index 3))
(line (index 4))
(line (index 5))
(line (index 6))
(line (index 7))
(line (index 8))
(line (index 9))
(line (index 10))
(line (index 11))
(line (index 12))
(line (index 13))
(line (index 14))
(line (index 15))
(line (index 16))
(line (index 17))
(line (index 18))
(line (index 19))
(line (index 20))
(line (index 21))
(line (index 22))
(line (index 23))
(line (index 24)))
(deffacts column
(column (index 1))
(column (index 2))
(column (index 3))
(column (index 4))
(column (index 5))
(column (index 6))
(column (index 7))
(column (index 8))
(column (index 9))
(column (index 10))
(column (index 11))
(column (index 12)))
(deffacts I
(object (coordinate 5 24) (coordinate 6 24) (coordinate 7 24) (coordinate 8 24))))
(defrule startcolumn
(not(columnCurrent))
(cenario (min-column ?x))
=>
(assert(columnCurrent ?x)))
(defrule startline
(not(lineCurrent))
(cenario (max-line ?x))
=>
(assert(lineCurrent ?x)))
(defrule print-board
(cenario (max-column ?maxcol))
?f <- (line (index ?i))
?g <- (columnCurrent ?ca&:(<= ?ca ?maxcol))
(not (object (coordinate ?i ?ca)))
(lineCurrent ?i)
=>
(retract ?g)
(assert (columnCurrent (+ ?ca 1)))
(printout t "?"))
(defrule print-object
(lineCurrent ?i)
(columnCurrent ?ca)
(object (coordinate ?i ?ca ))
=>
(printout t ?i " " ?ca ))
(defrule change-line
(cenario (max-column ?maxcol))
?f <- (line (index ?i))
?g <- (columnCurrent 13)
(lineCurrent ?i)
=>
(retract ?f)
(assert (columnCurrent 1))
(assert (lineCurrent (- ?i 1)))
(printout t crlf))
我想要这个最终结果:
????####????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????
????????????