예제 #1
0
 public IBaseDistributions GetCognitiveDist()
 {
     if (!isInitialized)
     {
         SharedHelper.LogError("Not initialized.");
     }
     return(cognitiveDist);
 }
예제 #2
0
 public IKorraAISampler GetSampler()
 {
     if (!isInitialized)
     {
         SharedHelper.LogError("Not initialized.");
     }
     return(korraSampler);
 }
예제 #3
0
        //NOT ADAPTED for category and subcategory
        private static void DisableAcion(ref ItemProb <string>[] items, string actionToRemove)
        {
            SharedHelper.Log("Error category PureFact");

            SharedHelper.Log("Action removed: " + actionToRemove.ToString());

            items = items.Where(x => x.Item != actionToRemove).ToArray();
        }
예제 #4
0
 public ModelContext GetContext()
 {
     if (!isInitialized)
     {
         SharedHelper.LogError("Not initialized.");
     }
     return(context);
 }
 public NameDateObjListViewVMdl(NameDateQuick thing)
 {
     Name          = thing.PathName;
     FileOrDirType = SharedHelper.Bool2Int(Directory.Exists(thing.PathName));
     Created       = thing.Created;
     Modified      = thing.Modified;
     Accessed      = thing.Accessed;
 }
예제 #6
0
        private Queue <string> GenerateActions(string[] disabledActions)
        {
            allActions.Clear();

            #region Create a list of all possible actions

            ItemProb <string>[] items =
            {
                ItemProb(ActionsEnum.MakeSuggestion,               ProbVariables.Bot.PrMakeSuggestion[(int)PV.Current]),

                ItemProb(ActionsEnum.AskUncertanFactQuestion,      ProbVariables.Bot.PrAskUncertanFactQuestion),

                ItemProb(ActionsEnum.AskPureFactQuestionAboutUser, ProbVariables.Bot.PrAskPureFactQuestionAboutUser[(int)PV.Current]), //to be packed as one

                ItemProb(ActionsEnum.SharePureFactInfoAboutBot,    ProbVariables.Bot.PrSharePureFactInfoAboutBot[(int)PV.Current]),    //to be packed as one

                ItemProb(ActionsEnum.ChangeVisualAppearance,       SharedHelper.GetProb(ProbVariables.Bot.ChangeVisualAppearance)),

                ItemProb(ActionsEnum.ExpressMentalState,           SharedHelper.GetProb(ProbVariables.Bot.ExpressMentalState)),
            };

            #endregion

            #region Disable actions - NOT ADAPTED for category and subcategory
            if (BotConfigShared.DisableAskQuestions)
            {
                SharedHelper.LogError("NOT ADAPTED for category and subcategory");

                //two actions are removed
                //DisableAcion(ref items, ActionsEnum.AskPureFactQuestionAboutUser);
                //DisableAcion(ref items, ActionsEnum.AskUncertanFactQuestion);
            }

            //foreach (string da in disabledActions)
            //{
            //    DisableAcion(ref items, da);
            //}
            #endregion

            #region Sampling

            var Action = CategoricalF(items).Normalize();

            SharedHelper.Log("Actions Histogram:\r\n" + Action.Histogram());

            var actionDist = Action.ToSampleDist();

            for (var i = 0; i < 100; i++)
            {
                string sample = actionDist.Sample();

                allActions.Enqueue(sample);
            }
            #endregion

            return(allActions);
        }
