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 Item[] GetAll() { List <Item> items = new List <Item>(); items.AddRange(UncertainFacts.GetList()); items.AddRange(JokesProvider.GetAll()); foreach (var manager in providers) { int oldCount = items.Count; items.AddRange(manager.GetAll()); if (items.Count == oldCount) { SharedHelper.LogError("No items were loaded for: " + manager.ToString()); } } return(items.ToArray()); }
public void LoadAll(ItemManager[] providers) { this.providers = providers; LoadAllPureFacts(); LoadAllUncertainFacts(); LoadAllJokes(); //PureFacts must be already loaded because some PureFacts are used as jokes LoadAllSongs(); LoadSports(); LoadMovies(); int count = UncertainFacts.GetList().Count + JokesProvider.GetAll().Count(); foreach (var manager in providers) { count += manager.Count(); } SharedHelper.Log("All items loaded: " + count + " " + BotConfigShared.Language); }
public void Init(DateTime?LastSessionDateTime) { #region Configure character Personality.UseMildOffensiveJokes = true; Personality.UseMildSexualThemes = false; Personality.UseRomanticReferences = false; #endregion context = new ModelContext(); //Select data providers itemProviders = new ItemManager[] { new SportsProvider(new Sport("")), new PureFacts(new PureFact()), new MoviesProvider(new Movie("", false, false)), new SongsProvider(new Song("", "")) }; if (BotConfigShared.Language == Lang.EN) { context.BasePhrases = new PhrasesEN(itemProviders); context.Items = new ItemsEN((PhrasesEN)context.BasePhrases); context.SpeechAdaptation = new SpeechAdaptationEN((IJoiPhrases)context.BasePhrases); } else if (BotConfigShared.Language == Lang.FR) { //context.BasePhrases = new PhrasesFR(itemProviders); //context.Items = new ItemsFR(); //context.SpeechAdaptation = new SpeechAdaptationFR((IJoiPhrases)context.BasePhrases); } else { SharedHelper.LogError("Language pack not found."); } context.Items.LoadAll(itemProviders); foreach (var provider in itemProviders) { if (provider.Count() == 0) { SharedHelper.LogError("Detected an item manager without items."); } } //ReuseInteractions(PersistentData.GetLastSession()); //some already used interactions are re-enabled cognitiveDist = new JoiDistributions(); ModelTriggers = new IModelTrigger[] { new MusicModelUpdateTrigger(MinutesIncreaseMusic), new MoviesModelUpdateTrigger(), new VideoGameSurpriseTrigger((IJoiPhrases)context.BasePhrases), }; korraSampler = new JoiSampler(); korraSampler.Init(context, AdjustProbVariablesDuringPlanning, itemProviders); //Delayed. These Uncertain Facts questions are automatically re-enabled after a certain period of time UncertainFacts.SetAsUsed("UserIsTired"); UncertainFacts.SetAsUsed("UserGoodMood"); UncertainFacts.SetAsUsed("BotAsksIfJokeRateIsOK"); UncertainFacts.SetAsUsed("BotChangeOutfit"); //cache values cognitiveDist.NextSmilePauseTime(); cognitiveDist.NextTimeDurationEyesStayFocusedOnCameraAfterStartedTalking(); cognitiveDist.GetNextInteactionPause(false); cognitiveDist.NextQuestionTimeout(); isInitialized = true; ContextLoaded(this, EventArgs.Empty); }