Search in sources :

Example 11 with Concept

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

the class Doubt method execute.

/**
 * To activate a concept as if a question has been asked about it
 *
 * @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 term = args[1];
    Concept concept = memory.conceptualize(Consider.budgetMentalConcept(operation), term);
    concept.discountConfidence(true);
    return null;
}
Also used : Concept(nars.entity.Concept) Term(nars.language.Term)

Example 12 with Concept

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

the class Hesitate method execute.

/**
 * To activate a concept as if a question has been asked about it
 *
 * @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 term = args[1];
    Concept concept = memory.conceptualize(Consider.budgetMentalConcept(operation), term);
    concept.discountConfidence(false);
    return null;
}
Also used : Concept(nars.entity.Concept) Term(nars.language.Term)

Example 13 with Concept

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

the class SwingLogText method print.

// public class TaskIcon extends NCanvas {
// 
// public TaskIcon() {
// super();
// setMaximumSize(new Dimension(50,10));
// setPreferredSize(new Dimension(50,10));
// setSize(50,10);
// 
// Graphics2D g = getBufferGraphics();
// 
// showBuffer(g);
// }
// 
// 
// 
// }
protected int print(Class c, Object o) {
    float priority = 1f;
    if (c != OUT.class) {
        // pad the channel name to max 6 characters, right aligned
        String n = c.getSimpleName();
        // n = n.substring(0,Math.min(4, n.length()));
        switch(n.length()) {
            case 0:
                break;
            case 1:
                n = "   " + n;
                break;
            case 2:
                n = "  " + n;
                break;
            case 3:
                n = " " + n;
                break;
        }
        Color chanColor = Video.getColor(c.getClass().hashCode(), 0.8f, 0.8f);
        print(chanColor, n);
    } else {
        if (o instanceof Task) {
            Task t = (Task) o;
            Sentence s = t.sentence;
            if (s != null) {
                priority = t.budget.getPriority();
                // printColorBlock(LogPanel.getPriorityColor(priority), "  ");
                TruthValue tv = s.truth;
                if (tv != null) {
                    float evidence = TruthFunctions.c2w(tv.getConfidence());
                    float pos_2 = tv.getConfidence() * tv.getFrequency();
                    float positive_evidence_in_0_1 = TruthFunctions.w2c(evidence * tv.getFrequency());
                    float negative_evidence_in_0_1 = TruthFunctions.w2c(evidence * (1.0f - tv.getFrequency()));
                    printColorBlock(LogPanel.getPositiveEvidenceColor(positive_evidence_in_0_1), "  ");
                    printColorBlock(LogPanel.getNegativeEvidenceColor(negative_evidence_in_0_1), "  ");
                } else if (t.getBestSolution() != null) {
                    float evidence = TruthFunctions.c2w(t.getBestSolution().truth.getConfidence());
                    float pos_2 = t.getBestSolution().truth.getConfidence() * t.getBestSolution().truth.getFrequency();
                    float positive_evidence_in_0_1 = TruthFunctions.w2c(evidence * t.getBestSolution().truth.getFrequency());
                    float negative_evidence_in_0_1 = TruthFunctions.w2c(evidence * (1.0f - t.getBestSolution().truth.getFrequency()));
                    // printColorBlock(LogPanel.getStatementColor('=', priority, t.getBestSolution().truth.get), "    ");
                    printColorBlock(LogPanel.getPositiveEvidenceColor(positive_evidence_in_0_1), "  ");
                    printColorBlock(LogPanel.getNegativeEvidenceColor(negative_evidence_in_0_1), "  ");
                } else {
                    printColorBlock(LogPanel.getStatementColor(s.punctuation, priority), "    ");
                }
            }
        }
    }
    CharSequence text = LogPanel.getText(c, o, showStamp, nar);
    StringBuilder sb = new StringBuilder(text.length() + 2);
    sb.append(' ');
    if (text.length() > maxLineWidth)
        sb.append(text.subSequence(0, maxLineWidth));
    else
        sb.append(text);
    if (sb.charAt(sb.length() - 1) != '\n')
        sb.append('\n');
    if (o instanceof Task) {
        Task t = (Task) o;
        int color = 128;
        Concept cc = nar.memory.concept(t.getTerm());
        color = (int) Math.min(255.0f, 80.0f + t.getPriority() * 255.0f);
        Color col = new Color(color, color, color);
        if (cc != null) {
            color = (int) (128.0f + cc.getPriority() * 128.0f);
            print(col, sb.toString(), new ConceptAction(cc));
            return doc.getLength();
        }
        print(col, sb.toString());
        return doc.getLength();
    }
    // float tc = 0.75f + 0.25f * priority;
    // Color textColor = new Color(tc,tc,tc);
    String s = sb.toString();
    print(Color.GRAY, sb.toString());
    return doc.getLength();
}
Also used : Concept(nars.entity.Concept) Task(nars.entity.Task) TruthValue(nars.entity.TruthValue) Color(java.awt.Color) Sentence(nars.entity.Sentence)

Example 14 with Concept

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

the class SentenceGraph method event.

@Override
public void event(final Class event, final Object[] a) {
    if (event == Events.ConceptForget.class) {
        // remove all associated beliefs
        Concept c = (Concept) a[0];
        // create a clone of the list for thread safety
        for (Task b : new ArrayList<Task>(c.beliefs)) {
            remove(b.sentence);
        }
    } else if (event == Events.ConceptBeliefAdd.class) {
        Concept c = (Concept) a[0];
        Sentence s = ((Task) a[1]).sentence;
        if (c.getPriority() > minConceptPri.get()) {
            add(s, c);
        }
    } else if (event == Events.ConceptBeliefRemove.class) {
        Concept c = (Concept) a[0];
        Sentence s = (Sentence) a[1];
        remove(s);
    } else /*else if (event == Events.ConceptGoalAdd.class) {
            Concept c = (Concept)a[0];
            Sentence s = ((Task)a[1]).sentence;
            add(s, c);
        }
        else if (event == Events.ConceptGoalRemove.class) {
            Concept c = (Concept)a[0];
            Sentence s = (Sentence)a[1];
            remove(s);
        }*/
    if (event == Events.CyclesEnd.class) {
        if (needInitialConcepts)
            getInitialConcepts();
    } else if (event == Events.ResetEnd.class) {
        reset();
    }
}
Also used : Concept(nars.entity.Concept) Task(nars.entity.Task) Events(nars.io.events.Events) ArrayList(java.util.ArrayList) Sentence(nars.entity.Sentence)

