Skip to content

Commit

Permalink
refactor: intention id
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-elena committed Jun 2, 2024
1 parent 946565e commit a6cfcd8
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/component/event/design/BeliefRemoved.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function BDIBeliefRemoved(props) {

if (intention) {
const intentionInfo = intention.message.event.intentionInfo
reason = " because of intention " + intentionInfo.id + " " + intentionInfo.intendedMeansInfo[0].trigger
reason = " because of intention int-" + intentionInfo.id + "-" + intentionInfo.intendedMeansInfo[0].trigger
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 === intentionInfo.id)
}

Expand Down
4 changes: 2 additions & 2 deletions src/component/event/design/DesireCommitted.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ function DesireCommitted(props) {
const context = selectedPlan.context ? " because I believe " + selectedPlan.context.replace("&", "and").replace("|", "or") : ""
const body = selectedPlan.body ? "Plan body: " + selectedPlan.body : ""
const id = intention.intentionInfo.id
const description = "I committed to desire " + desire + context + ", and it became a new intention " + id + " " + intention.intentionInfo.trigger
const description = "I committed to desire " + desire + context + ", and it became a new intention int-" + id + "-" + intention.intentionInfo.trigger

let reason = getIntentionReason(desire, intention.intentionInfo)
let parentDesire = reason ? ["Intention " + id + " " + desire + " is an intention " + reason, <br/>] : []
let parentDesire = reason ? ["Intention int-" + id + "-" + desire + " is an intention " + reason, <br/>] : []

if (agentState.intention[id]) {
agentState.intention[id].push(desire)
Expand Down
4 changes: 2 additions & 2 deletions src/component/event/design/DesireRemoved.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ function DesireRemoved(props) {

if (im.length > 0) {
let reason = getIntentionReason(functor, intention)
parentDesire = reason ? ["Intention " + id + " " + functor + " is an intention" + reason, <br/>] : []
parentDesire = reason ? ["Intention int-" + id + "-" + functor + " is an intention" + reason, <br/>] : []
}
} else {
id = Object.keys(agentState.intention).find(key => agentState.intention[key].includes(functor))
}

let intentionInfo = "intention " + id + " " + functor.split('(')[0]
let intentionInfo = "intention int-" + id + "-" + functor.split('(')[0]
if (result === "achieved") {
type = "Desire satisfied";
description = "I have satisfied my desire " + functor + " because its " + intentionInfo + " finished"
Expand Down
2 changes: 1 addition & 1 deletion src/component/event/design/ExecutedAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function ExecutedAction(props) {
break;
}

const intention = "intention " + intentionId + " " + intentionTrigger.plan.trigger
const intention = "intention int-" + intentionId + "-" + intentionTrigger.plan.trigger
description = description + deed.term + " because of " + intention
info = info + deed.type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function ExternalActionFinished(props) {
const type = "External Action Finished"
let description = "External action " + deed.term + " executed"
const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && intention && e.message.event.goalInfo.intention.value && e.message.event.goalInfo.intention.value.id === intention.id)
const info = "Type: external " + deed.type + (intention ? ", Intention: " + intention.id + " " + intention.trigger : "")
const info = "Type: external " + deed.type + (intention ? ", Intention: int-" + intention.id + "-" + intention.trigger : "")

return (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function ExternalActionTriggered(props) {
const intention = props.event.message.event.action.intention
let description = "External action " + deed.term + " triggered"
const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && intention && e.message.event.goalInfo.intention.value && e.message.event.goalInfo.intention.value.id === intention.id)
const info = "Type: external action" + (intention ? ", Intention: " + intention.id + " " + intention.trigger : "")
const info = "Type: external action" + (intention ? ", Intention: int-" + intention.id + "-" + intention.trigger : "")

return (
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function InternalActionFinished(props) {
const intention = props.event.message.event.intentionInfo.value
let description = "Internal action " + action.term + " finished"
const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && intention && e.message.event.goalInfo.goalFunctor === intention.trigger)
const info = "Type: " + action.type + (intention ? ", Intention: " + intention.id + " " + intention.trigger : "")
const info = "Type: " + action.type + (intention ? ", Intention: int-" + intention.id + "-" + intention.trigger : "")

return (
<div>
Expand Down
4 changes: 2 additions & 2 deletions src/model/agentState.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export function getIntentionReason(desire, intentionInfo) {
} else if (agentState.speechAct.tell.includes(parent)) {
reason = " created from " + parent + " message"
} else if (agentState.speechAct.achieve.includes(parent)) {
reason = " created from intention " + id + " " + parent
reason = " created from intention int-" + id + "-" + parent
} else if (agentState.belief.self.includes(parent)) {
reason = " formed from the belief " + parent
} else if (agentState.belief.percept.includes(parent)) {
reason = " created from the perception of " + parent
} else if (agentState.intention[id] && agentState.intention[id].includes(parent)) {
reason = " created from intention " + id + " " + parent
reason = " created from intention int-" + id + "-" + parent

}
}
Expand Down

0 comments on commit a6cfcd8

Please sign in to comment.