예제 #7
0
파일: Items.cs 프로젝트: toncho11/KorraAI
        private void LoadAllUncertainFacts()
        {
            #region Uncertain Facts/States about the User

            //3 button answer
            UncertainFacts.AddUncertainFact(new UncertainFact("UserGoodMood", false, "Are you in a good mood?",
                                                              new VarRef <FiniteDist <bool> >(() => ProbVariables.User.InAGoodMood, val => { ProbVariables.User.InAGoodMood = val; }),
                                                              new string[3] {
                "Not so well", "Fine", "Great"
            }, new double[3] {
                0.3, 0.7, 0.85
            },
                                                              UIAnswer.MultiAnswer
                                                              ));

            //3 button answer
            UncertainFacts.AddUncertainFact(new UncertainFact("UserIsTired", false, "Do you feel tired?",
                                                              new VarRef <FiniteDist <bool> >(() => ProbVariables.User.Tired, val => { ProbVariables.User.Tired = val; }),
                                                              new string[3] {
                phrases.No(), "A little bit", phrases.Yes()
            }, new double[3] {
                0.3, 0.6, 0.9
            },
                                                              UIAnswer.MultiAnswer
                                                              ));
            #endregion

            #region Uncertain Facts/Activities about the Bot

            //3 button answer
            UncertainFacts.AddUncertainFact(new UncertainFact("BotAsksIfJokeRateIsOK", true, "Do you like my jokes? Should I tell jokes more often?",
                                                              new VarRef <FiniteDist <bool> >(() => ProbVariables.User.JokeRate, val => { ProbVariables.User.JokeRate = val; }),
                                                              new string[3] {
                "Slow down", "Same rate", "More frequently"
            },
                                                              UIAnswer.MultiAnswer, 0.15
                                                              ));
            //3 button answer
            UncertainFacts.AddUncertainFact(new UncertainFact("BotChangeOutfit", true, "Do you want me to change my outfit more often?",
                                                              new VarRef <FiniteDist <bool> >(() => ProbVariables.Bot.ChangeVisualAppearance, val => { ProbVariables.Bot.ChangeVisualAppearance = val; }),
                                                              new string[3] {
                "Less frequently", "Same rate", "Change more"
            },
                                                              UIAnswer.MultiAnswer, 0.03
                                                              ));
            #endregion

            #region debug
            foreach (var item in UncertainFacts.GetList())
            {
                if (item.ProbabilitiesForEachPossibleAnswer.Sum() == 0)
                {
                    SharedHelper.LogError("Probabilities are all 0!!! for " + item.Name);
                }
            }
            #endregion
        }
예제 #8
0
 public static void PrintSuggestionsProbabilities()
 {
     SharedHelper.Log("SUGGESTIONS Probabilities: \r\n"
                      + "Suggest Go out: " + SharedHelper.GetProb(Bot.SuggestGoOut).Value.ToString() + "\r\n"
                      + "Tell Joke: " + SharedHelper.GetProb(Bot.TellJoke).Value.ToString() + "\r\n"
                      + "Suggest To WatchMovie: " + SharedHelper.GetProb(Bot.SuggestToWatchMovie).Value.ToString() + "\r\n"
                      + "Tell Weather Forecast: " + SharedHelper.GetProb(Bot.TellWeatherForecast).Value.ToString() + "\r\n"                          //not used
                      + "Suggest Listen To Song: " + Bot.PrSuggestListenToSong.Value.ToString() + "\r\n"
                      );
 }
