Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/nal/avoid.nal
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ G! :|:
a. :|:
T! :|: {0.0 0.99}
G! :|:
//expected: ^right executed with args
//--expected: ^right executed with args

2 changes: 1 addition & 1 deletion examples/nal/avoid2.nal
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ a. :|:
a. :|:
T! :|: {0.0 0.99}
G! :|:
//expected: ^right executed with args
//--expected: ^right executed with args

6 changes: 4 additions & 2 deletions src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#define TOP_K_DECLARATIVE_IMPLICATIONS 20
//When a concept belief was last updated to be used for declarative implication deduction
#define BELIEF_LAST_USED_TOLERANCE 5
//Anticipation model (0 assumption of failure, 1 hybrid, 2 classical anticipation)
#define ANTICIPATION_MODE 1

/*---------------------*/
/* Decision parameters */
Expand Down Expand Up @@ -219,8 +221,8 @@
//Allow declarative implication events, 0 NONE, 1 INPUT, 2 ALL
#define ALLOW_IMPLICATION_EVENTS 1
//Eternalization model: 0 None, 1 event-eternal, 2 ALL
#define ALLOW_ETERNALIZATION 0
#define ALLOW_ETERNALIZATION 2
//Whether declarative inference should happen on events
#define EVENT_EVENT_DECLARATIVE_INFERENCE false
#define EVENT_EVENT_DECLARATIVE_INFERENCE true

#endif
4 changes: 4 additions & 0 deletions src/Cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ static Implication Cycle_ReinforceLink(Event *a, Event *b)
{
return (Implication) {0};
}
if(ANTICIPATION_MODE == 1 && (a->truth.frequency == 0.0 || b->truth.frequency == 0.0))
{
return (Implication) {0};
}
Term a_term_nop = Narsese_GetPreconditionWithoutOp(&a->term);
Concept *A = Memory_FindConceptByTerm(&a_term_nop);
Concept *B = Memory_FindConceptByTerm(&b->term);
Expand Down
4 changes: 4 additions & 0 deletions src/Decision.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ int BABBLING_OPS = OPERATIONS_MAX;

static void Decision_AddNegativeConfirmation(Event *precondition, Implication imp, int operationID, Concept *postc)
{
if(ANTICIPATION_MODE == 2 || ANTICIPATION_CONFIDENCE == 0.0)
{
return;
}
Implication negative_confirmation = imp;
Truth TNew = { .frequency = 0.0, .confidence = ANTICIPATION_CONFIDENCE };
Truth TPast = Truth_Projection(precondition->truth, 0, round(imp.occurrenceTimeOffset));
Expand Down
12 changes: 12 additions & 0 deletions src/NAR.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,20 @@ void NAR_INIT()
void NAR_Cycles(int cycles)
{
assert(initialized, "NAR not initialized yet, call NAR_INIT first!");
Truth negTruth = (Truth) { .frequency = 0.0, .confidence = NAR_DEFAULT_CONFIDENCE };
for(int i=0; i<cycles; i++)
{
//check any concepts that have predicted beliefs of a past occurrence time
for(int j=0; ANTICIPATION_MODE && j<concepts.itemsAmount; j++)
{
Concept *c = concepts.items[j].address;
if(c->predicted_belief.occurrenceTime == currentTime && !Variable_hasVariable(&c->predicted_belief.term, true, true, false) &&
c->belief_spike.occurrenceTime < currentTime) //was predicted for now but did not happen now
{
Event ev = Event_InputEvent(c->predicted_belief.term, EVENT_TYPE_BELIEF, negTruth, 0, c->predicted_belief.occurrenceTime);
Memory_AddInputEvent(&ev, currentTime);
}
}
IN_DEBUG( puts("\nNew system cycle:\n----------"); )
Cycle_Perform(currentTime);
currentTime++;
Expand Down