Skip to content

Commit

Permalink
refactor: goal in the explanation function
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-elena committed Jun 4, 2024
1 parent 57b7cbc commit 9aef82b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/component/event/design/ExecutedAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function ExecutedAction(props) {
if (props.event.message.type === "SendMessage") {
const message = props.event.message.event.messageInfo
const description = "I sent a " + message.type + " message to " + message.receiver + ": " + message.message
const explanation = "" //todo
return (
<Event type={"Executed action"} description={description} info={""} timestamp={props.event.timestamp}
filter={props.filter} log={props.log} level={Level.DESIGN}/>
Expand All @@ -18,7 +19,8 @@ function ExecutedAction(props) {
const intentionInfo = props.event.message.event.intentionInfo.value ? props.event.message.event.intentionInfo.value : props.log.slice(0, props.log.indexOf(props.event)).find(e => e.message.type === "IntentionCreated" && e.message.event.intentionInfo.intendedMeansInfo[0].plan.body.includes(deed.term)).message.event.intentionInfo
const intentionId = intentionInfo.id
const intentionTrigger = intentionInfo.intendedMeansInfo[0]
const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.intention.value && e.message.event.goalInfo.intention.value.id === intentionId)
//const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.intention.value && e.message.event.goalInfo.intention.value.id === intentionId)
const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.goalFunctor.includes(intentionTrigger.trigger))

switch (deed.type) {
case "addBel":
Expand Down
6 changes: 4 additions & 2 deletions src/component/event/design/SelectPlan.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ import {Level} from "../../../model/Level";
function SelectPlan(props) {

const event = props.event.message
const type = "Select Plan"
const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.goalFunctor === event.event.event.split('[')[0])
const selectPlan = event.event
const trigger = selectPlan.event
let description = "I am choosing the plan for "
const goal = trigger.split(')[')[0]

if (trigger.includes("error(no_applicable)")) {
description += "the failure of "
}

description = description + trigger.split(')[')[0] + ") from: \n" + selectPlan.planOptions.map(p => "\t"+p.log).join("\n")
description = description + goal + ") from: \n" + selectPlan.planOptions.map(p => "\t"+p.log).join("\n") //todo plan selected [plan-name] for goal [goal]
description = description + "\n\nI selected the plan @" + selectPlan.selectedPlan.label

return (
<Event type={event.type} description={description} timestamp={props.event.timestamp} filter={props.filter} log={props.log} level={Level.DESIGN} explanation={explanation}/>
<Event type={type} description={description} timestamp={props.event.timestamp} filter={props.filter} log={props.log} level={Level.DESIGN} explanation={explanation}/>
)
}

Expand Down

0 comments on commit 9aef82b

Please sign in to comment.