예제 #9
0
 public bool IsClusterGroup()
 {
     using (IAmClusterGroup amClusterGroup = this.OwningCluster.FindCoreClusterGroup())
     {
         if (amClusterGroup != null && SharedHelper.StringIEquals(amClusterGroup.Name, this.Name))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #10
0
 private bool IsNodeMemberOfDag(AmServerName node, IADDatabaseAvailabilityGroup dag)
 {
     foreach (ADObjectId adobjectId in dag.Servers)
     {
         if (SharedHelper.StringIEquals(node.NetbiosName, adobjectId.Name))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #11
0
 public ClusterNode FindNode(string nodeName)
 {
     foreach (ClusterNode clusterNode in this.Nodes)
     {
         if (SharedHelper.StringIEquals(nodeName, clusterNode.Name.NetbiosName))
         {
             return(clusterNode);
         }
     }
     return(null);
 }
예제 #12
0
 public static void SetProb(string Name, double newProb)
 {
     foreach (var q in list)
     {
         if (q.Name == Name)
         {
             SharedHelper.Log("'" + Name + "' prob variable has been updated from " + q.ProbVariable.RefValue.ProbOf(e => e == true).Value + " to " + newProb);
             q.ProbVariable.RefValue = BernoulliF(Prob(newProb));
         }
     }
 }
예제 #13
0
 private bool DoesClusterNetworkContainNode(ClusterNetwork clusNet, string nodeName)
 {
     foreach (ClusterNic clusterNic in clusNet.Nics)
     {
         if (SharedHelper.StringIEquals(nodeName, clusterNic.NodeName))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #14
0
 public static void PrintActionsProbabilities()
 {
     SharedHelper.Log("ACTIONS Probabilities: \r\n"
                      + "PrMakeSuggestion: " + Bot.PrMakeSuggestion[(int)PV.Current].Value.ToString() + "\r\n"
                      + "PrAskUncertanFactQuestion: " + Bot.PrAskUncertanFactQuestion.Value.ToString() + "\r\n"
                      + "PrAskPureFactQuestionAboutUser: "******"\r\n"
                      + "PrSharePureFactInfoAboutBot: " + Bot.PrSharePureFactInfoAboutBot[(int)PV.Current].Value.ToString() + "\r\n"
                      + "PrChangeVisualAppearance: " + SharedHelper.GetProb(Bot.ChangeVisualAppearance).Value.ToString() + "\r\n"
                      + "PrExpressMentalState: " + SharedHelper.GetProb(Bot.ExpressMentalState).Value.ToString() + "\r\n"
                      );
 }
예제 #15
0
 internal static ADObjectId FindServerAdObjectIdInStampGroup(StampGroup stampGroup, AmServerName serverName)
 {
     foreach (ADObjectId adobjectId in stampGroup.Servers)
     {
         if (SharedHelper.StringIEquals(adobjectId.Name, serverName.NetbiosName))
         {
             return(adobjectId);
         }
     }
     return(null);
 }
예제 #16
0
 public static string FirstCharToUpper(string input)
 {
     if (String.IsNullOrEmpty(input))
     {
         SharedHelper.LogError("FirstCharToUpper: string is null or empty");
         return("");
     }
     else
     {
         return(input.First().ToString().ToUpper() + input.Substring(1));
     }
 }
예제 #17
0
        public static void CompileAndRegisterClientScript(this Page p, Assembly e)
        {
            lock (Token)
            {
                jsc.server.WebTools.CompileClientScript(e);

                foreach (var v in SharedHelper.ModulesOf(e))
                {
                    p.ClientScript.RegisterClientScriptInclude(v, string.Format("{0}.js", new System.IO.FileInfo(v).Name));
                }
            }
        }
예제 #18
0
        internal static IEnumerable <AmClusterResource> GetIpResourcesFromNetName(AmClusterGroup resGroup, AmClusterResource netName)
        {
            if (!SharedHelper.StringIEquals(netName.GetTypeName(), "Network Name"))
            {
                throw new ArgumentException("GetIpResourceFromNetName() needs a NetName resource.");
            }
            List <AmClusterResource> list = new List <AmClusterResource>(8);

            list.AddRange(resGroup.EnumerateResourcesOfType("IP Address"));
            list.AddRange(resGroup.EnumerateResourcesOfType("IPv6 Address"));
            return(list);
        }
 // Token: 0x06000111 RID: 273 RVA: 0x00007432 File Offset: 0x00005632
 private ServiceStartMode MapStartMode(string mode)
 {
     if (SharedHelper.StringIEquals(mode, "Manual"))
     {
         return(ServiceStartMode.Manual);
     }
     if (SharedHelper.StringIEquals(mode, "Disabled"))
     {
         return(ServiceStartMode.Disabled);
     }
     return(ServiceStartMode.Automatic);
 }
        // Token: 0x06000220 RID: 544 RVA: 0x00009E4C File Offset: 0x0000804C
        internal static T GetBestEffort <T>(string key, AmClusterRegkeyHandle handle, out bool doesKeyExist, out Exception ex)
        {
            T    result          = default(T);
            bool doesKeyExistTmp = false;

            ex = SharedHelper.RunClusterOperation(delegate
            {
                result = AmClusterRegProperty.Get <T>(key, handle, out doesKeyExistTmp);
            });
            doesKeyExist = doesKeyExistTmp;
            return(result);
        }
예제 #21
0
        public PhrasesEN(ItemManager[] managers)
        {
            #region Get Fact Manager
            PureFacts pfManager = (PureFacts)managers.SingleOrDefault(x => x is PureFacts);
            if (pfManager == null)
            {
                SharedHelper.LogError("No item managers in PhrasesEN.");
                return;
            }
            #endregion

            this.factsManager = pfManager;
        }
 // Token: 0x06001986 RID: 6534 RVA: 0x0006AA54 File Offset: 0x00068C54
 protected SeederInstanceBase(RpcSeederArgs rpcArgs, ConfigurationArgs configArgs)
 {
     this.SeederArgs     = rpcArgs;
     this.ConfigArgs     = configArgs;
     this.m_seederStatus = new RpcSeederStatus();
     ExTraceGlobals.SeederServerTracer.TraceDebug <string, string>((long)this.GetHashCode(), "SeederInstanceBase constructed with the following arguments: {0}; {1}", this.SeederArgs.ToString(), this.ConfigArgs.ToString());
     this.InitializePerfCounters();
     this.m_completedTimeUtc = DateTime.MaxValue;
     if (!string.IsNullOrEmpty(rpcArgs.SourceMachineName) && !SharedHelper.StringIEquals(rpcArgs.SourceMachineName, configArgs.SourceMachine))
     {
         this.m_fPassiveSeeding = true;
     }
 }
예제 #23
0
        public Item GetByName(string name)
        {
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i].Name == name)
                {
                    return(items[i]);
                }
            }

            SharedHelper.LogError("GetByName not found: " + name + " " + example.Category);
            return(null);
        }
예제 #24
0
        public void BeforeAnalyseUserResponse(PureFact pfact)
        {
            //Here you change the responses that were encoded when creating this PureFact, even replace the function responsible for the answers.
            //This can be useful if you have new information about the user and its environment and this could not be encoded in advance.

            bool   isAnswerd     = pfact.IsAnswered;
            string responseValue = pfact.Value;

            //if (context.Phrases.IsYes(responseValue))
            //{
            //    fact.StatementOnPositiveResponse = "";
            //}
            SharedHelper.Log("Pure fact updated: " + pfact.Name);
        }
예제 #25
0
        public static bool IsAutoActivationAllowed(IADServer sourceServer, IADServer targetServer, out LocalizedString error)
        {
            string name  = sourceServer.Name;
            string name2 = targetServer.Name;

            error = LocalizedString.Empty;
            if (SharedHelper.StringIEquals(name, name2))
            {
                AmTrace.Debug("IsAutoActivationAllowed: Skipping check since source == target. TargetServer: {0}", new object[]
                {
                    name2
                });
                return(true);
            }
            switch (targetServer.DatabaseCopyAutoActivationPolicy)
            {
            case DatabaseCopyAutoActivationPolicyType.Unrestricted:
                return(true);

            case DatabaseCopyAutoActivationPolicyType.IntrasiteOnly:
                if (!targetServer.ServerSite.Equals(sourceServer.ServerSite))
                {
                    AmTrace.Debug("IsAutoActivationAllowed: Rejecting server '{0}' (Site={1}) because it is in a different site from source server '{2}' (Site={2}). ", new object[]
                    {
                        name2,
                        targetServer.ServerSite.Name,
                        name,
                        sourceServer.ServerSite.Name
                    });
                    error = ReplayStrings.AmBcsTargetServerActivationIntraSite(targetServer.Fqdn, sourceServer.Fqdn, targetServer.ServerSite.Name, sourceServer.ServerSite.Name);
                    return(false);
                }
                return(true);

            case DatabaseCopyAutoActivationPolicyType.Blocked:
                AmTrace.Debug("IsAutoActivationAllowed: Rejecting server '{0}' because it is activation policy Blocked.", new object[]
                {
                    name2
                });
                error = ReplayStrings.AmBcsTargetServerActivationBlocked(targetServer.Fqdn);
                return(false);

            default:
                DiagCore.RetailAssert(false, "Unhandled case for DatabaseCopyAutoActivationPolicyType: {0}", new object[]
                {
                    targetServer.DatabaseCopyAutoActivationPolicy
                });
                return(false);
            }
        }
예제 #26
0
 /// <summary>
 /// Set File Time
 /// </summary>
 internal void SetTimeDateEachFile(string directoryPath, DateTime fileDateTime)
 {
     try
     {
         string[] subFiles = Directory.GetFiles(directoryPath);
         Array.Sort(subFiles, SharedHelper.explorerStringComparer());
         foreach (string filename in subFiles)
         {
             AddONEFiletoConfirmList(filename, fileDateTime, false);
         }
     } //catch for GetFiles
     catch (UnauthorizedAccessException)
     { }
 }
예제 #27
0
        public IEnumerable <AmClusterResource> EnumerateResourcesOfType(string resourceType)
        {
            IEnumerable <AmClusterResource> enumerable = this.EnumerateResources();
            List <AmClusterResource>        list       = (from resource in enumerable
                                                          where SharedHelper.StringIEquals(resource.GetTypeName(), resourceType)
                                                          select resource).ToList <AmClusterResource>();
            IEnumerable <AmClusterResource> enumerable2 = enumerable.Except(list);

            foreach (AmClusterResource amClusterResource in enumerable2)
            {
                amClusterResource.Dispose();
            }
            return(list);
        }
예제 #28
0
 // Token: 0x06000F2A RID: 3882 RVA: 0x0004059C File Offset: 0x0003E79C
 private bool IsPropertyChanged <T>(T oldValue, T newValue)
 {
     if (oldValue is string)
     {
         return(!SharedHelper.StringIEquals(oldValue as string, newValue as string));
     }
     if (oldValue is List <string> )
     {
         List <string> first  = oldValue as List <string>;
         List <string> second = newValue as List <string>;
         return(!first.SequenceEqual(second, StringComparer.OrdinalIgnoreCase));
     }
     return(!oldValue.Equals(newValue));
 }
예제 #29
0
        public string SurpriseVideoGames(int surprise, bool LikesGamesAskedFirst)
        {
            if (surprise == 1)
            {
                return("I had the impression, you will like video games.");
            }
            else if (surprise == 2)
            {
                //2
                //LVG No
                //Present Yes
                //inference on: LVG
                if (LikesGamesAskedFirst)
                {
                    return("But you still do not like computer games.");
                }
                //Present Yes
                //LVG No
                else
                {
                    return("Hmm, I thought you would like video games if you approve a video game as a present.");
                }
            }
            else if (surprise == 3)
            {
                //3
                //LVG Yes
                //Present No
                //inference on: present

                if (LikesGamesAskedFirst)
                {
                    return("Strange. I though you will like a video game as a present.");
                }

                //Present No
                //LVG Yes
                //inference on: present
                else
                {
                    return("Hmm, But you still think a video game is not a good present.");
                }
            }
            else
            {
                SharedHelper.LogError("Could not generate appropriate video game text to express surprise.");
                return("");
            }
        }
예제 #30
0
        public bool Process(bool isPureFactUpdated, TimeSpan timeSinceStart, IKorraAIModel model)
        {
            //SharedHelper.LogWarning("Inside music trigger");

            // We increase the music suggestions after a fixed amount of time
            if (timeSinceStart.TotalMinutes > MinutesIncreaseMusic) // && !IncreaseDistributionSuggestMusicDone)
            {
                executedCount = executedCount + 1;

                ProbVariables.Bot.PrSuggestListenToSong = Prob(0.35);
                SharedHelper.LogWarning("PrSuggestListenToSong updated to: " + ProbVariables.Bot.PrSuggestListenToSong.Value);
            }

            return(false); //no re-sampling
        }