lightning
lightning

Reputation: 409

Is there a way to reorder CHR rules at runtime in prolog?

I am writing a program for an artistic purpose in Prolog with heavy reliance on a large set of CHR rules. I would like to be able to run many times, but produce a different output each time. The easiest way to do this would be to non-deterministically reorder the constraints each time.

For instance, for the form of a poem, I may want an ABAB or ABAC form. I would then like to write:

stanza <=> verse(A,0), verse(B,1), verse(A,2), verse(B,3)
stanza <=> verse(A,0), verse(B,1), verse(A,2), verse(C,3)

I'd like for the first rule to sometimes fire when stanza is presented, and for the second rule to sometimes fire. How could I accomplish that with CHR?

Upvotes: 1

Views: 60

Answers (0)

Related Questions