OpenNARS-for-Applications icon indicating copy to clipboard operation
OpenNARS-for-Applications copied to clipboard

(WIP) Attempt to eliminate cyclic dependency `NAR→Cycle→Decision`

Open ARCJ137442 opened this issue 1 year ago • 2 comments

Maybe reducing cyclic dependency can make the module dependency of ONA better?

  • Privatize the global variable currentTime in NAR.c - completely possible
  • Supplement the parameter currentTime of Decision_ConsiderNegativeOutcomes to eliminate the cyclic dependency of NAR -> Cycle -> Decision - still WIP and needs further discussions

The only problem is here:

https://github.com/opennars/OpenNARS-for-Applications/blob/9954416ca1316bdb42ffe6c8e65b339c0c54ca95/src/Decision.c#L230

Are there any good alternatives to "input beliefs"? Pass a function pointer such like void (*InputBelief) (Term) as a parameter on Decision_Execute, Cycle_ProcessAndInferGoalEvents and Cycle_Perform?

ARCJ137442 avatar Sep 22 '24 19:09 ARCJ137442

Awesome that you found this, thank you! And I will think about a solution to replacing NAR_AddInputBelief(feedbackTerm) there.

patham9 avatar Sep 25 '24 11:09 patham9

Awesome that you found this, thank you! And I will think about a solution to replacing NAR_AddInputBelief(feedbackTerm) there.

Thanks for your watching too!

I also have some extra information that I hope will help us.

That's my dependancy analyze of ONA using Graphviz dot:

ONA include graph

(generated on 2024-09-21, .svg vectorgraph)

And its Graphviz code can be seen and previewed here. (2 cyclic dependencies: Narsese.hVariable.h, Decision.hNAR.hCycle.h)

Perhaps it can give us a macro overview of module dependencies in ONA :)

ARCJ137442 avatar Sep 25 '24 15:09 ARCJ137442