defworld.patterns — Patterns

class defworld.patterns.Assign(var, pattern)

Assign a fact to a variable

Parameters:
  • var (basic.Var) – a variable
  • pattern (Fact) – a pattern of the fact to assign
match(other=None, item=None)

Return pattern matching

class defworld.patterns.Entity(_name, *args, **kwargs)

A Fact represents a unique object.

apply(wm)

Alter the entity the name of which is same with one of this entity. If the working memory does not have one, then just append this to it.

Parameters:wm (agent.WorkingMemory) – An agent’s working memory
class defworld.patterns.Fact(_name, *args, **kwargs)
Parameters:
  • _name (basestring or basic.Var) – a kind of Fact
  • args – ordered values
  • kwargs – slot values
apply(wm)

Append self to the working memory

Parameters:wm (agent.WorkingMemory) – An agent’s working memory
class defworld.patterns.Func(func)

Function wrapper to evaluate the function at the time the rule is activated.

Parameters:func – the function to evaluate
class defworld.patterns.Retract(fact)

Retract a fact from the working memory

Parameters:fact (Fact) – the fact to retract
class defworld.patterns.Template(name, kind=<class 'defworld.patterns.Fact'>)

Template for a Fact or Entity

human = Template('human')
human('Socrates') == Fact('human', 'Socrates')
Parameters:
class defworld.patterns.Update(fact, *args, **kwargs)

Update a fact in the working memory

Parameters:
  • fact (Fact) – the fact to update
  • args – ordered values
  • kwargs – slot values

Project Versions

Previous topic

defworld.exception — Errors

Next topic

defworld.rete.node — Rete network

This Page