Example #1
0
        public KnowledgeBaseEntry(KnowledgeBaseEntry know1, KnowledgeBaseEntry know2)
        {
            clauses = new Clause[4];
            for (int i = 0; i < 4; i++)
            {
                if (know1[i] == Clause.Both)
                {
                    clauses[i] = Clause.Both;
                }
                else if (know1[i] == Clause.False && know2[i] == Clause.True)
                {
                    clauses[i] = Clause.Both;
                }
                else if (know1[i] == Clause.True && know2[i] == Clause.False)
                {
                    clauses[i] = Clause.Both;
                }
                else if (know2[i] == Clause.Both)
                {
                    clauses[i] = Clause.Both;
                }
                else if (know2[i] == Clause.False || know1[i] == Clause.False)
                {
                    clauses[i] = Clause.False;
                }
                else if (know2[i] == Clause.True || know1[i] == Clause.True)
                {
                    clauses[i] = Clause.True;
                }
            }

            //this.h = know1.h++;
        }
Example #2
0
        public static Path solver(Collection <KnowledgeBaseEntry> knowledge, KnowledgeBaseEntry start)
        {
            Path startpath = new Path(start);

            Search search = new Search(new Astar());

            search.addToFrontier(startpath);
            while (!search.frontierIsEmpty())
            {
                Path current = search.getFromFrontier();
                if (current.current.isgoal())
                {
                    return(current);
                }
                foreach (KnowledgeBaseEntry knowentry in knowledge)
                {
                    KnowledgeBaseEntry newKnow = new KnowledgeBaseEntry(current.current, knowentry);
                    Path next = new Path(current, newKnow, knowentry);
                    if (!search.inExplored(next.current))
                    {
                        search.addToFrontier(next);
                    }
                }
            }
            System.Console.WriteLine("haps");
            return(null);
        }
Example #3
0
 public Path(Path parent, KnowledgeBaseEntry current, KnowledgeBaseEntry combiner)
 {
     id            = _id++;
     this.parent   = parent;
     this.current  = current;
     this.combiner = combiner;
     g             = this.parent.g + 1;
 }
Example #4
0
 public Path(KnowledgeBaseEntry current)
 {
     id           = _id++;
     g            = 0;
     this.current = current;
 }
Example #5
0
 public bool inExplored(KnowledgeBaseEntry node)
 {
     return(explored.Contains(node));
 }