コード例 #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;
        }
コード例 #2
0
        public void Normalize( )
        {
            var sum = CooperatorGroup.QualitySum + DefectorGroup.QualitySum;
            var n   = AllIndividuals.Count;

            CooperatorGroup.Normalize(sum, n);
            DefectorGroup.Normalize(sum, n);
        }
コード例 #3
0
        public bool Remove(Individual individual)
        {
            AllIndividuals.Remove(individual);
            if (individual.Type == IndividualType.Cooperator)
            {
                return(CooperatorGroup.Remove(individual));
            }

            return(DefectorGroup.Remove(individual));
        }
コード例 #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( );
        }
コード例 #5
0
        public void Add(Individual individual)
        {
            if (individual.Type == IndividualType.Cooperator)
            {
                CooperatorGroup.Add(individual);
            }
            else
            {
                DefectorGroup.Add(individual);
            }

            AllIndividuals.Add(individual);
        }