use of nars.entity.BudgetValue in project opennars by opennars.
the class Emotions method adjustBusy.
public void adjustBusy(float newValue, float weight, DerivationContext nal) {
busy += newValue * weight;
busy /= (1.0f + weight);
if (!enabled) {
return;
}
float frequency = -1;
if (Math.abs(busy - lastbusy) > CHANGE_THRESHOLD && nal.memory.time() - last_busy_time > change_steps_demanded) {
if (busy > Parameters.BUSY_EVENT_HIGHER_THRESHOLD && lastbusy <= Parameters.BUSY_EVENT_HIGHER_THRESHOLD) {
frequency = 1.0f;
}
if (busy < Parameters.BUSY_EVENT_LOWER_THRESHOLD && lastbusy >= Parameters.BUSY_EVENT_LOWER_THRESHOLD) {
frequency = 0.0f;
}
lastbusy = busy;
last_busy_time = nal.memory.time();
}
if (frequency != -1) {
// ok lets add an event now
Term predicate = SetInt.make(new Term("busy"));
Term subject = new Term("SELF");
Inheritance inh = Inheritance.make(subject, predicate);
TruthValue truth = new TruthValue(busy, Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
Sentence s = new Sentence(inh, Symbols.JUDGMENT_MARK, truth, new Stamp(nal.memory));
s.stamp.setOccurrenceTime(nal.memory.time());
Task t = new Task(s, new BudgetValue(Parameters.DEFAULT_JUDGMENT_PRIORITY, Parameters.DEFAULT_JUDGMENT_DURABILITY, BudgetFunctions.truthToQuality(truth)), true);
nal.addTask(t, "emotion");
}
}
use of nars.entity.BudgetValue in project opennars by opennars.
the class Emotions method adjustSatisfaction.
public void adjustSatisfaction(float newValue, float weight, DerivationContext nal) {
// float oldV = happyValue;
happy += newValue * weight;
happy /= 1.0f + weight;
if (!enabled) {
return;
}
float frequency = -1;
if (Math.abs(happy - lasthappy) > CHANGE_THRESHOLD && nal.memory.time() - last_happy_time > change_steps_demanded) {
if (happy > Parameters.HAPPY_EVENT_HIGHER_THRESHOLD && lasthappy <= Parameters.HAPPY_EVENT_HIGHER_THRESHOLD) {
frequency = 1.0f;
}
if (happy < Parameters.HAPPY_EVENT_LOWER_THRESHOLD && lasthappy >= Parameters.HAPPY_EVENT_LOWER_THRESHOLD) {
frequency = 0.0f;
}
lasthappy = happy;
last_happy_time = nal.memory.time();
}
if (frequency != -1) {
// ok lets add an event now
Term predicate = SetInt.make(new Term("satisfied"));
Term subject = Term.SELF;
Inheritance inh = Inheritance.make(subject, predicate);
TruthValue truth = new TruthValue(happy, Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
Sentence s = new Sentence(inh, Symbols.JUDGMENT_MARK, truth, new Stamp(nal.memory));
s.stamp.setOccurrenceTime(nal.memory.time());
Task t = new Task(s, new BudgetValue(Parameters.DEFAULT_JUDGMENT_PRIORITY, Parameters.DEFAULT_JUDGMENT_DURABILITY, BudgetFunctions.truthToQuality(truth)), true);
nal.addTask(t, "emotion");
/*if(Parameters.REFLECT_META_HAPPY_GOAL) { //remind on the goal whenever happyness changes, should suffice for now
TruthValue truth2=new TruthValue(1.0f,Parameters.DEFAULT_GOAL_CONFIDENCE);
Sentence s2=new Sentence(inh,Symbols.GOAL_MARK,truth2,new Stamp(nal.memory));
s2.stamp.setOccurrenceTime(nal.memory.time());
Task t2=new Task(s2,new BudgetValue(Parameters.DEFAULT_GOAL_PRIORITY,Parameters.DEFAULT_GOAL_DURABILITY,BudgetFunctions.truthToQuality(truth2)));
nal.addTask(t2, "metagoal");
//this is a good candidate for innate belief for consider and remind:
Operator consider=nal.memory.getOperator("^consider");
Operator remind=nal.memory.getOperator("^remind");
Term[] arg=new Term[1];
arg[0]=inh;
if(InternalExperience.enabled && Parameters.CONSIDER_REMIND) {
Operation op_consider=Operation.make(consider, arg, true);
Operation op_remind=Operation.make(remind, arg, true);
Operation[] op=new Operation[2];
op[0]=op_remind; //order important because usually reminding something
op[1]=op_consider; //means it has good chance to be considered after
for(Operation o : op) {
TruthValue truth3=new TruthValue(1.0f,Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
Sentence s3=new Sentence(o,Symbols.JUDGMENT_MARK,truth3,new Stamp(nal.memory));
s3.stamp.setOccurrenceTime(nal.memory.time());
//INTERNAL_EXPERIENCE_DURABILITY_MUL
BudgetValue budget=new BudgetValue(Parameters.DEFAULT_JUDGMENT_PRIORITY,Parameters.DEFAULT_JUDGMENT_DURABILITY,BudgetFunctions.truthToQuality(truth3));
budget.setPriority(budget.getPriority()*InternalExperience.INTERNAL_EXPERIENCE_PRIORITY_MUL);
budget.setDurability(budget.getPriority()*InternalExperience.INTERNAL_EXPERIENCE_DURABILITY_MUL);
Task t3=new Task(s3,budget);
nal.addTask(t3, "internal experience for consider and remind");
}
}
}*/
}
// if (Math.abs(oldV - happyValue) > 0.1) {
// Record.append("HAPPY: " + (int) (oldV*10.0) + " to " + (int) (happyValue*10.0) + "\n");
}
use of nars.entity.BudgetValue in project opennars by opennars.
the class InternalExperience method InternalExperienceFromTaskInternal.
public static boolean InternalExperienceFromTaskInternal(Memory memory, Task task, boolean full) {
if (!enabled) {
return false;
}
// if(OLD_BELIEVE_WANT_EVALUATE_WONDER_STRATEGY ||
// (!OLD_BELIEVE_WANT_EVALUATE_WONDER_STRATEGY && (task.sentence.punctuation==Symbols.QUESTION_MARK || task.sentence.punctuation==Symbols.QUEST_MARK))) {
{
if (task.sentence.punctuation == Symbols.QUESTION_MARK || task.sentence.punctuation == Symbols.QUEST_MARK) {
if (task.getPriority() < MINIMUM_PRIORITY_TO_CREATE_WONDER_EVALUATE) {
return false;
}
} else if (task.getPriority() < MINIMUM_PRIORITY_TO_CREATE_WANT_BELIEVE_ETC) {
return false;
}
}
Term content = task.getTerm();
// to prevent infinite recursions
if (content instanceof Operation) /* || Memory.randomNumber.nextDouble()>Parameters.INTERNAL_EXPERIENCE_PROBABILITY*/
{
return true;
}
Sentence sentence = task.sentence;
TruthValue truth = new TruthValue(1.0f, Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
Stamp stamp = task.sentence.stamp.clone();
stamp.setOccurrenceTime(memory.time());
Term ret = toTerm(sentence, memory);
if (ret == null) {
return true;
}
Sentence j = new Sentence(ret, Symbols.JUDGMENT_MARK, truth, stamp);
BudgetValue newbudget = new BudgetValue(Parameters.DEFAULT_JUDGMENT_CONFIDENCE * INTERNAL_EXPERIENCE_PRIORITY_MUL, Parameters.DEFAULT_JUDGMENT_PRIORITY * INTERNAL_EXPERIENCE_DURABILITY_MUL, BudgetFunctions.truthToQuality(truth));
if (!OLD_BELIEVE_WANT_EVALUATE_WONDER_STRATEGY) {
newbudget.setPriority(task.getPriority() * INTERNAL_EXPERIENCE_PRIORITY_MUL);
newbudget.setDurability(task.getDurability() * INTERNAL_EXPERIENCE_DURABILITY_MUL);
}
Task newTask = new Task(j, (BudgetValue) newbudget, true);
memory.addNewTask(newTask, "Reflected mental operation (Internal Experience)");
return false;
}
use of nars.entity.BudgetValue in project opennars by opennars.
the class VisionChannel method step_start.
@Override
public void step_start() {
Sentence s = new Sentence(Inheritance.make(new Term("A"), this.label), Symbols.JUDGMENT_MARK, new TruthValue(1.0f, Parameters.DEFAULT_JUDGMENT_CONFIDENCE), new Stamp(nar.memory));
Task T = new Task(s, new BudgetValue(Parameters.DEFAULT_JUDGMENT_PRIORITY, Parameters.DEFAULT_JUDGMENT_DURABILITY, BudgetFunctions.truthToQuality(s.truth)), true);
// feeds results into "upper" sensory channels:
this.results.add(T);
this.step_finished();
}
use of nars.entity.BudgetValue in project opennars by opennars.
the class Believe method execute.
/**
* To create a judgment with a given statement
* @param args Arguments, a Statement followed by an optional tense
* @param memory The memory in which the operation is executed
*+ * @return Immediate results as Tasks
*/
@Override
protected ArrayList<Task> execute(Operation operation, Term[] args, Memory memory) {
Term content = args[1];
TruthValue truth = new TruthValue(1, Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
Sentence sentence = new Sentence(content, Symbols.JUDGMENT_MARK, truth, new Stamp(memory));
float quality = BudgetFunctions.truthToQuality(truth);
BudgetValue budget = new BudgetValue(Parameters.DEFAULT_JUDGMENT_PRIORITY, Parameters.DEFAULT_JUDGMENT_DURABILITY, quality);
return Lists.newArrayList(new Task(sentence, budget, true));
}
Aggregations