Skip navigation

As I continue to learn on how to use CLIPS, I found an improvement to the terminating condition for the knights tour from the previous post by using the halt statement. Replace the terminating condition with the code as follows:

;; Terminating condition
(defrule goal-rule
?init <- (square-is 2)
=>
(printout t “Reached the goal square.” crlf)
(halt))

The execution is the same:

CLIPS> (run)
Firing rule 1.
New square is 8.
Firing rule 13.
New square is 3.
Firing rule 5.
New square is 4.
Firing rule 7.
New square is 9.
Firing rule 15.
New square is 2.
Reached the goal square.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.