Search in sources :

Example 6 with TruthValue

use of nars.entity.TruthValue 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;
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) TruthValue(nars.entity.TruthValue) Term(nars.language.Term) Operation(nars.operator.Operation) Sentence(nars.entity.Sentence)

Example 7 with TruthValue

use of nars.entity.TruthValue 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();
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) TruthValue(nars.entity.TruthValue) Term(nars.language.Term) Sentence(nars.entity.Sentence)

Example 8 with TruthValue

use of nars.entity.TruthValue in project opennars by opennars.

the class VisualSpace method AbductionOrComparisonTo.

@Override
public TruthValue AbductionOrComparisonTo(ImaginationSpace obj, boolean comparison) {
    if (!(obj instanceof VisualSpace)) {
        return new TruthValue(1.0f, 0.0f);
    }
    VisualSpace other = (VisualSpace) obj;
    double kh = ((float) other.height) / ((double) this.height);
    double kw = ((float) other.width) / ((double) this.width);
    TruthValue sim = new TruthValue(1.0f, 0.0f);
    for (int i = 0; i < this.height; i++) {
        for (int j = 0; j < this.width; j++) {
            int i2 = (int) (((double) this.height) * kh);
            int j2 = (int) (((double) this.width) * kw);
            TruthValue t1 = new TruthValue(cropped[i][j], Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
            TruthValue t2 = new TruthValue(other.cropped[i2][j2], Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
            TruthValue t3 = comparison ? TruthFunctions.comparison(t1, t2) : TruthFunctions.abduction(t1, t2);
            sim = TruthFunctions.revision(sim, t3);
        }
    }
    return sim;
}
Also used : TruthValue(nars.entity.TruthValue)

Example 9 with TruthValue

use of nars.entity.TruthValue 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));
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Stamp(nars.entity.Stamp) TruthValue(nars.entity.TruthValue) Term(nars.language.Term) Sentence(nars.entity.Sentence)

Example 10 with TruthValue

use of nars.entity.TruthValue in project opennars by opennars.

the class Name 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 compound = args[1];
    Term atomic = args[2];
    Similarity content = Similarity.make(compound, atomic);
    // a naming convension
    TruthValue truth = new TruthValue(1, 0.9999f);
    Sentence sentence = new Sentence(content, Symbols.JUDGMENT_MARK, truth, new Stamp(memory));
    BudgetValue budget = new BudgetValue(Parameters.DEFAULT_JUDGMENT_PRIORITY, Parameters.DEFAULT_JUDGMENT_DURABILITY, truth);
    return Lists.newArrayList(new Task(sentence, budget, true));
}
Also used : BudgetValue(nars.entity.BudgetValue) Task(nars.entity.Task) Similarity(nars.language.Similarity) Stamp(nars.entity.Stamp) TruthValue(nars.entity.TruthValue) Term(nars.language.Term) Sentence(nars.entity.Sentence)

Aggregations

TruthValue (nars.entity.TruthValue)64 BudgetValue (nars.entity.BudgetValue)52 Term (nars.language.Term)46 Sentence (nars.entity.Sentence)39 CompoundTerm (nars.language.CompoundTerm)36 Task (nars.entity.Task)34 Statement (nars.language.Statement)20 Stamp (nars.entity.Stamp)18 Conjunction (nars.language.Conjunction)18 Inheritance (nars.language.Inheritance)12 Interval (nars.language.Interval)10 Implication (nars.language.Implication)9 Product (nars.language.Product)7 Variable (nars.language.Variable)7 Concept (nars.entity.Concept)5 SetExt (nars.language.SetExt)5 SetInt (nars.language.SetInt)5 Operation (nars.operator.Operation)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4