Skip to content

Commit

Permalink
Don't allow compound events in EventBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrock4t committed Mar 5, 2024
1 parent aba1bad commit 3352758
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pynars/NARS/Control/Reasoner.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def observe(self, tasks_derived: List[Task]):
task_in: Task = channel.take()
if task_in is not None:
self.overall_experience.put(task_in)
if task_in.is_event:
if self.event_buffer.can_task_enter(task_in):
self.event_buffer.put(task_in)
# when there's a new event, run the temporal chaining
temporal_results = self.event_buffer.generate_temporal_sentences()
Expand Down
11 changes: 7 additions & 4 deletions pynars/NARS/DataStructures/_py/Buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ def generate_temporal_sentences(self):
return results

def put(self, event_task_to_insert: Task):
if not event_task_to_insert.is_event \
or event_task_to_insert.term.type != TermType.STATEMENT \
or event_task_to_insert.term.is_higher_order:
if not self.can_task_enter(event_task_to_insert):
print("ERROR! Only events with first-order statements can enter the EventBuffer.")
return

Expand All @@ -107,4 +105,9 @@ def put(self, event_task_to_insert: Task):

if len(self.buffer) > self.capacity:
# if too many events, take out the oldest event
self.buffer.pop(0)
self.buffer.pop(0)

def can_task_enter(self, task: Task):
return task.is_event \
and task.term.type == TermType.STATEMENT \
and not task.term.is_higher_order

0 comments on commit 3352758

Please sign in to comment.