Exemplo n.º 1
0
        public void Swap(Individual remove,
                         Individual add)
        {
            if (remove.Type == IndividualType.Cooperator)
            {
                CooperatorGroup.Remove(remove);
            }
            else
            {
                DefectorGroup.Remove(remove);
            }

            if (add.Type == IndividualType.Cooperator)
            {
                CooperatorGroup.Add(add);
            }
            else
            {
                DefectorGroup.Add(add);
            }

            var index = AllIndividuals.IndexOf(remove);

            AllIndividuals[index] = add;
        }
Exemplo n.º 2
0
        public void Normalize( )
        {
            var sum = CooperatorGroup.QualitySum + DefectorGroup.QualitySum;
            var n   = AllIndividuals.Count;

            CooperatorGroup.Normalize(sum, n);
            DefectorGroup.Normalize(sum, n);
        }
Exemplo n.º 3
0
        public bool Remove(Individual individual)
        {
            AllIndividuals.Remove(individual);
            if (individual.Type == IndividualType.Cooperator)
            {
                return(CooperatorGroup.Remove(individual));
            }

            return(DefectorGroup.Remove(individual));
        }
Exemplo n.º 4
0
        public void Init(Variables v)
        {
            CooperatorGroup = new CooperatorGroup( );
            DefectorGroup   = new DefectorGroup( );

            CooperatorGroup.Populate(v.CooperatorQuantity, v);
            DefectorGroup.Populate(v.DefectorQuantity, v);

            AllIndividuals = CooperatorGroup.Concat(DefectorGroup).ToList( );
        }
Exemplo n.º 5
0
        public void Add(Individual individual)
        {
            if (individual.Type == IndividualType.Cooperator)
            {
                CooperatorGroup.Add(individual);
            }
            else
            {
                DefectorGroup.Add(individual);
            }

            AllIndividuals.Add(individual);
        }