public IBaseDistributions GetCognitiveDist() { if (!isInitialized) { SharedHelper.LogError("Not initialized."); } return(cognitiveDist); }
public IKorraAISampler GetSampler() { if (!isInitialized) { SharedHelper.LogError("Not initialized."); } return(korraSampler); }
//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(); }
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; }
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); }
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 }
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" ); }
public bool IsClusterGroup() { using (IAmClusterGroup amClusterGroup = this.OwningCluster.FindCoreClusterGroup()) { if (amClusterGroup != null && SharedHelper.StringIEquals(amClusterGroup.Name, this.Name)) { return(true); } } return(false); }
private bool IsNodeMemberOfDag(AmServerName node, IADDatabaseAvailabilityGroup dag) { foreach (ADObjectId adobjectId in dag.Servers) { if (SharedHelper.StringIEquals(node.NetbiosName, adobjectId.Name)) { return(true); } } return(false); }
public ClusterNode FindNode(string nodeName) { foreach (ClusterNode clusterNode in this.Nodes) { if (SharedHelper.StringIEquals(nodeName, clusterNode.Name.NetbiosName)) { return(clusterNode); } } return(null); }
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)); } } }
private bool DoesClusterNetworkContainNode(ClusterNetwork clusNet, string nodeName) { foreach (ClusterNic clusterNic in clusNet.Nics) { if (SharedHelper.StringIEquals(nodeName, clusterNic.NodeName)) { return(true); } } return(false); }
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" ); }
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); }
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)); } }
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)); } } }
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); }
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; } }
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); }
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); }
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); } }
/// <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) { } }
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); }
// 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)); }
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(""); } }
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 }