From 23920299d7d11e199d04369f7cbbf5cfc2f7d5e8 Mon Sep 17 00:00:00 2001 From: Patrick Hammer <patham9@gmail.com> Date: Thu, 29 Mar 2018 17:23:45 -0400 Subject: [PATCH] Fear implementation. --- .../nars/plugin/mental/ComplexEmotions.java | 46 ++++++++----------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/nars_core/nars/plugin/mental/ComplexEmotions.java b/nars_core/nars/plugin/mental/ComplexEmotions.java index fa77a75531..b9a0483049 100644 --- a/nars_core/nars/plugin/mental/ComplexEmotions.java +++ b/nars_core/nars/plugin/mental/ComplexEmotions.java @@ -6,11 +6,12 @@ package nars.plugin.mental; import nars.entity.Concept; import nars.entity.Task; +import static nars.inference.LocalRules.solutionQuality; import nars.io.events.EventEmitter; import nars.io.events.EventEmitter.EventObserver; import nars.io.events.Events; import nars.io.events.Events.Answer; -import nars.io.events.OutputHandler; +import nars.language.Term; import nars.main.NAR; import nars.plugin.Plugin; import nars.storage.Memory; @@ -22,6 +23,7 @@ import nars.storage.Memory; public class ComplexEmotions implements Plugin { public EventEmitter.EventObserver obs; + float fear = 0.5f; @Override public boolean setEnabled(NAR n, boolean enabled) { if(enabled) { @@ -39,34 +41,26 @@ public class ComplexEmotions implements Plugin { if(future_task.sentence.getOccurenceTime() > n.time()) { Concept c = n.memory.concept(future_task.getTerm()); - float true_expectation = 0.6f; - float false_expectation = 0.4f; + float true_expectation = 0.5f; + float false_expectation = 0.5f; if(c != null) { if(c.desires.size() > 0 && c.beliefs.size() > 0) { - /* - want: a! - have a. :|: - believe it will stay that way: a. :/: - Happiness about a - */ - if(c.desires.get(0).sentence.truth.getExpectation() > true_expectation) { - if(c.beliefs.get(0).sentence.truth.getExpectation() > true_expectation) { - if(future_task.sentence.truth.getExpectation() > true_expectation) { - System.out.println("happy"); - n.addInput("<(*,{SELF},happy) --> ^feel>. :|:"); - memory.emit(Answer.class, "happy"); - } - } - } - - if(c.desires.get(0).sentence.truth.getExpectation() < false_expectation) { - if(c.beliefs.get(0).sentence.truth.getExpectation() < false_expectation) { - if(future_task.sentence.truth.getExpectation() > true_expectation) { - System.out.println("fear"); - n.addInput("<(*,{SELF},fear) --> ^feel>. :|:"); - memory.emit(Answer.class, "fear"); - } + //Fear: + if(future_task.sentence.truth.getExpectation() > true_expectation && + c.desires.get(0).sentence.truth.getExpectation() < false_expectation) { + //n.addInput("<(*,{SELF},fear) --> ^feel>. :|:"); + float weight = future_task.getPriority(); + float fear = solutionQuality(true, c.desires.get(0), future_task.sentence, memory); + float newValue = fear*weight; + fear += newValue * weight; + fear /= 1.0f + weight; + //incrase concept priority by fear value: + Concept C1 = memory.concept(future_task.getTerm()); + if(C1 != null) { + C1.incPriority(fear); } + memory.emit(Answer.class, "Fear value="+fear); + System.out.println("Fear value="+fear); } } } -- GitLab