Example 15 with Concept

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

the class CircleLayout method vertex.

@Override
public void vertex(AbstractGraphVis<Item, Object> g, VertexVis<Item, Object> v) {
    Item vertex = v.getVertex();
    float priority = vertex.getPriority();
    double radius = (1.0 - priority) * spacing + 8;
    boolean task = false;
    Concept x = null;
    if (vertex instanceof Concept) {
        x = (Concept) vertex;
    } else if (vertex instanceof Task) {
        task = true;
        x = nar.memory.concept(((Task) vertex).getTerm());
    }
    float angle = ((arcStop - arcStart) * Video.hashFloat(x.hashCode()) + arcStart) * ((float) Math.PI * 2f);
    v.tx = (float) (Math.cos(angle) * radius) * spacing;
    v.ty = (float) (Math.sin(angle) * radius) * spacing;
    if (task) {
        v.ty += spacing * Video.hashFloat(vertex.hashCode());
    }
}
Also used : Concept(nars.entity.Concept) Item(nars.entity.Item) Task(nars.entity.Task)

Aggregations

Concept (nars.entity.Concept)30 Task (nars.entity.Task)18 Term (nars.language.Term)14 Sentence (nars.entity.Sentence)10 BudgetValue (nars.entity.BudgetValue)7 Events (nars.io.events.Events)6 CompoundTerm (nars.language.CompoundTerm)6 TruthValue (nars.entity.TruthValue)5 Interval (nars.language.Interval)4 ArrayList (java.util.ArrayList)3 Conjunction (nars.language.Conjunction)3 Color (java.awt.Color)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 DerivationContext (nars.control.DerivationContext)2 Item (nars.entity.Item)2 Stamp (nars.entity.Stamp)2 Implication (nars.language.Implication)2 NAR (nars.main.NAR)2 Memory (nars.storage.Memory)2