private void PrintKnowledge(IKnowledge knowledge, Func <bool, bool> filter) { Log("Knowledge: "); foreach (var state in GetFullState()) { Log("\t" + PrintState(state) + ":"); var fun = knowledge.Get(state); if (GetFullState().Any(s => filter(fun(s)))) { if (GetFullState().All(s => fun(s))) { Log("\t\t... -> True"); } else if (GetFullState().All(s => fun(s) == false)) { Log("\t\t... -> False"); } else { foreach (var state2 in GetFullState()) { var result = fun(state2); if (filter(result)) { Log("\t\t" + PrintState(state2) + " -> " + (result ? "True" : "False")); } } } } } }
private void SurfaceVerify(IKnowledge source, IKnowledge obj, out string msg, out object output) { msg = AGTutorMessage.VerifyWrong; output = null; var eqGoalExpr = obj as AGPropertyExpr; if (eqGoalExpr != null) { GoalVerify(source, eqGoalExpr.Goal, out msg, out output); } var shapeExpr = obj as AGShapeExpr; if (shapeExpr != null) { ShapeVerify(source, shapeExpr.ShapeSymbol, out msg, out output); } /* var eqGoalLst = obj as List<object>; * if (eqGoalLst != null) * { * foreach (var tempObj in eqGoalLst) * { * var gGoal = tempObj as AG; * bool verified = GoalVerify(obj, gGoal, out msg, out output); * if (verified) return; * } * }*/ }
public BehaviorGraphNode UpdateSolvingCache(IKnowledge userKnowledge, bool isAdd = true) { var node = SearchInnerLoopNode(userKnowledge); if (node == null) { return(null); } Debug.Assert(node.State.Level == BehaviorLevel.Inner); /* if (node.OutEdges.Count != 0) return node; * Debug.Assert(node.OutEdges.Count == 0);*/ bool contained = SolvingCache.ContainsKey(node); //Debug.Assert(contained); if (!contained) { return(node); } if (isAdd) { SolvingCache[node] = true; } else { SolvingCache[node] = false; } return(node); }
private string ExamFailsObserver(IKnowledge knowledge) { var result = new StringBuilder(); this.trainers.Where(t => t.TrainerType == TrainerType.PreviousYears).ToList().ForEach(t => result.AppendLine(((IHelper)t).HelpMe(knowledge))); return(result.ToString()); }
public void Initialize() { MainOrganization.Models.SetOn(1); _knowledge = new Knowledge(MainOrganization.ArtifactNetwork, MainOrganization.Models, "1", (byte)_floats1.Length); _database = new Database(MainOrganization.ArtifactNetwork, MainOrganization.Models, _communication, Database.ClassId); _database.CognitiveArchitecture.InternalCharacteristics.TimeToLive = 10; _bits1 = new Bits(_floats1, 0); }
public Student(string name, IPet pet, StudentType studentType, OtherCompetence otherCompetance, IKnowledge knowledge) : base(name, Student.StudentBaseHp) { this.studentType = studentType; this.otherCompetence = otherCompetance; this.Knowledge = knowledge; this.pet = pet; this.IsAlive = true; }
public void AddDayKnowledge(int day, IKnowledge knowledge) { if (KnowledgeDict.ContainsKey(day)) { var prevKnowlede = KnowledgeDict[day]; KnowledgeDict[day] = new Combine2Knowledge(prevKnowlede, knowledge); return; } KnowledgeDict.Add(day, knowledge); }
public Belief(GraphMetaNetwork metaNetwork, IKnowledge knowledge, byte length, RandomGenerator model, BeliefWeightLevel beliefWeightLevel) : this(metaNetwork, length, model, beliefWeightLevel) { if (knowledge == null) { throw new ArgumentNullException(nameof(knowledge)); } Name = knowledge.Name; KnowledgeId = knowledge.EntityId; }
protected virtual string OnExamFail(IKnowledge knowledg) { Func <IKnowledge, string> handler = CantPassExam; if (handler != null) { return(handler(knowledg)); } return(string.Empty); }
public void Verify(IKnowledge source, IKnowledge obj, out string msg, out object output) { output = null; object outobj; SurfaceVerify(source, obj, out msg, out outobj); //Equation Eval Trace if (msg != null && msg.Equals(AGTutorMessage.VerifyCorrect)) { return; } DeepVerify(source, obj, out msg, out outobj); //Relation Eval }
// Construct a new knowledge base with a provided path to the installation folder. public GameKB(string installPath, IKnowledge gameKnowledge) { if (!Directory.Exists(installPath)) { throw new ArgumentException("LibraryPath parameter must point to a valid path! " + installPath); } _installpath = Path.GetFullPath(installPath); _gameKnowledge = gameKnowledge ?? throw new ArgumentNullException("GameKnowledge parameter cannot be null!"); ConstructLibraryPaths(); }
public static GameKB CreateFromLibraryPath(IKnowledge gameKnowledge, string libPath) { string libPathPart = gameKnowledge.LibraryRelativePath; if (!libPath.EndsWith(libPathPart)) { throw new InvalidOperationException("The provided library path does not match the provided game knowledge base!"); } // The install path is the relative library path removed from the full lib path. string installPath = libPath.Remove(libPath.Length - libPathPart.Length); return(new GameKB(installPath, gameKnowledge)); }
public void Select(IKnowledge entity) { var path = _semanticNetworkNode.Find(entity).OfType <object>().ToList(); if (path.Count > 0) { this.ExecuteWithItem(path, item => { item.IsSelected = true; item.BringIntoView(); }); } }
private bool GoalVerify(IKnowledge obj, EqGoal eqGoal, out string msg, out object output) { msg = AGTutorMessage.VerifyWrong; output = null; List <Tuple <object, object> > trace = null; var agPropExpr = new AGPropertyExpr(obj.Expr, eqGoal); agPropExpr.IsSelected = true; agPropExpr.GenerateSolvingTrace(); trace = agPropExpr.AutoTrace; BehaviorGraphNode node; if (trace == null || trace.Count == 0) { node = UserGraph.UpdateSolvingCache(agPropExpr); //node = UserGraph.SearchInnerLoopNode(eqGoal); if (node == null) { return(false); } } if (trace != null) { bool matchResult = UserGraph.Match(trace); if (!matchResult) { return(false); } //insert nodes UserGraph.Insert(trace); CurrentStateNode = UserGraph.SearchInnerLoopNode(obj); //update _currentStateNode; } else { CurrentStateNode = UserGraph.SearchInnerLoopNode(eqGoal); } /* var nextTuple1 = UserGraph.SearchNextInnerLoopNode(CurrentStateNode); * if (nextTuple1 == null) // query-end * { * msg = AGTutorMessage.SolvedProblem; * return true; * } */ msg = AGTutorMessage.VerifyCorrect; return(true); }
private void DeepVerify(IKnowledge source, IKnowledge obj, out string msg, out object output) { msg = AGTutorMessage.VerifyWrong; object result; var shapeExpr = obj as AGShapeExpr; if (shapeExpr != null) { result = Reasoner.Instance.RelationValidate(shapeExpr.ShapeSymbol, out output); } else { result = Reasoner.Instance.RelationValidate(obj.Expr, out output); } if (result == null) { return; } var inputApproximateMatched = result as bool?; if (inputApproximateMatched != null) { if (inputApproximateMatched.Value) { msg = AGTutorMessage.VerifyCorrect; } return; } var trace = result as List <Tuple <object, object> >; if (trace != null) { bool matchResult = UserGraph.Match(trace); //match and update if (matchResult) { //insert nodes UserGraph.Insert(trace); CurrentStateNode = UserGraph.SearchInnerLoopNode(source); //update _currentStateNode; //Debug.Assert(_currentStateNode != null); msg = AGTutorMessage.VerifyCorrect; } } }
private void LoadObjectGraph() { Debug.Assert(QueriedKnowledge != null); IKnowledge selectRenderAnswer = QueriedKnowledge.FindSelectedKnowledge(); if (selectRenderAnswer == null) { return; } selectRenderAnswer.GenerateSolvingTrace(); //if (selectRenderAnswer.AutoTrace == null) return; var behaviorGraph = new BehaviorGraph(); if (selectRenderAnswer.AutoTrace != null) { behaviorGraph.Insert(selectRenderAnswer.AutoTrace); } ObjectGraph = behaviorGraph; }
public async Task <(string?, IKnowledge)> Reply(IKnowledge knowledge, MuteCommandContext message) { if (IsComplete) { return(null, knowledge); } // Get or construct an eliza engine from the knowledge chain // If the previous engine has finished a new one will be constructed ElizaEngineAdapter engine; (engine, knowledge) = knowledge.GetOrAdd(e => !e.Eliza.Finished, k => new ElizaEngineAdapter(k, _script)); // Get a response from eliza and pass it back var response = engine.Eliza.ProcessInput(message); IsComplete = engine.Eliza.Finished; return(response, knowledge); }
private bool ShapeVerify(IKnowledge obj, ShapeSymbol shape, out string msg, out object output) { msg = AGTutorMessage.VerifyWrong; output = null; List <Tuple <object, object> > trace = null; var agShapeExpr = new AGShapeExpr(obj.Expr, shape); agShapeExpr.IsSelected = true; agShapeExpr.GenerateSolvingTrace(); trace = agShapeExpr.AutoTrace; if (trace == null || trace.Count == 0) { return(false); } /* var lastTuple = trace[trace.Count - 1] as Tuple<object, object>; * var lastLst = lastTuple.Item2 as List<object>; * Debug.Assert(lastLst != null); * Debug.Assert(lastLst.Count != 0); * var lastTs = lastLst[lastLst.Count - 1] as TraceStepExpr;*/ bool matchResult = UserGraph.Match(trace); //match and update if (!matchResult) { return(false); } //insert nodes UserGraph.Insert(trace); CurrentStateNode = UserGraph.SearchInnerLoopNode(obj); //update _currentStateNode; //var nextTuple1 = UserGraph.SearchNextInnerLoopNode(CurrentStateNode); /* if (nextTuple1 == null) // query-end * { * msg = AGTutorMessage.SolvedProblem; * return true; * }*/ msg = AGTutorMessage.VerifyCorrect; return(true); }
public static Belief CreateInstance(GraphMetaNetwork metaNetwork, IKnowledge knowledge, byte length, RandomGenerator model, BeliefWeightLevel beliefWeightLevel) { return(new Belief(metaNetwork, knowledge, length, model, beliefWeightLevel)); }
public override string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return($"{this.ToString()} needs to go for a walk!!! The student time to study has been decreased! You receive {Dog.KnowledgeBoost} knowledge!!"); }
public override string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return $"{this.ToString()} gives the student it's wisdom!!! The student receives {Turtle.KnowledgeBoost} knowledge!"; }
public string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return($"{base.Name} is here to help!The student receives {KnowledgeBoost} knowledge!!"); }
private void AddInsightKeyword(int persIndex, int day, string insightName, IKnowledge knowledge) { PersList[persIndex].AddInsightKnowledge(insightName, day, knowledge); Debug.Log("insight " + PersList[persIndex].Name + " " + insightName); }
private void AddDayKnowledge(int persIndex, int day, IKnowledge knowledge) { PersList[persIndex].AddDayKnowledge(day, knowledge); Debug.Log("addKnowledge " + PersList[persIndex].Name + " day " + day); }
private IKnowledge AddKnowledge(string varName, IKnowledge knowledge) { Debug.Log("knowledge " + varName); KnowledgeDict.Add(varName, knowledge); return(knowledge); }
public override string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return $"{this.ToString()} blessed the student! The student receives {GoldFish.KnowledgeBoost} knowledge!"; }
public string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return $"{base.Name} is here to help!The student receives {KnowledgeBoost} knowledge!!"; }
private string ExamFailsObserver(IKnowledge knowledge) { var result = new StringBuilder(); this.trainers.Where(t => t.TrainerType == TrainerType.PreviousYears).ToList().ForEach(t => result.AppendLine(((IHelper)t).HelpMe(knowledge))); return result.ToString(); }
public static String GetAnchor(this IKnowledge knowledge) { return($"#{knowledge.ID}#"); }
public abstract string HelpMe(IKnowledge knowledge);
public (string, IKnowledge) Reply(IKnowledge knowledge, IUtterance message) { return(_message, null); }
public override string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return($"{this.ToString()} gives the student it's wisdom!!! The student receives {Turtle.KnowledgeBoost} knowledge!"); }
public override string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return($"{this.ToString()} ate the homework!! The student receives {Cat.KnowledgeBoost} knowledge!!"); }
public ImplyStateInfo(IKnowledge a, IKnowledge b, List <State> fullState) { this.A = a; this.B = b; this.FullState = fullState; }
public override string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return $"{this.ToString()} needs to go for a walk!!! The student time to study has been decreased! You receive {Dog.KnowledgeBoost} knowledge!!"; }
public override string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return($"{this.ToString()} blessed the student! The student receives {GoldFish.KnowledgeBoost} knowledge!"); }
protected virtual string OnExamFail(IKnowledge knowledg) { Func<IKnowledge, string> handler = CantPassExam; if (handler != null) { return handler(knowledg); } return string.Empty; }
public override string HelpMe(IKnowledge knowledge) { knowledge.AddKnowledge(KnowledgeBoost); return $"{this.ToString()} ate the homework!! The student receives {Cat.KnowledgeBoost} knowledge!!"; }