• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Population类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Population的典型用法代码示例。如果您正苦于以下问题:C# Population类的具体用法?C# Population怎么用?C# Population使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Population类属于命名空间,在下文中一共展示了Population类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadAll

    public void LoadAll(Population pop,float curHouses)
    {
        LoadAllHouses(curHouses);
        LoadAllPeople(pop);
        LoadAllBiomes();

    }
开发者ID:mattstg,项目名称:GameJam2016,代码行数:7,代码来源:WorldLoader.cs


示例2: RunGA

        private void RunGA(){
            _teams = LoadTeams();
            _winners = _teams.FindAll(l => l.Winner == true);
            _losers = _teams.FindAll(l => l.Winner == false);

            const double crossoverProbability = 0.85;
            const double mutationProbability = 0.15;
            const int elitismPercentage = 5;

            var population = new Population(1000, 72, true, false, ParentSelectionMethod.TournamentSelection);

            var elite = new Elite(elitismPercentage);

            var crossover = new Crossover(crossoverProbability, true)
            {
                CrossoverType = CrossoverType.DoublePoint
            };

            var mutation = new BinaryMutate(mutationProbability, true);

            var ga = new GeneticAlgorithm(population, EvaluateFitness);

            ga.OnGenerationComplete += ga_OnGenerationComplete;

            ga.Operators.Add(elite);
            ga.Operators.Add(crossover);
            ga.Operators.Add(mutation);

            ga.Run(TerminateAlgorithm);

        }
开发者ID:steppinrazor2009,项目名称:LetsPlayMiddle,代码行数:31,代码来源:LoLGAForm.cs


示例3: FitnessFunction

 public override void FitnessFunction(Population population, GeneticAlgorithm.NextStepDelegate callback)
 {
     this.population = population;
     InitiateNewSimulation();
     simulating = true;
     doneCallback = callback;
 }
开发者ID:KalleSjostrom,项目名称:Genome,代码行数:7,代码来源:CarsEnvironment.cs


示例4: PopulationSimulator

 public PopulationSimulator(int width, int height)
 {
     swarmInBirthOrder = new Species();
     swarmInXOrder = new Species();
     swarmInYOrder = new Species();
     Population = new Population();
 }
开发者ID:kbo4sho,项目名称:Swarm,代码行数:7,代码来源:PopulationSimulator.cs


示例5: LoadAllPeople

 private void LoadAllPeople(Population pop)
 {
     float errorCounter = 0;
     float totalError = 0;
     bool recklessPlacement = false;
     
     for (int i = 0; i < pop.currentPopulation; ++i)
     {
         Vector2 creationSpot = new Vector2(Random.Range(-Globals.mapRadiusX, Globals.mapRadiusX), Random.Range(-Globals.mapRadiusY, Globals.mapRadiusY));
         RaycastHit2D[] allHit = Physics2D.RaycastAll(creationSpot, -Vector2.up,0);
         if (allHit.Length == 0 || recklessPlacement)
         {
             GameObject go = Instantiate(Resources.Load("Villager"), creationSpot, Quaternion.identity) as GameObject;
             go.GetComponent<Villager>().Initialize(pop.averagePercentLifePoints, pop.averageHappiness, pop.averageHealthiness);
         } else {
             errorCounter++;
             totalError++;
             if (errorCounter > 10) //too much wait, that vilagers toast, next one
             {
                 errorCounter = 0;
                 ++i;
             }
             if (totalError > 40)  //too much thrashing, just place them ontop other objects and hope unity forces them out
             {
                 recklessPlacement = true;
             }                
         }            
     }        
 }
开发者ID:mattstg,项目名称:GameJam2016,代码行数:29,代码来源:WorldLoader.cs


示例6: DemoPlayerInputStrategy

    public DemoPlayerInputStrategy()
    {
        var population = new Population (6, 6, new DemoPlayerChromosome ());
        var fitness = new DemoPlayerFitness ();
        var selection = new EliteSelection ();
        var crossover = new OnePointCrossover (0);
        var mutation = new UniformMutation (true);

        m_ga = new GeneticAlgorithm (
            population,
            fitness,
            selection,
            crossover,
            mutation);

        m_ga.MutationProbability = 0.5f;
        m_ga.GenerationRan += (sender, e) => {
            m_bestChromossome = m_ga.BestChromosome as DemoPlayerChromosome;

            if(m_bestChromossome.AvoidAliensProjectilesProbability > 0.9f) {
                HorizontalDirection = 1f;
            }
        };
        m_ga.Start ();

        SHThread.PingPong (.01f, 0, 1, (t) => {
            m_ga.Termination = new GenerationNumberTermination (m_ga.GenerationsNumber + 1);
            m_ga.Resume();

            return true;
        });
    }
开发者ID:skahal,项目名称:SpaceInvadersRemake,代码行数:32,代码来源:DemoPlayerInputStrategy.cs


