示例#1
0
        public void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
        {
            var link = (Hyperlink)sender;
            var text = new TextRange(link.ContentStart, link.ContentEnd).Text;

            var character_prototype = new r.character();
            var belief_prototype    = new r.belief();
            var character_belief_hypothesis_split = text.Split(new char[] { character_prototype.seperator });
            var character_gm_name = character_belief_hypothesis_split[0];
            var belief_variable   = character_belief_hypothesis_split[1];
            var character         = this.CurrentGame
                                    .Characters.Single(x => x.gm_name == character_gm_name && x.partition == this.CurrentGame.Partition);
            var belief = character
                         .beliefs.Single(x => x.variable == belief_variable && x.partition == this.CurrentGame.Partition);
            var prototype = this.CurrentGame.SaveHypothesesToBelief(character_belief_hypothesis_split[2], belief);

            this.Navigation.Navigate(this, prototype);
        }
示例#2
0
        public List <hypothesis> SaveHypothesesToBelief(string json, belief b)
        {
            var condition_probablity = new ConditionalProbability(json);
            var hypothesis_list      = new List <hypothesis>();
            int h_index = 0;

            this.Beliefs.ToArray();
            this.Hypotheses.ToArray();
            foreach (var h in condition_probablity)
            {
                var hypothesis = new hypothesis {
                    belief = b, name = h_index.ToString(), partition = this.Partition, propositions = new List <proposition>(h.Count)
                };
                for (int i = 0; i < h.Count; i++)
                {
                    var proposition = new proposition {
                        hypothesis = hypothesis, name = i.ToString(), value = decimal.Parse(h.ElementAt(i))
                    };
                    proposition = this.CreateOrRetrieve(
                        this.Propositions,
                        x => x.name == proposition.name &&
                        x.hypothesis.name == hypothesis.name,
                        proposition,
                        true);
                }
                hypothesis = this.CreateOrRetrieve(
                    this.Hypotheses,
                    x => x.name == hypothesis.name &&
                    x.belief.variable == hypothesis.belief.variable,
                    hypothesis,
                    true);
                hypothesis_list.Add(hypothesis);
                h_index++;
            }
            return(hypothesis_list);
        }