From 3352758f9435781f73b70e73fcab7df62a4b81ef Mon Sep 17 00:00:00 2001 From: ccrock4t <15344554+ccrock4t@users.noreply.github.com> Date: Tue, 5 Mar 2024 16:51:54 -0500 Subject: [PATCH] Don't allow compound events in EventBuffer --- pynars/NARS/Control/Reasoner.py | 2 +- pynars/NARS/DataStructures/_py/Buffer.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pynars/NARS/Control/Reasoner.py b/pynars/NARS/Control/Reasoner.py index 105ceb1..a64f500 100644 --- a/pynars/NARS/Control/Reasoner.py +++ b/pynars/NARS/Control/Reasoner.py @@ -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() diff --git a/pynars/NARS/DataStructures/_py/Buffer.py b/pynars/NARS/DataStructures/_py/Buffer.py index b65cdac..ebb5499 100644 --- a/pynars/NARS/DataStructures/_py/Buffer.py +++ b/pynars/NARS/DataStructures/_py/Buffer.py @@ -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 @@ -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) \ No newline at end of file + 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 \ No newline at end of file