Beispiel #1
0
        public Population(IPopulationParameters parameters)
        {
            Units = new List <Team>();

            for (int i = 0; i < parameters.PopulationSize; i++)
            {
                Units.Add(TeamFactory.GetTeam(parameters));
            }

            Best = Units.FirstOrDefault()?.GetClone();
        }
        public Team LoadTeam(string path, ITeamParameters parameters)
        {
            var team = TeamFactory.GetTeam(parameters);

            for (int i = 0; i < parameters.NumberOfShepherds; i++)
            {
                team.Members[i] = Load <Shepherd>(Path.Combine(path, i.ToString()) + ".xml");
            }

            return(team);
        }
Beispiel #3
0
        public void GetTeam_AssignsAppropriateNumberOfEnemiesToTeam([Values(1, 2, 3, 4)] int numEnemies)
        {
            //push logic for determining how many fighters will be in the enemy team, driven by SubRegion configuration
            _chanceService.PushWhichEventOccurs(0);

            Type[] types = { typeof(Goblin), typeof(Fairy), typeof(Golem), typeof(Ogre) };
            for (var i = 0; i < numEnemies; ++i)
            {
                _chanceService.PushWhichEventOccurs(i);
            }

            SubRegion subRegion = new SubRegion(WorldSubRegion.Fields, 1, new [] { new ChanceEvent <int>(numEnemies, 1) },
                                                new[] { FighterType.Goblin, FighterType.Fairy, FighterType.Golem, FighterType.Ogre }, null);

            _enemyTeam = _teamFactory.GetTeam(subRegion);

            Assert.AreEqual(numEnemies, _enemyTeam.Fighters.Count);

            for (var i = 0; i < numEnemies; ++i)
            {
                var enemy = _enemyTeam.Fighters[i];
                Assert.AreEqual(types[i], enemy.GetType());
            }
        }
 public Team GetTeam(SubRegion region)
 {
     return(_teams.Count > 0 ? _teams.Dequeue() : _realTeamFactory.GetTeam(region));
 }