The dynrules C API contains fast C based implementations of the dynamic scripting module API.
Include headers:
dynrules/dynrules.h
Imports the dynrules module. This returns 0 on success and -1 on failure.
The PyRule object is a simple class type that carries a weight indicator and arbitrary code data for usage in the dynamic script generation process.
The PyRuleSet object is a rule container class that manages rules, their weights and the weight distribution for the rules.
A dictionary containing the rules. It uses the PyRule.id as key and the PyRule as value.
The total weight of all contained rules.
Returns true, if the argument is a PyRuleSet or a subclass of PyRuleSet.
Creates a new PyRuleSet object with an initial minimum and maximum weight. On failure, this returns NULL.
Adds a PyRule to a PyRuleSet. If there is a rule with the same id already in the PyRuleSet, it will be removed and the passed rule will be used instead. Additionally the PyRule.weight member will be set to stay within the boundaries of the PyRuleSet.minweight and PyRuleSet.maxweight limits. This returns 1 on success and 0 on failure.
Removes a PyRule from a PyRuleSet. This returns 1 on success and 0 on failure.
Updates the weights of all contained rules. fitness will be passed to the user-specific PyRuleSet.calculate_adjustment() method. This returns 1 on success and 0 on failure.
The PyLearnSystem object takes care of creating new scripts based on a predefined PyRuleSet. It does not evaluate the scripts nor modifies the rules written to them.
The maximum number of tries to select rules and generate a script.
The maximum size in bytes of the scripts to generate.
Returns true, if the argument is a PyLearnSystem or a subclass of PyLearnSystem.
Creates a new PyLearnSytem object for the passed PyRuleSet. On failure, this returns NULL.
Creates a script from the set PyLearnSystem.rulset using the passed script file. A maximum of maxrules rules will be written. file can be any file-like Python object or a filename. In case of a file object it is assumed to be writeable and won’t be closed on leaving the function.