use of nars.language.SetInt in project opennars by opennars.
the class StructuralRules method structuralDecompose2.
/**
* {<(S*T) --> (P*T)>, S@(S*T)} |- <S --> P>
*
* @param statement The premise
* @param nal Reference to the memory
*/
static void structuralDecompose2(Statement statement, int index, DerivationContext nal) {
Term subj = statement.getSubject();
Term pred = statement.getPredicate();
if (subj.getClass() != pred.getClass()) {
return;
}
if (!(subj instanceof Product) && !(subj instanceof SetExt) && !(subj instanceof SetInt)) {
// no abduction on other compounds for now, but may change in the future
return;
}
CompoundTerm sub = (CompoundTerm) subj;
CompoundTerm pre = (CompoundTerm) pred;
if (sub.size() != pre.size() || sub.size() <= index) {
return;
}
Term t1 = sub.term[index];
Term t2 = pre.term[index];
Statement content;
int order = statement.getTemporalOrder();
if (switchOrder(sub, (short) index)) {
content = Statement.make(statement, t2, t1, TemporalRules.reverseOrder(order));
} else {
content = Statement.make(statement, t1, t2, order);
}
if (content == null) {
return;
}
Task task = nal.getCurrentTask();
Sentence sentence = task.sentence;
TruthValue truth = sentence.truth;
BudgetValue budget;
if (sentence.isQuestion() || sentence.isQuest()) {
budget = BudgetFunctions.compoundBackward(content, nal);
} else {
budget = BudgetFunctions.compoundForward(truth, content, nal);
}
nal.singlePremiseTask(content, truth, budget);
}
use of nars.language.SetInt in project opennars by opennars.
the class Feel method feeling.
/**
* To get the current value of an internal sensor
*
* @param value The value to be checked, in [0, 1]
* @param memory The memory in which the operation is executed
* @return Immediate results as Tasks
*/
protected ArrayList<Task> feeling(float value, Memory memory) {
Stamp stamp = new Stamp(memory, Tense.Present);
TruthValue truth = new TruthValue(value, Parameters.DEFAULT_JUDGMENT_CONFIDENCE);
Term predicate = new SetInt(feelingTerm);
Term content = Inheritance.make(selfSubject, predicate);
Sentence sentence = new Sentence(content, Symbols.JUDGMENT_MARK, truth, stamp);
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