-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add goal created in the design level
- Loading branch information
Showing
3 changed files
with
73 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import DesireCommitted from "./DesireCommitted"; | ||
import NewDesire from "./NewDesire"; | ||
|
||
function BDIGoalCreated(props) { | ||
return ( | ||
<div> | ||
<NewDesire log={props.log} event={props.event} filter={props.filter} level={props.level}/> | ||
<div className={"mb-5"}/> | ||
<DesireCommitted log={props.log} event={props.event} filter={props.filter} level={props.level}/> | ||
</div> | ||
) | ||
} | ||
|
||
export default BDIGoalCreated; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,70 @@ | ||
import React from "react"; | ||
import Event from "../Event"; | ||
import {agentState, getIntentionReason} from "../../../model/agentState"; | ||
import {Level} from "../../../model/Level"; | ||
|
||
function DesireCommitted(props) { | ||
|
||
const type = "Desire committed"; | ||
|
||
const intention = props.event.message.event | ||
const desire = intention.intentionInfo.trigger | ||
let selectedPlan = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "SelectPlanEvent" && e.message.event.selectedPlan.trigger === desire) | ||
const planSelected = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "PlanSelected" && e.message.event.goalInfo.goalFunctor === desire) | ||
const type = "Desire committed" | ||
const goalInfo = props.event.message.event.goalInfo | ||
const goal = goalInfo.goalFunctor | ||
const description = "I committed to desire " + goal + " and it becomes a goal" | ||
const source = goalInfo.source.value | ||
const intention = goalInfo.intention.value | ||
const explanation = props.event | ||
let parentDesire | ||
|
||
const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.goalFunctor === desire) | ||
if (source && source.includes("self")) { | ||
if (intention && intention.intendedMeansInfo.length > 0) { | ||
console.log(intention.intendedMeansInfo) | ||
parentDesire = "Goal " + goal + " is a goal created from " + intention.intendedMeansInfo[0].trigger | ||
} | ||
} | ||
|
||
if (intention && selectedPlan && planSelected) { | ||
selectedPlan = selectedPlan.message.event.selectedPlan | ||
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 int-" + id + "-" + intention.intentionInfo.trigger | ||
return ( | ||
<Event type={type} description={description} info={parentDesire} | ||
timestamp={props.event.timestamp} | ||
filter={props.filter} | ||
explanation={explanation} | ||
log={props.log} | ||
level={Level.DESIGN}/> | ||
) | ||
|
||
let reason = getIntentionReason(desire, intention.intentionInfo) | ||
let parentDesire = reason ? ["Intention int-" + id + "-" + desire + " is an intention " + reason, <br/>] : [] | ||
|
||
if (agentState.intention[id]) { | ||
agentState.intention[id].push(desire) | ||
} else { | ||
agentState.intention[id] = [desire] | ||
} | ||
|
||
return ( | ||
<div> | ||
<Event type={type} description={description} info={[...parentDesire, body]} | ||
timestamp={props.event.timestamp} | ||
filter={props.filter} | ||
explanation={explanation} | ||
log={props.log} | ||
level={Level.DESIGN}/> | ||
</div> | ||
|
||
) | ||
} | ||
// const type = "Desire committed"; | ||
// | ||
// const intention = props.event.message.event | ||
// const desire = intention.intentionInfo.trigger | ||
// let selectedPlan = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "SelectPlanEvent" && e.message.event.selectedPlan.trigger === desire) | ||
// const planSelected = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "PlanSelected" && e.message.event.goalInfo.goalFunctor === desire) | ||
// | ||
// const explanation = props.log.slice(0, props.log.indexOf(props.event)).findLast(e => e.message.type === "GoalCreated" && e.message.event.goalInfo.goalFunctor === desire) | ||
// | ||
// if (intention && selectedPlan && planSelected) { | ||
// selectedPlan = selectedPlan.message.event.selectedPlan | ||
// 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 int-" + id + "-" + intention.intentionInfo.trigger | ||
// | ||
// let reason = getIntentionReason(desire, intention.intentionInfo) | ||
// let parentDesire = reason ? ["Intention int-" + id + "-" + desire + " is an intention " + reason, <br/>] : [] | ||
// | ||
// if (agentState.intention[id]) { | ||
// agentState.intention[id].push(desire) | ||
// } else { | ||
// agentState.intention[id] = [desire] | ||
// } | ||
// | ||
// return ( | ||
// <Event type={type} description={description} info={[...parentDesire, body]} | ||
// timestamp={props.event.timestamp} | ||
// filter={props.filter} | ||
// explanation={explanation} | ||
// log={props.log} | ||
// level={Level.DESIGN}/> | ||
// ) | ||
// } | ||
} | ||
|
||
export default DesireCommitted; |