Skip to content

Commit

Permalink
update: implement realization threshold and disable goal detachment
Browse files Browse the repository at this point in the history
  • Loading branch information
PtrMan committed May 23, 2020
1 parent fa6dc86 commit 41a347a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions Executive.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,10 @@ class GoalSystem {

public var goaltableSize:Int = 30;

public var realizedThreshold:Float = 0.9*0.5; // setting - threshold to realize a goal

public var enGoalDetachment:Bool = false; // do we enable goal detachment?, disabled because current version has control problems

public function new() {}

// filter goals by first event
Expand All @@ -1115,7 +1119,6 @@ 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
}
Expand Down Expand Up @@ -1265,7 +1268,7 @@ class GoalSystem {
}
else { // case with ops
{
if (sampledGoal.condOps.cond.events.length > 0) { // must have cond events!
if (sampledGoal.condOps.cond.events.length > 0 && enGoalDetachment) { // must have cond events!
// (a &/ ^x)!
// |- DesireDed (deduction) (structural deduction)
// a!
Expand Down Expand Up @@ -1353,7 +1356,7 @@ class GoalSystem {
// scan all goals and decrement desire if it matches
for(iGoal in activeGoals) {
if (iGoal.condOps.ops.length == 0 && Par.checkSame(iGoal.condOps.cond, new Par([term]))) { // does term match?
iGoal.desire = new Tv(0.0, 0.998); // we fullfilled the goal when the event happened
iGoal.beliefTv = new Tv(1.0, 0.998); // we have a belief for the goal when it happened
}
}
}
Expand Down Expand Up @@ -1443,6 +1446,8 @@ class ActiveGoal2 {

public var desire:Tv = new Tv(1.0, 0.998); // how much do we want to realize the goal?

public var beliefTv:Tv = null; // belief which has the same term

public function new(condOps, desire, stamp, creationTime) {
this.condOps = condOps;
this.desire = desire;
Expand All @@ -1456,15 +1461,8 @@ class ActiveGoal2 {
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!";
}
var beliefExp:Float = beliefTv == null ? beliefTv.exp() : 0.5; // expectation of the belief
return Math.abs(desire.exp() - beliefExp);
}

public function convToStr():String {
Expand Down

0 comments on commit 41a347a

Please sign in to comment.