public AddOrEditAttributionRuleForm(SocialImportanceAsset asset, AttributionRuleDTO dto) { InitializeComponent(); this.asset = asset; this.dto = dto; this.UpdatedGuid = Guid.Empty; //Validators _targetVariableBox.AllowUniversal = false; _targetVariableBox.AllowNil = false; _targetVariableBox.AllowComposedName = false; _targetVariableBox.AllowLiteral = false; _valueFieldBox.OnlyIntOrVariable = true; _ruleDescriptionTextBox.Text = dto.Description; _valueFieldBox.Value = dto.Value; _targetVariableBox.Value = (Name)dto.Target; if (this.dto.Id != Guid.Empty) { this.Text = "Edit SI Attribution Rule"; button1.Text = "Update"; } }
/// <summary> /// Loads the associated assets from the defined sources and prevents further authoring of the asset /// </summary> public void LoadAssociatedAssets() { var charName = CharacterName.ToString(); EmotionalAppraisalAsset ea = Loader(m_emotionalAppraisalAssetSource, () => new EmotionalAppraisalAsset()); EmotionalDecisionMakingAsset edm = Loader(m_emotionalDecisionMakingAssetSource, () => new EmotionalDecisionMakingAsset()); SocialImportanceAsset si = Loader(m_socialImportanceAssetSource, () => new SocialImportanceAsset()); CommeillFautAsset cfa = Loader(m_commeillFautAssetSource, () => new CommeillFautAsset()); m_emotionalAppraisalAsset = ea; m_emotionalDecisionMakingAsset = edm; m_socialImportanceAsset = si; m_commeillFautAsset = cfa; MCTSAsset mcts = new MCTSAsset(); //Dynamic properties BindToRegistry(m_kb); edm.RegisterKnowledgeBase(m_kb); si.RegisterKnowledgeBase(m_kb); cfa.RegisterKnowledgeBase(m_kb); mcts.RegisterKnowledgeBase(m_kb); m_allowAuthoring = false; }
public MainForm() { InitializeComponent(); _storage = new AssetStorage(); _loadedAsset = SocialImportanceAsset.CreateInstance(_storage); OnAssetDataLoaded(); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { _currentPath = null; _storage = new AssetStorage(); _loadedAsset = SocialImportanceAsset.CreateInstance(_storage); OnAssetDataLoaded(); }
internal ConfigStore(Platform platform = Platform.Windows) { Platform = platform; ConfigValues = new Dictionary <ConfigKey, float>(); var configText = Templates.ResourceManager.GetString("config"); var contractResolver = new PrivatePropertyResolver(); var settings = new JsonSerializerSettings { ContractResolver = contractResolver }; ConfigValues = JsonConvert.DeserializeObject <Dictionary <ConfigKey, float> >(configText, settings); foreach (var key in (ConfigKey[])Enum.GetValues(typeof(ConfigKey))) { if (!ConfigValues.ContainsKey(key)) { throw new Exception("Config key " + key + " not included in config!"); } } BoatTypes = new Dictionary <string, List <Position> >(); var boatText = Templates.ResourceManager.GetString("boat_config"); BoatTypes = JsonConvert.DeserializeObject <Dictionary <string, List <Position> > >(boatText); GameConfig = new GameConfig().GetConfig(); NameConfig = new NameConfig().GetConfig(); Avatar.Config = new AvatarGeneratorConfig().GetConfig(); AssetManager.Instance.Bridge = new TemplateBridge(); RolePlayCharacter = RolePlayCharacterAsset.LoadFromFile("template_rpc"); EmotionalAppraisal = EmotionalAppraisalAsset.LoadFromFile("template_ea"); EmotionalDecisionMaking = EmotionalDecisionMakingAsset.LoadFromFile("template_edm"); SocialImportance = SocialImportanceAsset.LoadFromFile("template_si"); IntegratedAuthoringTool = IntegratedAuthoringToolAsset.LoadFromFile("template_iat"); switch (Platform) { case Platform.Android: AssetManager.Instance.Bridge = new AndroidBaseBridge(); break; case Platform.iOS: AssetManager.Instance.Bridge = new IOSBaseBridge(); break; case Platform.Windows: AssetManager.Instance.Bridge = new BaseBridge(); break; } }
public void LoadAssociatedAssets(AssetStorage storage) { var charName = CharacterName.ToString(); m_emotionalAppraisalAsset = EmotionalAppraisalAsset.CreateInstance(storage); m_emotionalDecisionMakingAsset = EmotionalDecisionMakingAsset.CreateInstance(storage); m_socialImportanceAsset = SocialImportanceAsset.CreateInstance(storage); m_commeillFautAsset = CommeillFautAsset.CreateInstance(storage); //Dynamic properties BindToRegistry(m_kb); m_emotionalDecisionMakingAsset.RegisterKnowledgeBase(m_kb); m_commeillFautAsset.RegisterKnowledgeBase(m_kb); m_socialImportanceAsset.RegisterKnowledgeBase(m_kb); }
protected override void OnAssetDataLoaded(SocialImportanceAsset asset) { _attributionRulesVM.Reload(); _attRulesDataView.ClearSelection(); _attRulesDataView.GetColumnByName(PropertyUtil.GetPropertyName<AttributionRuleDTO>(dto => dto.Id)).Visible = false; _attRulesDataView.GetColumnByName(PropertyUtil.GetPropertyName<AttributionRuleDTO>(dto => dto.Conditions)).Visible = false; _claimsVM.Reload(); _claimDataView.ClearSelection(); _conferralsVM.Reload(); _conferralsDataView.ClearSelection(); _conferralsDataView.GetColumnByName(PropertyUtil.GetPropertyName<ConferralDTO>(dto => dto.Id)).Visible = false; _conferralsDataView.GetColumnByName(PropertyUtil.GetPropertyName<ConferralDTO>(dto => dto.Conditions)).Visible = false; }
//This is a small console program to exemplify the main functionality of the Social Importance Asset static void Main(string[] args) { var siTarget = "Player"; //First, we load the asset from an existing profile var siAsset = SocialImportanceAsset.CreateInstance(new GAIPS.Rage.AssetStorage()); var rules = siAsset.GetAttributionRules(); //We then register a knowledge base var kb = new KB((Name)"John"); kb.Tell((Name)"IsFriend(Player)", (Name)"False"); siAsset.RegisterKnowledgeBase(kb); Console.WriteLine("The SI attributed to " + siTarget + " is:" + siAsset.GetSocialImportance(siTarget)); Console.ReadKey(); }
protected override void OnAssetDataLoaded(SocialImportanceAsset asset) { attributionRules = new BindingListView <AttributionRuleDTO>((IList)null); dataGridViewAttributionRules.DataSource = this.attributionRules; _attRuleConditionSetEditor.View = conditions; conditions = new ConditionSetView(); _attRuleConditionSetEditor.View = conditions; conditions.OnDataChanged += ConditionSetView_OnDataChanged; attributionRules.DataSource = LoadedAsset.GetAttributionRules().ToList(); EditorTools.HideColumns(dataGridViewAttributionRules, new[] { PropertyUtil.GetPropertyName <AttributionRuleDTO>(o => o.Id), PropertyUtil.GetPropertyName <AttributionRuleDTO>(o => o.Conditions) }); _wasModified = false; }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { var aux = EditorTools.OpenFileDialog("Asset Storage File (*.json)|*.json|All Files|*.*"); if (aux != null) { try { _currentPath = aux; _storage = AssetStorage.FromJson(File.ReadAllText(_currentPath)); _loadedAsset = SocialImportanceAsset.CreateInstance(_storage); OnAssetDataLoaded(); } catch (Exception ex) { MessageBox.Show("Exception: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private static RolePlayCharacterAsset BuildEmotionalRPCAsset() { var kb = new KB((Name)"Matt"); var ea = new EmotionalAppraisalAsset(); var appraisalRule = new EmotionalAppraisal.DTOs.AppraisalRuleDTO() { Conditions = new Conditions.DTOs.ConditionSetDTO(), EventMatchingTemplate = (Name)"Event(*, *,*, *)", Desirability = Name.BuildName(2), Praiseworthiness = Name.BuildName(2) }; ea.AddOrUpdateAppraisalRule(appraisalRule); var rpc = new RolePlayCharacterAsset { BodyName = "Male", VoiceName = "Male", CharacterName = (Name)"Matt", m_kb = kb, }; rpc.m_emotionalAppraisalAsset = ea; rpc.BindToRegistry(rpc.m_kb); EmotionalDecisionMakingAsset edm = new EmotionalDecisionMakingAsset(); SocialImportanceAsset si = new SocialImportanceAsset(); CommeillFautAsset cfa = new CommeillFautAsset(); rpc.m_emotionalAppraisalAsset = ea; rpc.m_emotionalDecisionMakingAsset = edm; rpc.m_socialImportanceAsset = si; rpc.m_commeillFautAsset = cfa; return(rpc); }
private static SocialImportanceAsset BuildAsset() { var ea = new EmotionalAppraisalAsset("Matt"); #region Set KB ea.AddOrUpdateBelief(new BeliefDTO() { Name = "IsPerson(Matt)", Perspective = "*", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "IsPerson(Mary)", Perspective = "*", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "IsPerson(Diego)", Perspective = "*", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "IsPerson(Thomas)", Perspective = "*", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "IsPerson(Robot)", Perspective = "Diego", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "IsOutsider(Diego)", Perspective = "*", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "IsOutsider(Diego)", Perspective = "Robot", Value = "false" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "AreFriends(Self,Mary)", Perspective = "Self", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "AreFriends(Self,Matt)", Perspective = "Mary", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "AreFriends(Self,Thomas)", Perspective = "Self", Value = "true" }); ea.AddOrUpdateBelief(new BeliefDTO() { Name = "IsBartender(Matt)", Perspective = "*", Value = "true" }); #endregion #region SI DTO especification var siDTO = new SocialImportanceDTO { AttributionRules = new[] { new AttributionRuleDTO() { Target = "[target]", Value = 20, Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsPerson([target]) = true", "[target] != Self" } } }, new AttributionRuleDTO() { Target = "[target]", Value = -1, Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsOutsider([target]) = true", "[target] != Self" } } }, new AttributionRuleDTO() { Target = "[target]", Value = 15, Conditions = new ConditionSetDTO() { ConditionSet = new [] { "AreFriends(Self,[target]) = true" } } }, new AttributionRuleDTO() { Target = "[target]", Value = 10, Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsClient([target]) = true", "IsBartender(Self) = true", "[target] != Self" } } }, new AttributionRuleDTO() { Target = "[target]", Value = 1, Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsElder([target]) = true", "IsElder(Self) = false" } } }, new AttributionRuleDTO() { Target = "[target]", Value = -1, Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsElder([target]) = false", "IsElder(Self) = true" } } } }, Conferral = new[] { new ConferralDTO() { Action = "Give(Drink)", ConferralSI = 10, Target = "[x]", Conditions = new ConditionSetDTO() { ConditionSet = new [] { "AskedDrink([x])=true" } } }, new ConferralDTO() { Action = "Give(Best-Drink)", ConferralSI = 23, Target = "[x]", Conditions = new ConditionSetDTO() { ConditionSet = new [] { "AskedDrink([x])=true" } } } } }; #endregion var si = new SocialImportanceAsset(); si.LoadFromDTO(siDTO); si.BindEmotionalAppraisalAsset(ea); return si; }
private static SocialImportanceAsset BuildAsset() { var ea = new EmotionalAppraisalAsset("Matt"); #region Set KB ea.Kb.Tell((Name)"IsPerson(Matt)", true, Name.UNIVERSAL_SYMBOL); ea.Kb.Tell((Name)"IsPerson(Mary)", true, Name.UNIVERSAL_SYMBOL); ea.Kb.Tell((Name)"IsPerson(Diego)", true, Name.UNIVERSAL_SYMBOL); ea.Kb.Tell((Name)"IsPerson(Thomas)", true, Name.UNIVERSAL_SYMBOL); ea.Kb.Tell((Name)"IsPerson(Robot)", true, (Name)"Diego"); ea.Kb.Tell((Name)"IsOutsider(Diego)", true, Name.UNIVERSAL_SYMBOL); ea.Kb.Tell((Name)"IsOutsider(Diego)", false, (Name)"Robot"); ea.Kb.Tell((Name)"AreFriends(Self,Mary)", true, Name.SELF_SYMBOL); ea.Kb.Tell((Name)"AreFriends(Self,Matt)", true, (Name)"Mary"); ea.Kb.Tell((Name)"AreFriends(Self,Thomas)", true, Name.SELF_SYMBOL); #endregion #region SI DTO especification var siDTO = new SocialImportanceDTO { AttributionRules = new[] { new AttributionRuleDTO() { Target = "[target]", Value = 20, Conditions = new ConditionSetDTO() { Set = new [] { new ConditionDTO() { Condition = "IsPerson([target]) = true" }, new ConditionDTO() { Condition = "[target] != Self" } } } }, new AttributionRuleDTO() { Target = "[target]", Value = -1, Conditions = new ConditionSetDTO() { Set = new [] { new ConditionDTO() { Condition = "IsOutsider([target]) = true" }, new ConditionDTO() { Condition = "[target] != Self" } } } }, new AttributionRuleDTO() { Target = "[target]", Value = 15, Conditions = new ConditionSetDTO() { Set = new [] { new ConditionDTO() { Condition = "AreFriends(Self,[target]) = true" } } } }, new AttributionRuleDTO() { Target = "[target]", Value = 10, Conditions = new ConditionSetDTO() { Set = new [] { new ConditionDTO() { Condition = "IsClient([target]) = true" }, new ConditionDTO() { Condition = "IsBartender(Self) = true" }, new ConditionDTO() { Condition = "[target] != Self" } } } }, new AttributionRuleDTO() { Target = "[target]", Value = 1, Conditions = new ConditionSetDTO() { Set = new [] { new ConditionDTO() { Condition = "IsElder([target]) = true" }, new ConditionDTO() { Condition = "IsElder(Self) = false" } } } }, new AttributionRuleDTO() { Target = "[target]", Value = -1, Conditions = new ConditionSetDTO() { Set = new [] { new ConditionDTO() { Condition = "IsElder([target]) = false" }, new ConditionDTO() { Condition = "IsElder(Self) = true" } } } } } }; #endregion var si = new SocialImportanceAsset(); si.LoadFromDTO(siDTO); si.RegisterEmotionalAppraisalAsset(ea); return(si); }
private static SocialImportanceAsset BuildAsset() { var kb = new KB((Name)"Matt"); #region Set KB kb.Tell((Name)"IsPerson(Matt)", (Name)"true", (Name)"*"); kb.Tell((Name)"IsPerson(Mary)", (Name)"true", (Name)"*"); kb.Tell((Name)"IsPerson(Thomas)", (Name)"true", (Name)"*"); kb.Tell((Name)"IsPerson(Diego)", (Name)"true", (Name)"*"); kb.Tell((Name)"IsPerson(Robot)", (Name)"true", (Name)"Diego"); kb.Tell((Name)"IsOutsider(Diego)", (Name)"true", (Name)"*"); kb.Tell((Name)"IsOutsider(Diego)", (Name)"false", (Name)"Robot"); kb.Tell((Name)"AreFriends(SELF,Mary)", (Name)"true", (Name)"SELF"); kb.Tell((Name)"AreFriends(SELF,Matt)", (Name)"true", (Name)"Mary"); kb.Tell((Name)"AreFriends(SELF,Thomas)", (Name)"true", (Name)"SELF"); kb.Tell((Name)"IsBartender(Matt)", (Name)"true", (Name)"*"); #endregion #region SI DTO especification var siDTO = new SocialImportanceDTO { AttributionRules = new[] { new AttributionRuleDTO() { Target = (Name)"[target]", Value = (Name)"[v]", Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsPerson([target]) = true", "[target] != Self", "[v] = 20" } } }, new AttributionRuleDTO() { Target = (Name)"[target]", Value = (Name)"-1", Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsOutsider([target]) = true", "[target] != Self" } } }, new AttributionRuleDTO() { Target = (Name)"[target]", Value = (Name)"15", Conditions = new ConditionSetDTO() { ConditionSet = new [] { "AreFriends(Self,[target]) = true" } } }, new AttributionRuleDTO() { Target = (Name)"[target]", Value = (Name)"10", Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsClient([target]) = true", "IsBartender(Self) = true", "[target] != Self" } } }, new AttributionRuleDTO() { Target = (Name)"[target]", Value = (Name)"1", Conditions = new ConditionSetDTO() { ConditionSet = new [] { "IsElder([target]) = true", "IsElder(Self) = false" } } } } }; #endregion var si = new SocialImportanceAsset(); si.RegisterKnowledgeBase(kb); return(si); }
private static RolePlayCharacterAsset BuildEmotionalRPCAsset(int eaSet = -1) { var kb = new KB((Name)"Matt"); var ea = new EmotionalAppraisalAsset(); if (eaSet == -1) { var appraisalRule = new EmotionalAppraisal.DTOs.AppraisalRuleDTO() { Conditions = new Conditions.DTOs.ConditionSetDTO(), EventMatchingTemplate = (Name)"Event(*, *,*, *)", AppraisalVariables = new AppraisalVariables(new List <AppraisalVariableDTO>() { new AppraisalVariableDTO() { Name = OCCAppraisalVariables.DESIRABILITY, Value = (Name)"2" }, new AppraisalVariableDTO() { Name = OCCAppraisalVariables.PRAISEWORTHINESS, Value = (Name)"2" } }) }; ea.AddOrUpdateAppraisalRule(appraisalRule); } else { PopulateAppraisalRuleSet(); ea.AddOrUpdateAppraisalRule(appraisalRuleSet[eaSet]); } ea.AddOrUpdateGoal(new GoalDTO() { Name = "Goal", Significance = 5, Likelihood = 0.5f }); ea.AddOrUpdateGoal(new GoalDTO() { Name = "GoalNegative", Significance = 5, Likelihood = 0.2f }); ea.AddOrUpdateGoal(new GoalDTO() { Name = "GoalPositive", Significance = 5, Likelihood = 0.8f }); var rpc = new RolePlayCharacterAsset { BodyName = "Male", VoiceName = "Male", CharacterName = (Name)"Matt", m_kb = kb, }; rpc.m_emotionalAppraisalAsset = ea; rpc.BindToRegistry(rpc.m_kb); EmotionalDecisionMakingAsset edm = new EmotionalDecisionMakingAsset(); SocialImportanceAsset si = new SocialImportanceAsset(); CommeillFautAsset cfa = new CommeillFautAsset(); rpc.m_emotionalAppraisalAsset = ea; rpc.m_emotionalDecisionMakingAsset = edm; rpc.m_socialImportanceAsset = si; rpc.m_commeillFautAsset = cfa; return(rpc); }
protected override void OnAssetDataLoaded(RolePlayCharacterAsset asset) { textBoxCharacterName.Text = asset.CharacterName == null ? string.Empty : asset.CharacterName.ToString(); textBoxCharacterBody.Text = asset.BodyName; textBoxCharacterVoice.Text = asset.VoiceName; _emotionalStateVM = new EmotionalStateVM(this); _autobiographicalMemoryVM = new AutobiographicalMemoryVM(this); this.moodValueLabel.Text = Math.Round(_emotionalStateVM.Mood).ToString(MOOD_FORMAT); this.moodTrackBar.Value = (int)float.Parse(this.moodValueLabel.Text); this.StartTickField.Value = _emotionalStateVM.Start; this.emotionsDataGridView.DataSource = _emotionalStateVM.Emotions; this.dataGridViewAM.DataSource = _autobiographicalMemoryVM.Events; //EA ASSET if (string.IsNullOrEmpty(asset.EmotionalAppraisalAssetSource)) { _eaForm.Hide(); } else { this.pathTextBoxEA.Text = LoadableAsset <EmotionalDecisionMakingAsset> .ToRelativePath(LoadedAsset.AssetFilePath, asset.EmotionalAppraisalAssetSource); var ea = EmotionalAppraisalAsset.LoadFromFile(asset.EmotionalAppraisalAssetSource); _eaForm.LoadedAsset = ea; FormHelper.ShowFormInContainerControl(this.panelEA, _eaForm); } //EDM ASSET if (string.IsNullOrEmpty(asset.EmotionalDecisionMakingSource)) { _edmForm.Hide(); } else { this.textBoxPathEDM.Text = LoadableAsset <EmotionalDecisionMakingAsset> .ToRelativePath(LoadedAsset.AssetFilePath, asset.EmotionalDecisionMakingSource); var edm = EmotionalDecisionMakingAsset.LoadFromFile(asset.EmotionalDecisionMakingSource); _edmForm.LoadedAsset = edm; FormHelper.ShowFormInContainerControl(this.panelEDM, _edmForm); } //SI ASSET if (string.IsNullOrEmpty(asset.SocialImportanceAssetSource)) { _siForm.Hide(); } else { this.textBoxPathSI.Text = LoadableAsset <EmotionalDecisionMakingAsset> .ToRelativePath(LoadedAsset.AssetFilePath, asset.SocialImportanceAssetSource); var si = SocialImportanceAsset.LoadFromFile(asset.SocialImportanceAssetSource); _siForm.LoadedAsset = si; FormHelper.ShowFormInContainerControl(this.panelSI, _siForm); } //CIF ASSET if (string.IsNullOrEmpty(asset.CommeillFautAssetSource)) { _cifForm.Hide(); } else { this.textBoxPathCIF.Text = LoadableAsset <EmotionalDecisionMakingAsset> .ToRelativePath(LoadedAsset.AssetFilePath, asset.CommeillFautAssetSource); var cif = CommeillFautAsset.LoadFromFile(asset.CommeillFautAssetSource); _cifForm.LoadedAsset = cif; FormHelper.ShowFormInContainerControl(this.panelCIF, _cifForm); } //KB _knowledgeBaseVM = new KnowledgeBaseVM(this); dataGridViewBeliefs.DataSource = _knowledgeBaseVM.Beliefs; }