Skip to content

Is there an easy way to modify facts? #30

Open
@gonzafernan

Description

I don't know if my question is caused by a misunderstanding of the topic. I have a list of facts that I need to be able to easily modify.

The documentation shows the modify method as follows:

>>> engine.facts
<f-0> InitialFact()
<f-1> Fact(color='red')
>>> engine.modify(engine.facts[1], color='yellow', blink=True)
<f-2>
>>> engine.facts
<f-0> InitialFact()
<f-2> Fact(color='yellow', blink=True)

But to use it you need to know the index of the fact you want to modify in the list of facts, and I don't necessarily know the order in which the facts are declared. What's more, if I make successive modifications, the disorder of the list increases.

It would be great to have a way to modify facts like:

>>> engine.modify(Fact(color='red'), color='yellow', blink=True)

Or maybe a way to search for facts like:

>>> index = engine.facts.search(Fact(color='red'))
>>> engine.modify(engine.facts[index], color='yellow', blink=True)

I really appreciate the help. If it's something that wasn't covered in the code and you think it would be great to add, I'd be happy to consider working on it. If the solution to the question is a different approach, please share it with me.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions