Thanks.
Hi, a rule can easily act on instance creation. Can a rule act on deletion of each instance of particular class? (there is an option to use delete handlers, but is it possible to do with rules). Here is my test: (watch instances) (watch slots) (watch activations) (defclass A (is-a USER) (slot foo) (slot bar)) (defrule match-A-s (not (object (is-a A) (foo ?f))) => (printout t "=== Removed!" crlf )) (make-instance a of A (foo 200)) (make-instance a1 of A (foo 200)) (run) (unmake-instance [a]) (unmake-instance...
Something wrong with types: from clips import Environment env = Environment() superclass = env.find_class('USER') print type(superclass) Prints: <type 'instance'> Root cause: "class Instance:" should be "class Instance(object):" for Python 2.7. It's a good idea to inherit from "object" for the rest of the classes, too.
Something wrong with types: from clips import Environment env = Environment() superclass = env.find_class('USER') print type(superclass) Prints: <type 'instance'> Root cause: "class Instance:" should be "class Instance(object):" for Python 2.7. It's a good idea to inherit fro "object" for the rest of the classes, too.
Something wrong with types: from clips import Environment env = Environment() superclass = env.find_class('USER') print type(superclass) Prints: <type 'instance'>
What is correct way of working with INSTANCE-ADDRESS? import clips env = clips.Environment() class_string = """ (defclass MyClass (is-a USER) (slot One) (slot Two (type INSTANCE-ADDRESS))) """ env.build(class_string) klass = env.find_class('MyClass') instance = klass.new_instance('instance-name') instance['One'] = 1 instance1 = klass.new_instance('instance-name1') instance1['Two'] = instance Result: $ python test5.py Traceback (most recent call last): File "test5.py", line 17, in <module> instance1['Two']...
Here is another test: import clips env = clips.Environment() class_string = """ (defclass MyClass1 (is-a USER) (slot One (type INTEGER)) (slot Two)) """ env.build(class_string) class_string = """ (defclass MyClass (is-a MyClass1)) """ env.build(class_string) klass = env.find_class('MyClass') instance = klass.new_instance('instance-name') instance['One'] = 1 instance['Two'] = 2 print instance.instance_class.slots print "=== Iterate through slots ===" for s in instance.instance_class.slots(): print...
Here is another test: import clips env = clips.Environment() class_string = """ (defclass MyClass1 (is-a USER) (slot One (type INTEGER)) (slot Two)) """ env.build(class_string) class_string = """ (defclass MyClass (is-a MyClass1)) """ env.build(class_string) klass = env.find_class('MyClass') instance = klass.new_instance('instance-name') instance['One'] = 1 instance['Two'] = 2 print instance.instance_class.slots print "=== Iterate through slots ===" for s in instance.instance_class.slots(): print...