Ejemplo n.º 1
0
        // Adds a new literal at the end of the belief base
        protected bool Add(Literal l, bool addInEnd)
        {
            if (!l.CanBeAddedInBB())
            {
                return(false);
            }

            Literal bl = Contains(l);

            if (bl != null && !bl.IsRule())
            {
                if (bl.ImportAnnots(l))
                {
                    if (l.HasAnnot(TPercept))
                    {
                        percepts.Add(bl);
                    }
                    return(true);
                }
            }
            else
            {
                // new belief
                l = l.Copy();
                BelEntry entry = ProvideBelEntry(l);
                entry.Add(l, addInEnd);

                // Add it to percepts list
                if (l.HasAnnot(TPercept))
                {
                    percepts.Add(l);
                }

                size++;
                return(true);
            }
            return(false);
        }