コード例 #1
0
        //public static void SetAsPlanned(string name)
        //{
        //    for (int i = 0; i < list.Count; i++)
        //    {
        //        if (list[i].Name == name)
        //        {
        //            //UnityEngine.Debug.Log("Set to used true: " + list[i].Name);
        //            list[i].IsPlanned = true;
        //            return;
        //        }
        //    }

        //    SharedHelper.LogError("Pure Fact Name not found in SetAsUsed!");
        //}

        public void SetValue(string Name, string Value)
        {
            foreach (var item in items)
            {
                PureFact f = (PureFact)item;
                if (f.Name == Name)
                {
                    SharedHelper.LogWarning("Set as answered: " + f.Name + " with value: '" + Value + "'");
                    f.Value      = Value;
                    f.IsAnswered = true;

                    return;
                }
            }
        }
コード例 #2
0
        //public static PureFact GetByName(string name)
        //{
        //    foreach (var q in list)
        //    {
        //        if (q.Name == name)
        //        {
        //            return q;
        //        }
        //    }

        //    SharedHelper.LogError("GetFacfByName: Pure Fact Name '" + name + "'not found");

        //    return null;
        //}

        //public static void RemovePlannedFlagForAllPureFacts()
        //{
        //    for (int i = 0; i < list.Count; i++)
        //    {
        //        list[i].IsPlanned = false;
        //    }
        //}

        /// <summary>
        /// Used to delete answers that are invalid after validation: ex. age is not a valid number
        /// </summary>
        public void DropAnswer(string Name)
        {
            foreach (var item in items)
            {
                PureFact f = (PureFact)item;
                if (f.Name == Name)
                {
                    SharedHelper.LogWarning("DropAnswer: " + f.Name);
                    f.Value      = "";
                    f.IsAnswered = false;
                    f.IsUsed     = false;
                    return;
                }
            }
        }
コード例 #3
0
        public string GetValueByName(string name)
        {
            foreach (var item in items)
            {
                PureFact f = (PureFact)item;
                if (f.Name == name)
                {
                    return(f.Value);
                }
            }

            SharedHelper.LogError("GetValueByName: Pure Fact Name '" + name + "'not found");

            return("");
        }
コード例 #4
0
        public PureFact GetPureFactAbouUser()
        {
            var q = (from item in items
                     let pf = (PureFact)item
                              where pf.Type == PureFactType.AboutUser && pf.IsPlanned == false && pf.IsUsed == false
                              select pf).ToArray();

            if (q.Length > 0)
            {
                string[] group1 = { "UserName" };                                                                      //conversation should start with these
                string[] group2 = { "UserAge", "UserSex" };                                                            //conversation should continue with these
                string[] group3 = { "UserLocation", "UserNationality", "UserIsMarried", "UserHasKids", "UserHasJob" }; //and then with these

                List <ItemProb <string> > itemProbs = new List <ItemProb <string> >();

                //assign probabilities
                foreach (PureFact fact in q)
                {
                    if (group1.Contains(fact.Name)) //GROUP 1
                    {
                        itemProbs.Add(new ItemProb <string>(fact.Name, Prob(0.99)));
                        break; //add only 1 item
                    }
                    else
                    if (group2.Contains(fact.Name)) //GROUP 2
                    {
                        itemProbs.Add(new ItemProb <string>(fact.Name, Prob(0.8)));
                    }
                    else

                    if (group3.Contains(fact.Name)) //GROUP 3
                    {
                        itemProbs.Add(new ItemProb <string>(fact.Name, Prob(0.20)));
                    }

                    else
                    {
                        itemProbs.Add(new ItemProb <string>(fact.Name, Prob(0.06))); //all the other pure facts not in group1 and group 2
                    }
                }

                var pureFactDistF = CategoricalF(itemProbs.ToArray()).Normalize();

                //SharedHelper.Log("Pure fact questions to ask the user histogram:\r\n" + pureFactDistF.Histogram());

                var pureFactDist = pureFactDistF.ToSampleDist();

                var selectionName = pureFactDist.Sample();

                PureFact selectedPureFact = (PureFact)GetByName(selectionName);

                //SharedHelper.Log("GetPureFactAbouUser: selectionName " + selectionName);

                return(selectedPureFact);
            }
            else
            {
                SharedHelper.LogError("GetPureFactAbouUser could not supply a pure fact about the user.");
                return(null);
            }
        }
コード例 #5
0
        //static List<PureFact> list = new List<PureFact>();

        public PureFacts(PureFact fact) : base(fact)
        {
        }