public PlayerPosition Generate() { // we generate a random percentile Percentile percentileCategory = _percentileGenerator.Generate(); // then, using the 1-NN calculator, we get the nearest neighbour to the percentile var categoryCalculator = new PercentileNearestNeighbourCalculator <PositionCategory>( percentileCategory, _percentileCategories.ToArray()); // and we get the category from the nearest neighbour PositionCategory category = categoryCalculator.GetNearestNeighbourUnderlyingType(); // retrieve positions from the category List <PercentileData <PlayerPosition> > positionsData = _percentilePositions .Where(pp => pp.Object.PositionCategory == category) .ToList(); var min = positionsData.Min(p => p.Percentile); var max = positionsData.Max(p => p.Percentile); var positionPercentile = _percentileGenerator.Generate(min, max); var positionCalculator = new PercentileNearestNeighbourCalculator <PlayerPosition>( positionPercentile, positionsData.ToArray()); return(positionCalculator.GetNearestNeighbourUnderlyingType()); }
public Foot Generate() { Percentile rndPct = _percentileGenerator.Generate(); var calculator = new PercentileKNearestNeighborCalculator <Foot>(rndPct, _data); return(calculator.GetNearestNeighbours().Value[0].Value.Object); }
public Player Generate(Gender?playerGender = null, Country[] countries = null, PlayerPosition playerPosition = null) { if (playerGender == null) { playerGender = _genderGenerator.Generate(); } if (countries == null) { countries = _countriesGenerator.Generate().Value; } PersonName playerName = _nameGenerator.Generate(playerGender.Value, countries.FirstOrDefault()); Date dob = _dobGenerator.Generate(); PersonAge playerAge = PersonAge.FromDate(dob, _game.CurrentDate); Location birthLocation = _birthLocationGenerator.Generate(countries.FirstOrDefault()); Foot playerFoot = _favouriteFootGenerator.Generate(); Percentile percentile = _percentileGenerator.Generate(); BodyMassIndex bmi = _bmiGenerator.Generate(countries.FirstOrDefault(), playerGender.Value, percentile, dob); PlayerPosition position = _playerPositionGenerator.Generate(); PhysicalFeatureSet playerFeatureSet = _physicalFeatureSetGenerator.Generate(position, bmi, countries.FirstOrDefault(), playerAge); // first name & last name => according to the player's country return(new PlayerBuilder() .WithName(playerName) .WithGender(playerGender.Value) .WithBirthInfo(new BirthInfo(dob, birthLocation)) .WithFoot(playerFoot) .WithPercentile(percentile) .WithBodyMassIndex(bmi) .WithPlayerPosition(position) .WithFeatureSet(playerFeatureSet) .WithCountries(countries) .Build()); }