PyKnow is a Python library for building expert systems strongly inspired by CLIPS.
fromrandomimportchoicefrompyknowimport*classLight(Fact):
"""Info about the traffic light."""passclassRobotCrossStreet(KnowledgeEngine):
@Rule(Light(color='green'))defgreen_light(self):
print("Walk")
@Rule(Light(color='red'))defred_light(self):
print("Don't walk")
@Rule(AS.light<<Light(color=L('yellow') |L('blinking-yellow')))defcautious(self, light):
print("Be cautious because light is", light["color"])>>>engine=RobotCrossStreet()
>>>engine.reset()
>>>engine.declare(Light(color=choice(['green', 'yellow', 'blinking-yellow', 'red'])))
>>>engine.run()
Becautiousbecauselightisblinking-yellowYou can find some more examples on GitHub.