示例7: Select

    public override void Select(Population population, SelectionBuffer selection, GeneticAlgorithm.NextStepDelegate callback)
    {
        int size = 0;

        // TODO: Implement settings for how to truncate.
        float cutoff = 0;
        switch (truncationMode) {
        case TruncationMode.AboveMiddle:
            cutoff = population.MinFitness + (population.MaxFitness - population.MinFitness)/2;
            break;
        case TruncationMode.AboveMean:
            cutoff = population.MeanFitness;
            break;
        case TruncationMode.AboveMedian:
            cutoff = population.MedianFitness;
            break;
        }

        for (int i = 0; i < population.Size; i++) {
            if (population[i].Fitness > cutoff) {
                selection[size].CloneFrom(population[i].Genome);
                size++;
            }
        }

        selection.Size = size;
        callback();
    }
开发者ID:KalleSjostrom,项目名称:Genome,代码行数:28,代码来源:TruncationSelection.cs


示例8: InitializePanelWithTrainerData

	public void InitializePanelWithTrainerData() {
		DebugBot.DebugFunctionCall("TPopUI; InitializePanelWithTrainerData(); ", debugFunctionCalls);
		Trainer trainer = trainerModuleScript.gameController.masterTrainer;
		if(trainer.PlayerList != null) {

			int curPlayer = trainer.CurPlayer;
			//Debug.Log ("InitializePanelWithTrainerData(), " + trainer.PlayerList[curPlayer-1].maxMaxPopulationSize.ToString());
			//sliderMaxPopulationSize.minValue = trainer.PlayerList[curPlayer-1].minMaxPopulationSize;
			//sliderMaxPopulationSize.maxValue = trainer.PlayerList[curPlayer-1].maxMaxPopulationSize;
			//sliderMaxPopulationSize.value = trainer.PlayerList[curPlayer-1].maxPopulationSize;
			if(trainer.PlayerList[curPlayer-1].masterPopulation != null) {  // if the current player has a Population instance:
				populationRef = trainer.PlayerList[curPlayer-1].masterPopulation; // get current population instance
				//Current Population text:
				textCurrentPopulationSize.text = "Current Population Size: " + (populationRef.isFunctional ? populationRef.masterAgentArray.Length.ToString() : "0"); // Update this later!!
				//Current Max Population Size:
				sliderMaxPopulationSize.minValue = minMaxPopulationSize; // set up slider bounds
				sliderMaxPopulationSize.maxValue = maxMaxPopulationSize;
				sliderMaxPopulationSize.value = populationRef.populationMaxSize;
				textMaxPopulationSize.text = populationRef.populationMaxSize.ToString();

			}
			else {  // Population hasn't been created yet:
				//textMaxPopulationSize.text = trainer.PlayerList[curPlayer-1].maxPopulationSize.ToString();
			}
		}

		valuesChanged = false;
		applyPressed = false;

		UpdateUIWithCurrentData();
	}
开发者ID:eaclou,项目名称:Master_CreatureTrainer01,代码行数:31,代码来源:TrainerPopulationUI.cs


示例9: AdvancePopulation

        public Population AdvancePopulation(Population population)
        {
            var chromosomes = new List<Chromosome>();
            population = new Population(population.Take((int)(TruncationRate * population.Count()))); // TRUNCATION

            do
            {
                Chromosome chosen1 = selection.Select(population),
                           chosen2 = selection.Select(population);

                if (random.NextDouble() < CrossoverRate)
                {
                    var children = crossover.Crossover(chosen1, chosen2); // CROSSOVER
                    chosen1 = children.Item1;
                    chosen2 = children.Item2;
                }

                if (random.NextDouble() < MutationRate)
                {
                    chosen1 = mutation.Mutate(chosen1); // MUTATION
                }

                if (random.NextDouble() < MutationRate)
                {
                    chosen2 = mutation.Mutate(chosen2); // MUTATION
                }

                chromosomes.Add(chosen1);
                chromosomes.Add(chosen2);
            } while (chromosomes.Count < ChromosomeCount);

            return new Population(chromosomes);
        }
开发者ID:dreasgrech,项目名称:HATETRIS-GA,代码行数:33,代码来源:GeneticAlgorithm.cs


示例10: Resource

 public Resource(ResourceType type, ResourceLevel level)
 {
     Type = type;
     Level = level;
     Population = new Population();
     StorageLevel = 20;
 }
开发者ID:ndech,项目名称:Alpha,代码行数:7,代码来源:Resource.cs


示例11: display

 public static void display(Population p, int gen)
 {
     Tour best = p.findBest();
     System.Console.WriteLine("Generation {0}\n" +
         "Best fitness:  {1}\n" +
         "Best distance: {2}\n", gen, best.fitness, best.distance);
 }
开发者ID:7lb,项目名称:TSP,代码行数:7,代码来源:Program.cs


