CRuleSet - Rule container

class CRuleSet(minweight, maxweight) → CRuleSet

Creates a new, empty CRuleSet.

CRuleSet is a rule container class that manages rules, their weights and the weight distribution for the rules. The minweight and maxweight parameters are the minimum and maximum weight boundaries, each rule’s weight has to stay in.

Attributes

CRuleSet.maxweight

Gets or sets the maximum weight to use for rules.

CRuleSet.minweight

Gets or sets the minimum weight to use for rules.

CRuleSet.rules

Gets the list of currently managed CRule objects.

CRuleSet.weight

Gets the total weight of all managed CRule objects.

Methods

CRuleSet.add(rule) → None

Adds a CRule to the CRuleSet.

CRuleSet.calculate_adjustment(fitness) → float

Calculates the reward or penalty, each of the activated rules recives. fitness hereby can be used as measure of the performance or whatever is suitable in the implementation.

This must be implemented by inheriting classes.

CRuleSet.clear() → None

Removes all rules from the CRuleSet.

CRuleSet.distribute_remainder(remainder) → value

Distributes the remainder of the weight differences between the last weights and current weights.

The method must return a value. This must be implemented by inheriting classes.

CRuleSet.find(rid) → :class:`CRule`

Tries to find the CRule with the matching id and returns it. In case no CRule with the passed id exists, None is returned.

CRuleSet.remove(rule) → None

Removes a CRule from the CRuleSet.

CRuleSet.update_weights(fitness) → None

Updates the weights of all contained rules.

Adapted from Pieter Spronck’s algorithm as explained in Spronck et al: 2005, ‘Adaptive Game AI with Dynamic Scripting’.

Table Of Contents

Previous topic

CRule - Rule object

Next topic

CLearnSystem - Rule script generation

This Page