I am trying to run this code:
class RuleEng(KnowledgeEngine):
@Rule(salience=1)
def r1(self):
print("Execution r1 second")
pass
@Rule(salience=2)
def r2(self):
print("Execution r2 first")
pass
@Rule(Fact(foo="bar"))
def Foo(self):
print("Execute Foo")
pass
engine = RuleEng()
engine.reset()
engine.declare(Fact(foo="bar"))
print(engine.facts)
engine.modify(engine.facts[1], foo="bar2")
engine.modify(engine.facts[1], foo="bar")
and got this error:
<f-0>: InitialFact()
<f-1>: Fact(foo='bar')
Traceback (most recent call last):
File ***, in <module>
engine.modify(engine.facts[1], foo="bar")
~~~~~~~~~~~~^^^
KeyError: 1
I am trying to run this code:
and got this error: