From 472596c81d3056ea6529010afc31443f224d180a Mon Sep 17 00:00:00 2001 From: Elena Yan Date: Thu, 2 May 2024 17:55:55 +0200 Subject: [PATCH] fix: new belief --- src/component/event/design/NewBelief.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/component/event/design/NewBelief.js b/src/component/event/design/NewBelief.js index 0688bf3..0b827e7 100644 --- a/src/component/event/design/NewBelief.js +++ b/src/component/event/design/NewBelief.js @@ -34,10 +34,15 @@ function NewBelief(props) { agentState.belief.self.push(functor) break; case "percept": - const percept = props.log.slice(props.log.indexOf(props.event)).find(e => e.message.type === "NewPercept" && e.message.event.perceptInfo.functor === belief).message.event.perceptInfo; - reason = " because I perceived it" + (percept.artifactName ? " from " + percept.artifactName : "") - info = percept.perceptType ? "Percept type: " + percept.perceptType : "" - agentState.belief.percept.push(functor) + const percept = props.log.slice(props.log.indexOf(props.event)).find(e => e.message.type === "NewPercept" && e.message.event.perceptInfo.functor === belief) + if (percept) { + const p = percept.message.event.perceptInfo; + reason = " because I perceived it" + (p.artifactName ? " from " + p.artifactName : "") + info = p.perceptType ? "Percept type: " + p.perceptType : "" + agentState.belief.percept.push(functor) + } else { + reason = "" + } break; case "": reason = ""