Skip to content

Commit

Permalink
refactor: add trigger in the intention info
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-elena committed May 6, 2024
1 parent ae10709 commit 892624a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/java/event/eventInfo/IntentionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class IntentionInfo {
private final Intention.State state;
private final LinkedList<IntendedMeansInfo> intendedMeansInfo;

private final String trigger;


/**
* Creates a new instance of {@link IntentionInfo} from the given intention.
* @param intention the intention of the agent
Expand All @@ -25,6 +28,7 @@ public IntentionInfo(Intention intention) {
intendedMeansInfo = new LinkedList<>();
intention.spliterator().forEachRemaining(intendedMeans -> intendedMeansInfo.add(new IntendedMeansInfo(intendedMeans)));

trigger = !intendedMeansInfo.isEmpty() ? intendedMeansInfo.getFirst().getPlan().getTrigger() : "";
}

/**
Expand All @@ -51,4 +55,11 @@ public Intention.State getState() {
return state;
}

/**
* Returns the trigger of the intention
* @return trigger
*/
public String getTrigger() {
return trigger;
}
}
2 changes: 1 addition & 1 deletion src/java/event/intentionEvent/IntentionEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public IntentionEvent(Intention intention, Term reason) {
public String logEvent() {
Optional<IntendedMeansInfo> intendedMeans = intentionInfo.peekFirstIntendedMeans();
return "Intention " + intentionInfo.getId() +
intendedMeans.map(im -> " " + im.getTrigger()).orElse("") +
intendedMeans.map(im -> " " + im.getPlan().getTrigger()).orElse("") +
" " + getEventMessage() + this.reasonInfo.map(ReasonInfo::toString).orElse("") +
", state: " + intentionInfo.getState() +
"\n\tcurrent step: " + intendedMeans.map(im ->
Expand Down

0 comments on commit 892624a

Please sign in to comment.