static void testNars() { CompoundAndTermContext compoundAndTermContext = new CompoundAndTermContext(); RuleDispatcher.compoundAndTermContext = compoundAndTermContext; // for debugging PrototypingInput prototypingInput = new PrototypingInput(compoundAndTermContext); Nar nar = Nar.make(compoundAndTermContext, new MetaNix.nars.config.RuntimeParameters()); CompoundIndex compoundIndex1 = prototypingInput.makeInheritance("a", "b"); ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters task1SentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters(); task1SentenceParameters.term = compoundAndTermContext.accessCompoundByIndex(compoundIndex1).thisTermReferer; task1SentenceParameters.truth = TruthValue.make(1.0f, 0.5f); task1SentenceParameters.stamp = Stamp.makeWithPresentTense(nar.memory); task1SentenceParameters.punctation = ClassicalSentence.EnumPunctation.JUDGMENT; ClassicalSentence task1Sentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(task1SentenceParameters); ClassicalTask.MakeParameters task1MakeParameters = new ClassicalTask.MakeParameters(); task1MakeParameters.sentence = task1Sentence; task1MakeParameters.budget = new ClassicalBudgetValue(0.5f, 0.5f, 0.5f); nar.inputTask(ClassicalTask.make(task1MakeParameters)); CompoundIndex compoundIndex2 = prototypingInput.makeInheritance("b", "c"); ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters task2SentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters(); task2SentenceParameters.term = compoundAndTermContext.accessCompoundByIndex(compoundIndex2).thisTermReferer; task2SentenceParameters.truth = TruthValue.make(1.0f, 0.5f); task2SentenceParameters.stamp = Stamp.makeWithPresentTense(nar.memory); task2SentenceParameters.punctation = ClassicalSentence.EnumPunctation.JUDGMENT; ClassicalSentence task2Sentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(task2SentenceParameters); ClassicalTask.MakeParameters task2MakeParameters = new ClassicalTask.MakeParameters(); task2MakeParameters.sentence = task2Sentence; task2MakeParameters.budget = new ClassicalBudgetValue(0.5f, 0.5f, 0.5f); nar.inputTask(ClassicalTask.make(task2MakeParameters)); for (;;) { nar.cycle(); } int here = 5; }
/* --------------- new task building --------------- */ /** * Shared final operations by all double-premise rules, called from the * rules except StructuralRules * * \param newContent The content of the sentence in task * \param newTruth The truth value of the sentence in task * \param newBudget The budget value in task */ public bool doublePremiseTaskRevised(TermOrCompoundTermOrVariableReferer newContent, TruthValue newTruth, ClassicalBudgetValue newBudget) { ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters makeSentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters(); makeSentenceParameters.term = newContent; makeSentenceParameters.punctation = currentTask.sentence.punctation; makeSentenceParameters.truth = newTruth; makeSentenceParameters.stamp = returnTheNewStamp(); ClassicalSentence newSentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(makeSentenceParameters); ClassicalTask.MakeParameters makeTaskParameters = new ClassicalTask.MakeParameters(); makeTaskParameters.sentence = newSentence; makeTaskParameters.budget = newBudget; makeTaskParameters.parentTask = currentTask; makeTaskParameters.parentBelief = currentBelief; ClassicalTask newTask = ClassicalTask.make(makeTaskParameters); return(derivedTask(newTask, true, false, null, null, true)); // allows overlap since overlap was already checked on revisable( function // which is not the case for other single premise tasks }
// see https://github.com/opennars/opennars/blob/4515f1d8e191a1f097859decc65153287d5979c5/nars_core/nars/control/DerivationContext.java#L217 /** * Shared final operations by all double-premise rules, called from the * rules except StructuralRules * * /param newContent The content of the sentence in task * /param newTruth The truth value of the sentence in task * /param newBudget The budget value in task * /param temporalInduction * /param overlapAllowed // https://groups.google.com/forum/#!topic/open-nars/FVbbKq5En-M */ public IList <ClassicalTask> doublePremiseTask( TermOrCompoundTermOrVariableReferer newContent, TruthValue newTruth, ClassicalBudgetValue newBudget, bool temporalInduction, bool overlapAllowed ) { IList <ClassicalTask> ret = new List <ClassicalTask>(); if (newContent == null) { return(null); } if (!newBudget.isAboveThreshold) { return(null); } if ( newContent == null /* commented because not implemented || * ((newContent instanceof Interval)) || * ((newContent instanceof Variable))*/ ) { return(null); } /* commented because not implemented * if (newContent.subjectOrPredicateIsIndependentVar()) { * return null; * }*/ ClassicalSentence newSentence; ClassicalTask newTask; ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters makeSentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters(); makeSentenceParameters.term = newContent; makeSentenceParameters.punctation = currentTask.sentence.punctation; makeSentenceParameters.truth = newTruth; makeSentenceParameters.stamp = returnTheNewStamp(); newSentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(makeSentenceParameters); newSentence.producedByTemporalInduction = temporalInduction; ClassicalTask.MakeParameters taskMakeParameters = new ClassicalTask.MakeParameters(); taskMakeParameters.sentence = newSentence; taskMakeParameters.budget = newBudget; taskMakeParameters.parentTask = currentTask; taskMakeParameters.parentBelief = currentBelief; newTask = ClassicalTask.make(taskMakeParameters); if (newTask != null) { bool added = derivedTask(newTask, false, false, null, null, overlapAllowed); if (added) { ret.Add(newTask); } } // "Since in principle it is always valid to eternalize a tensed belief" if (temporalInduction && Parameters.IMMEDIATE_ETERNALIZATION) // temporal induction generated ones get eternalized directly { TruthValue truthEternalized = TruthFunctions.eternalize(newTruth); Stamp st = returnTheNewStamp().clone(); st.isEternal = true; makeSentenceParameters = new ClassicalSentence.MakeByTermPunctuationTruthStampNormalizeParameters(); makeSentenceParameters.term = newContent; makeSentenceParameters.punctation = currentTask.sentence.punctation; makeSentenceParameters.truth = truthEternalized; makeSentenceParameters.stamp = st; newSentence = ClassicalSentence.makeByTermPunctuationTruthStampNormalize(makeSentenceParameters); newSentence.producedByTemporalInduction = temporalInduction; taskMakeParameters = new ClassicalTask.MakeParameters(); taskMakeParameters.sentence = newSentence; taskMakeParameters.budget = newBudget; taskMakeParameters.parentTask = currentTask; taskMakeParameters.parentBelief = currentBelief; newTask = ClassicalTask.make(taskMakeParameters); if (newTask != null) { bool added = derivedTask(newTask, false, false, null, null, overlapAllowed); if (added) { ret.Add(newTask); } } } return(ret); }