示例12: AdvanceGeneration

        static Population AdvanceGeneration(Population population, ISelection selection, ICrossover crossover, IMutation mutation)
        {
            var chromosomes = new List<Chromosome>();
            population = new Population(population.Take((int)(truncationRate * population.Count()))); // TRUNCATION
            chromosomes.AddRange(population.Take((int)(elitismRate * chromosomeCount)));  //ELITE (assuming that the chromosomes in the population are sorted by fitness (the fitter are at the top of the list)

            do
            {
                Chromosome chosen1 = selection.Select(population),
                           chosen2 = selection.Select(population);

                if (random.NextDouble() < crossoverRate)
                {
                    var children = crossover.Crossover(chosen1, chosen2); // CROSSOVER
                    chosen1 = children.Item1;
                    chosen2 = children.Item2;
                }

                if (random.NextDouble() < mutationRate)
                {
                    chosen1 = mutation.Mutate(chosen1); // MUTATION
                }

                if (random.NextDouble() < mutationRate)
                {
                    chosen2 = mutation.Mutate(chosen2); // MUTATION
                }

                chromosomes.Add(chosen1);
                chromosomes.Add(chosen2);
            } while (chromosomes.Count < chromosomeCount);

            return new Population(chromosomes);
        }
开发者ID:dreasgrech,项目名称:StringEvolver,代码行数:34,代码来源:Program.cs


示例13: InitializePanelWithTrainerData

    public void InitializePanelWithTrainerData() {
		
		Player currentPlayer = trainerModuleScript.gameController.masterTrainer.PlayerList[trainerModuleScript.gameController.masterTrainer.CurPlayer-1];
		populationRef = currentPlayer.masterPopulation;
		
		DebugBot.DebugFunctionCall("LoadPopulationUI; InitializePanelWithTrainerData(); ", debugFunctionCalls);
		
		UpdateUIWithCurrentData();
	}
开发者ID:eaclou,项目名称:Master_CreatureTrainer01,代码行数:9,代码来源:TrainerLoadPopulationUI.cs


示例14: Create

 //    string name,
 //    float fullFoodAmt,
 //    float feedIntSec,
 //    float hungryWindow,
 //    float energyProduceVal
 public override Organism Create(Population population)
 {
     return new Organism(population,
                         "bacteria",
                         1f,
                         20f,
                         20f,
                         1f);
 }
开发者ID:hmuar,项目名称:darwin,代码行数:14,代码来源:BacteriaFactory.cs


示例15: Scale

 private void Scale(Population population)
 {
     foreach (var chromosome in population.Chromosomes)
     {
         double value = chromosome.Value + (population.AvgFitness - c * _sigma);
         if (value < 0) value = 0;
         chromosome.Value = value;
     }
 }
开发者ID:OlekNg,项目名称:AHMED,代码行数:9,代码来源:ModifiedRouletteSelector.cs


示例16: Agent

    public Agent(Population populationIn, int generationIn)
    {
        //	Debug.Log("Agent created " + Time.time);
        componentsList = new ArrayList();
        generation = generationIn;
        population = populationIn;

        CreateRandomComponents();
    }
开发者ID:CallumCode,项目名称:GeneticAlgorithmGame,代码行数:9,代码来源:Agent.cs


示例17: Create

 //    string name,
 //    float fullFoodAmt,
 //    float feedIntSec,
 //    float hungryWindow,
 //    float energyProduceVal
 public override Organism Create(Population population)
 {
     return new Organism(population,
                         "fish",
                         1f,
                         3f,
                         3f,
                         5f);
 }
开发者ID:hmuar,项目名称:darwin,代码行数:14,代码来源:FishFactory.cs


示例18: Parametres

        public Parametres(Population oldParam)
        {
            InitializeComponent();

            MaxNotes = oldParam.MaxNotes;
            MaxIndividus = oldParam.MaxIndividus;
            Crossover = oldParam.Crossover;
            Mutarate = oldParam.Mutarate;
        }
开发者ID:lezhumain,项目名称:GenerateurMusique,代码行数:9,代码来源:ParamView.xaml.cs


示例19: SetUp

        public void SetUp()
        {
            PopulationGenerator = new Mock<IPopulationGenerator<string>>();
            FitnessEvaluator = new Mock<IFitnessEvaluator<string>>();
            Count = 1;

            PopulationMock = new Mock<Population<string>>(Count, PopulationGenerator.Object, FitnessEvaluator.Object);
            Population = new Population<string>(Count, PopulationGenerator.Object, FitnessEvaluator.Object);
        }
开发者ID:smudge202,项目名称:geneticsharporithm,代码行数:9,代码来源:PopulationTests.cs


示例20: Create

 // override this
 public virtual Organism Create(Population population)
 {
     return new Organism(population,
                         "unnamed",
                         0f,
                         0f,
                         0f,
                         0f);
 }
开发者ID:hmuar,项目名称:darwin,代码行数:10,代码来源:OrganismFactory.cs



注:本文中的Population类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PopupDialog类代码示例发布时间:2022-05-24
下一篇:
C# PooledSocket类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap