Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there an easy way to modify facts? #30

Open
gonzafernan opened this issue May 26, 2022 · 0 comments
Open

Is there an easy way to modify facts? #30

gonzafernan opened this issue May 26, 2022 · 0 comments

Comments

@gonzafernan
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant