Rule Agent¶
The module holding RuleAgent
, an agent which evaluates artifacts using
its rules.
-
class
creamas.rules.agent.
RuleAgent
(*args, **kwargs)[source]¶ Base class for agents using rules to evaluate artifacts.
In addition to common attributes inherited from
CreativeAgent
, rule agents have following attributes:- Variables
-
async
act
(*args, **kwargs)[source]¶ Trigger agent to act.
This is a dummy method which should be overridden in a subclass.
This function serves as the main function for the simulations, and is called for each agent on each iteration step of the simulation.
- Raises
NotImplementedError – If not overridden in subclass.
See also
-
evaluate
(artifact)[source]¶ Evaluate artifact with agent’s current rules and weights.
- Parameters
- Returns
Agent’s evaluation of the artifact, in [-1,1], and framing. In this basic implementation framing is always
None
.- Return type
Actual evaluation formula in this basic implementation is:
\[e(A) = \frac{\sum_{i=1}^{n} r_{i}(A)w_i} {\sum_{i=1}^{n} \lvert w_i \rvert},\]where \(r_{i}(A)\) is the \(i\) th rule’s evaluation on artifact \(A\), and \(w_i\) is the weight for rule \(r_i\).
-
property
R
¶ Rules agent uses to evaluate artifacts. Each rule in R is expected to be a callable with a single parameter, the artifact to be evaluated. Callable should return a float in [-1,1]; where 1 means that rule is very prominent in the artifact; 0 means that there is none of that rule in the artifact; -1 means that the artifact shows traits opposite to the rule.
-
property
W
¶ Weights for the rules.
Each weight should be in [-1,1].