Skip to content

Commit

Permalink
update: Executive: implemented Pei's new 'realized' idea partially
Browse files Browse the repository at this point in the history
  • Loading branch information
PtrMan committed May 22, 2020
1 parent a6b6184 commit fa6dc86
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Executive.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,11 @@ class GoalSystem {
if( iGoal.condOps.ops.length == 0 ) { // must have no ops
if (iGoal.condOps.cond.events.length == 1) { // must be a single event which is the goal
if (TermUtils.equal(iGoal.condOps.cond.events[0], effects[0])) { // is the term the same? // TODO< check for subset of par >
var realizedThreshold:Float = 0.9;
if (iGoal.calcRealized() > realizedThreshold) {
continue; // don't realize already realized goals
}

if (bestGoal == null) {
bestGoal = iGoal;
}
Expand Down Expand Up @@ -1225,6 +1230,11 @@ class GoalSystem {
return;
}

//var realizedThreshold:Float = 0.9;
//if (sampledGoal.calcRealized() > realizedThreshold) {
// return; // don't realize already realized goals
//}

if (sampledGoal.condOps.ops.length == 0) {
Dbg.dbg(debugGoalSystem, 'goalsystem: GOAL DERIVATION');

Expand Down Expand Up @@ -1440,6 +1450,23 @@ class ActiveGoal2 {
this.creationTime = creationTime;
}

/*Goal:
If the expectation of its desire-value is e, and the system has a matching belief with expectation e′, h=|e−e′|.
If there is no matching belief, h=|e−0.5|.
It measures the extent the desired statement is already realized.
*/
public function calcRealized():Float {
var hasMatchingBelief = false;

if (!hasMatchingBelief) {
return 1.0-desire.exp(); // adapted formula which makes more sense
}
else {
// TODO< implement matching belief case >
throw "NOT IMPLEMENTED!";
}
}

public function convToStr():String {
var res = ExecUtils.convCondOpToStr(condOps) + "! ";
res += desire.convToStr() + " ";
Expand Down

0 comments on commit fa6dc86

Please sign in to comment.