public Belief(Belief p1, Belief p2) { Belief takingBelief; //If parent1 beliefs is dominate but not parent twos if (p1.Dominate && !p2.Dominate) { takingBelief = p1; } //If parent 2 is dominat but not parent 1 else if (p2.Dominate && !p1.Dominate) { takingBelief = p2; } //If both are dominant or both receesive else { var rand = new Random(); //Will pick either 0,1 takingBelief = rand.Next(0, 2) == 1 ? p1 : p2; } BeliefType = takingBelief.BeliefType; Dominate = takingBelief.Dominate; }
public Beliefs GenerateChildBeliefs(List <Belief> otherBeliefs) { var beliefs = new Beliefs(); //TODO fix this so that people with different count of beliefs can have children if (HeldBeliefs.Count != otherBeliefs.Count) { throw new ArgumentException("The beliefs need to be the same length!"); } for (int i = 0; i < HeldBeliefs.Count; i++) { var p1 = HeldBeliefs.ElementAt(i); var p2 = otherBeliefs.ElementAt(i); var belief = new Belief(p1, p2); beliefs.AddBelief(belief); } return(beliefs); }
public void AddBelief(Belief belief) { HeldBeliefs.Add(belief); }