Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Drools forever loop knowledge base / published by #f5215bd9-2dff-4529-bdbf-13b5b134b744/7d6dba4247756aa20799be1b78b99d40123b0444
// summary : Drools forever loop knowledge base
// keywords : scala, drools, mvel, scalatest, ai, knowledgebase
// publish : gist
// authors : David Crosson
// license : Apache2
// id : f5215bd9-2dff-4529-bdbf-13b5b134b744
// execution : scala ammonite script ( - run as follow 'amm'
// created-on : 2019-10-04T09:15:21+02:00
import $ivy.`fr.janalyse::drools-scripting:1.0.11`, $ivy.`org.scalatest::scalatest:3.2.6`
import fr.janalyse.droolscripting._, org.scalatest._, flatspec._, matchers._, OptionValues._
object KbTest extends AnyFlatSpec with should.Matchers {
val drl =
"""package test
|declare A end
|declare B end
|declare B end
|rule "init" when not A() then insert(new A()); end
|rule "A -> B" when A() then insert(new B()); end
|rule "B and A -> not A" when $a:A() B() then delete($a); end
"test KB" should "work" in {
val engine = DroolsEngine(drl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment