public override bool MatchTypes(NounType t1, NounType t2) { // can do identity or name <-> backstory or motive return( CheckCommutative(t1, t2, NounType.Identity, NounType.Backstory) || CheckCommutative(t1, t2, NounType.Identity, NounType.Motive) || CheckCommutative(t1, t2, NounType.Name, NounType.Backstory) || CheckCommutative(t1, t2, NounType.Name, NounType.Motive) ); }
/// <summary> /// 名詞を設定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void SetNounView(object sender, EventArgs e) { if (NowPanelMode != NounType.Noun) { NowPanelMode = NounType.Noun; ContainerFactory.NounList.SetNounFocus(); ContainerFactory.ArticleList.SetArticleList(ContainerFactory.JapaneseReadTypeComboBox._JapaneseReadType); SetOpenView(); } }
private ClueItem GetClueInternal(Noun n1, Noun n2) { NounType t1 = n1.Type(); NounType t2 = n2.Type(); foreach (GameObject g in clues) { ClueGenerator generator = g.GetComponent <ClueGenerator>(); if (generator.MatchTypes(t1, t2)) { ClueItem item = generator.GetItem(n1, n2); return(item); } } return(null); }
/// <summary> /// パネルを初期化 /// </summary> public void SetInitPanel() { //名詞リスト表示 NowPanelMode = NounType.Noun; ContainerFactory.NounList.SetNounList(ContainerFactory.JapaneseReadTypeComboBox._JapaneseReadType, true); ContainerFactory.PersonPrepositionList.SetPersonPrepositionList(ContainerFactory.JapaneseReadTypeComboBox._JapaneseReadType, true); ContainerFactory.LocationPrepositionList.SetLocationPrepositionList(ContainerFactory.JapaneseReadTypeComboBox._JapaneseReadType, true); //冠詞リスト表示 ContainerFactory.ArticleList.SetArticleList(ContainerFactory.JapaneseReadTypeComboBox._JapaneseReadType, true); //所有格リスト表示 ContainerFactory.PossessiveList.SetPossessiveList(ContainerFactory.JapaneseReadTypeComboBox._JapaneseReadType, true); //単数複数ボタンのイベント処理登録 parent.quantitySingleBtn.Click += SetQuantitySingle_ButtonClick; parent.quantityMultiBtn.Click += SetQuantityMulti_ButtonClick; parent.NounListView.ColumnClick += SetNounView; parent.PersonPrepositionListView.ColumnClick += SetPersonPrepositionView; parent.LocationPrepositionListView.ColumnClick += SetLocationPrepositionListViewView; }
public static Noun[] GetMutuallyExclusiveNouns(this NounType nounType) // this is for the AI to make deductions based on mutual exclusion { switch (nounType) { case NounType.HairColor: return(new Noun[] { Noun.Blonde, Noun.Brunette, Noun.Redhead }); case NounType.Identity: return(new Noun[] { Noun.ExWife, Noun.Daughter, Noun.Mistress }); case NounType.Role: return(new Noun[] { Noun.Killer }); case NounType.Name: return(new Noun[] { Noun.Alice, Noun.Brianna, Noun.Catherine }); default: return(null); } }
public override bool MatchTypes(NounType t1, NounType t2) { return(t1 == NounType.Unique || t2 == NounType.Unique); }
public virtual bool MatchTypes(NounType t1, NounType t2) { return(false); }
protected bool CheckCommutative(NounType a1, NounType a2, NounType b1, NounType b2) { return((a1 == b1 && a2 == b2) || (a1 == b2 && a2 == b1)); }
public override bool MatchTypes(NounType t1, NounType t2) { return((t1 == NounType.HairColor && t2 == NounType.Identity) || (t1 == NounType.Identity && t2 == NounType.HairColor)); }
public override bool MatchTypes(NounType t1, NounType t2) { return((t1 == NounType.Name && t2 == NounType.Identity) || (t1 == NounType.Identity && t2 == NounType.Name)); }
public Noun(string name, NounType nounType, string pluralized = null) { Name = name; NounType = nounType; Pluralized = pluralized ?? name + "s"; }
private void UpdateBeliefs(List <SentenceBelief> newBeliefs) { // go through all knowledge, and see if we can synthesize anything new from the new beliefs Debug.Log(mPersonId + " updating beliefs "); // defer adding/removing knowledge until the end, so we aren't modifying knowledge while we read it List <SentenceBelief> beliefDeductions = new List <SentenceBelief>(); List <SentenceBelief> refutedBeliefs = new List <SentenceBelief>(); foreach (SentenceBelief b1 in newBeliefs) { Sentence s1 = b1.mSentence; // before making any inferences, check for contradictions bool contradictory = false; foreach (SentenceBelief b2 in mBeliefs) { Sentence s2 = b2.mSentence; if (s1.SameIdea(s2) && s1.Adverb != s2.Adverb) { contradictory = true; if (b2.mConfidence >= 1) { Debug.Log(mPersonId + " accepted info that contradicts something known: " + s1 + " vs. " + s2); refutedBeliefs.Add(b1); continue; } if (b1.mConfidence >= 1) { Debug.Log(mPersonId + " found information contradicting previous beliefs: " + s1 + " vs. " + s2); refutedBeliefs.Add(b2); beliefDeductions.Add(b1); // queue up this belief for re-thinking, after removing the belief it contradicts } else { // conflicting information, but not sure about which is true... oh well // TODO: what to do here? set up some kind of contradictory info set that the AI active seeks to resolve? } } } if (contradictory) { Debug.Log(mPersonId + " thinks " + b1.mSentence + " is contradictory, and will not make inferences with it"); continue; } // rule 1: transitivity // [A is B] and [B is C] => [A is C] (including valid permutations) // also, the negative version (rule 1.5): [A is B] and [B is not C] => [A is not C] if (s1.Verb == Verb.Is) { if (s1.Adverb == Adverb.True) { foreach (SentenceBelief b2 in mBeliefs) { if (b1.Equals(b2)) { continue; } Sentence s2 = b2.mSentence; if (s2.Verb != Verb.Is) { continue; } Sentence newSentence = null; float confidence = b1.mConfidence * b2.mConfidence; if (confidence <= 0.2) { continue; } if (s2.Adverb == Adverb.True || s2.Adverb == Adverb.False) { if (s1.DirectObject == s2.Subject) { newSentence = new Sentence(s1.Subject, Verb.Is, s2.DirectObject, s2.Adverb); } else if (s1.Subject == s2.Subject) { newSentence = new Sentence(s1.DirectObject, Verb.Is, s2.DirectObject, s2.Adverb); } else if (s1.DirectObject == s2.DirectObject) { newSentence = new Sentence(s1.Subject, Verb.Is, s2.Subject, s2.Adverb); } else if (s1.Subject == s2.DirectObject) { newSentence = new Sentence(s1.DirectObject, Verb.Is, s2.Subject, s2.Adverb); } } if (newSentence != null) { SentenceBelief newBelief = new SentenceBelief(newSentence, b1, b2, confidence); beliefDeductions.Add(newBelief); Debug.Log("New belief: " + newBelief.mSentence + " (confidence: " + confidence + ") | Since " + s1 + " (confidence: " + b1.mConfidence + ") and " + s2 + " (confidence: " + b2.mConfidence + ")"); } } } else if (s1.Adverb == Adverb.False) { foreach (SentenceBelief b2 in mBeliefs) { if (b1.Equals(b2)) { continue; } Sentence s2 = b2.mSentence; if (!(s2.Verb == Verb.Is && s2.Adverb == Adverb.True)) { continue; } Sentence newSentence = null; float confidence = b1.mConfidence * b2.mConfidence; if (confidence <= 0.2) { continue; } if (s1.DirectObject == s2.Subject) { newSentence = new Sentence(s1.Subject, Verb.Is, s2.DirectObject, Adverb.False); } else if (s1.Subject == s2.Subject) { newSentence = new Sentence(s1.DirectObject, Verb.Is, s2.DirectObject, Adverb.False); } else if (s1.DirectObject == s2.DirectObject) { newSentence = new Sentence(s1.Subject, Verb.Is, s2.Subject, Adverb.False); } else if (s1.Subject == s2.DirectObject) { newSentence = new Sentence(s1.DirectObject, Verb.Is, s2.Subject, Adverb.False); } if (newSentence != null) { SentenceBelief newBelief = new SentenceBelief(newSentence, b1, b2, confidence); beliefDeductions.Add(newBelief); Debug.Log("New belief: " + newBelief.mSentence + " (confidence: " + confidence + ") | Since " + s1 + " (confidence: " + b1.mConfidence + ") and " + s2 + " (confidence: " + b2.mConfidence + ")"); } } } } // END TRANSITIVITY // rule 2: mutual exclusion // if [A is X] and [X, Y] are mutually exclusive, then [A is not Y] // but this only applies if A <-> X is an IS relationship (i.e. nothing else can be X) if ((s1.Verb == Verb.Is && s1.Adverb == Adverb.True)) { NounType t = s1.DirectObject.Type(); Noun[] nouns = t.GetMutuallyExclusiveNouns(); if (nouns != null) { foreach (Noun n in nouns) { if (s1.DirectObject != n) { Sentence newSentence = new Sentence(s1.Subject, Verb.Is, n, Adverb.False); SentenceBelief belief = new SentenceBelief(newSentence, b1, null, b1.mConfidence); beliefDeductions.Add(belief); Debug.Log("New belief: " + belief.mSentence + " (confidence: " + b1.mConfidence + ") | Since " + s1 + " (confidence: " + b1.mConfidence + ")"); } } } t = s1.Subject.Type(); nouns = t.GetMutuallyExclusiveNouns(); if (nouns != null) { foreach (Noun n in nouns) { if (s1.Subject != n) { Sentence newSentence = new Sentence(s1.DirectObject, Verb.Is, n, Adverb.False); SentenceBelief belief = new SentenceBelief(newSentence, b1, null, b1.mConfidence); beliefDeductions.Add(belief); Debug.Log("New belief: " + belief.mSentence + " (confidence: " + b1.mConfidence + ") | Since " + s1 + " (confidence: " + b1.mConfidence + ")"); } } } } // END MUTUAL EXCLUSIVITY // special rule: determining motive NounType subjectType = s1.Subject.Type(); NounType objectType = s1.DirectObject.Type(); if (subjectType == NounType.Motive) { Sentence newSentence = new Sentence(s1.DirectObject, Verb.Has, Noun.Motive, Adverb.True); SentenceBelief belief = new SentenceBelief(newSentence, b1, null, b1.mConfidence); beliefDeductions.Add(belief); } else if (objectType == NounType.Motive) { Sentence newSentence = new Sentence(s1.Subject, Verb.Has, Noun.Motive, Adverb.True); SentenceBelief belief = new SentenceBelief(newSentence, b1, null, b1.mConfidence); beliefDeductions.Add(belief); } } RemoveBeliefs(refutedBeliefs); AddBeliefs(beliefDeductions); }