public void Deploy(TurnManager turnManager, int numberOfTroops) { while (numberOfTroops > 0) { turnManager.DeployTroops(GetRandomOwnedCountry(turnManager), 1); numberOfTroops--; } }
public void Deploy(TurnManager turnManager, int numberOfTroops) { while (numberOfTroops > 0) { turnManager.DeployTroops(GetMostImportantCountry(turnManager), 1); numberOfTroops--; } }
public void Deploy(TurnManager turnManager, int numberOfTroops) { gameInformation = turnManager.GetGameInfo(); //exclude all isolated countries (all countries with only enemy neighbours) var countriesToAimAt = gameInformation.GetAllCountriesOwnedByPlayer(this) .Where(x => gameInformation.GetAdjacentCountriesWithSameOwner(x).Any()) .ToArray(); //Determine defensiveRate. //While there are countries with low defensiveRate (number of own troops / number of surrounding troups), make those stronger. var countriesWithEnemyNeighbours = countriesToAimAt.Where(x => gameInformation.GetAdjacentCountriesWithDifferentOwner(x).Count > 0) .ToArray(); var defensiveRates = GetDefensiveRates(countriesWithEnemyNeighbours).OrderBy(x => x.Value); while (defensiveRates.First().Value < DEFENSIVE_THRESHOLD_FOR_DEPLOYMENT && numberOfTroops > 0) { turnManager.DeployTroops(defensiveRates.First().Key, 1); defensiveRates = GetDefensiveRates(countriesWithEnemyNeighbours).OrderByDescending(x => x.Value); numberOfTroops--; } //Get the continent with the biggest presence. //Determine what country has the highest defensiveRate (number of own troops / number of surrounding troups), make those even stronger. //Make sure this ratio is not too big. var biggestContinent = GetBiggestOwnedContinentWithRemainingEnemyCountries(); var allOwnCountriesInBiggestContinent = countriesToAimAt.Where(x => x.Continent == biggestContinent.Key).ToArray(); var countriesWithRates = GetDefensiveRates(allOwnCountriesInBiggestContinent) .Where(x => x.Key.NumberOfTroops < MAX_TROOPS_FOR_DEPLOYMENT) .OrderByDescending(x => x.Value); while (countriesWithRates.Any() && numberOfTroops > 0) { turnManager.DeployTroops(countriesWithRates.First().Key, 1); countriesWithRates = GetDefensiveRates(allOwnCountriesInBiggestContinent) .Where(x => x.Key.NumberOfTroops < MAX_TROOPS_FOR_DEPLOYMENT) .OrderByDescending(x => x.Value); numberOfTroops--; } while (numberOfTroops > 0) { turnManager.DeployTroops(GetRandomOwnedCountry(turnManager), 1); numberOfTroops--; } }
/* DONT LOOK AT OUR CODE PLS */ public void Deploy(TurnManager turnManager, int numberOfTroops) { if (numberOfTroops == 2) { var tempList = turnManager.GetGameInfo().GetAllCountriesOwnedByPlayer(this); var Australia = tempList.Where(p => p.Continent == EContinent.Australia).ToList(); var SouthAmerica = tempList.Where(p => p.Continent == EContinent.SouthAmerica).ToList(); var Africa = tempList.Where(p => p.Continent == EContinent.Africa).ToList(); var NorthAmerica = tempList.Where(p => p.Continent == EContinent.NorthAmerica).ToList(); var Europe = tempList.Where(p => p.Continent == EContinent.Europe).ToList(); var Asia = tempList.Where(p => p.Continent == EContinent.Asia).ToList(); var AustraliaCount = Australia.Count; if (Australia.Count >= 2) { if (AustraliaCount == 4) { var AustraliaBottleNeck = tempList.Where(p => p.Continent == EContinent.Australia && p.Number == 4).Single(); var i = AustraliaBottleNeck.AdjacentCountries.Where(p => p.Owner != this).ToList(); while (AustraliaBottleNeck.NumberOfTroops < 10 && numberOfTroops > 0 && i.Count > 0) { turnManager.DeployTroops(AustraliaBottleNeck, 1); numberOfTroops--; } } else { var Random = new Random(); var AustraliaBottleNeck = tempList.Where(p => p.Continent == EContinent.Australia); if (AustraliaBottleNeck != null) { var index = Random.Next(Australia.Count); var country = Australia[index]; var i = country.AdjacentCountries.Where(p => p.Owner != this).ToList(); while (country.NumberOfTroops < 10 && numberOfTroops > 0 && i.Count > 0) { turnManager.DeployTroops(country, 1); numberOfTroops--; } } } } if (SouthAmerica.Count >= 2) { var Random = new Random(); var SouthAmericaBottleNeck = tempList.Where(p => p.Continent == EContinent.SouthAmerica); if (SouthAmericaBottleNeck != null) { var index = Random.Next(SouthAmerica.Count); var country = SouthAmerica[index]; var i = country.AdjacentCountries.Where(p => p.Owner != this).ToList(); while (country.NumberOfTroops < 10 && numberOfTroops > 0 && i.Count > 0) { turnManager.DeployTroops(country, 1); numberOfTroops--; } } } if (Africa.Count >= 4) { var Random = new Random(); var AfricaBottleNeck = tempList.Where(p => p.Continent == EContinent.Africa); if (AfricaBottleNeck != null) { var index = Random.Next(Africa.Count); var country = Africa[index]; var i = country.AdjacentCountries.Where(p => p.Owner != this).ToList(); while (country.NumberOfTroops < 10 && numberOfTroops > 0 && i.Count > 0) { turnManager.DeployTroops(country, 1); numberOfTroops--; } } } if (NorthAmerica.Count >= 5) { var Random = new Random(); var AfricaBottleNeck = tempList.Where(p => p.Continent == EContinent.NorthAmerica); if (AfricaBottleNeck != null) { var index = Random.Next(NorthAmerica.Count); var country = NorthAmerica[index]; var i = country.AdjacentCountries.Where(p => p.Owner != this).ToList(); while (country.NumberOfTroops < 10 && numberOfTroops > 0 && i.Count > 0) { turnManager.DeployTroops(country, 1); numberOfTroops--; } } } if (Europe.Count >= 7) { var Random = new Random(); var AfricaBottleNeck = tempList.Where(p => p.Continent == EContinent.Europe); if (AfricaBottleNeck != null) { var index = Random.Next(Europe.Count); var country = Europe[index]; var i = country.AdjacentCountries.Where(p => p.Owner != this).ToList(); while (country.NumberOfTroops < 10 && numberOfTroops > 0 && i.Count > 0) { turnManager.DeployTroops(country, 1); numberOfTroops--; } } } if (Asia.Count >= 8) { var Random = new Random(); var AfricaBottleNeck = tempList.Where(p => p.Continent == EContinent.Asia); if (AfricaBottleNeck != null) { var index = Random.Next(Asia.Count); var country = Asia[index]; var i = country.AdjacentCountries.Where(p => p.Owner != this).ToList(); while (country.NumberOfTroops < 10 && numberOfTroops > 0 && i.Count > 0) { turnManager.DeployTroops(country, 1); numberOfTroops--; } } } while (numberOfTroops > 0) { var target = GetRandomOwnedCountry(turnManager); var i = target.AdjacentCountries.Where(p => p.Owner != this).ToList(); if (i.Count > 0) { if (target.NumberOfTroops < 7) { var z = 0; while (numberOfTroops > 0) { turnManager.DeployTroops(GetRandomOwnedCountry(turnManager), 1); z++; numberOfTroops--; if (z > 30) { break; } } } else { break; } } else { break; } } while (numberOfTroops > 0) { turnManager.DeployTroops(GetRandomOwnedCountry(turnManager), 1); numberOfTroops--; } } else { var myCountries = turnManager.GetGameInfo().GetAllCountriesOwnedByPlayer(this); var potential = new List<Country>(); foreach (var country in myCountries) { if (country.AdjacentCountries.Where(p => p.Owner != this).ToList().Count > 0) { potential.Add(country); } } var tempList = potential.OrderBy(p => p.NumberOfTroops).ToList(); foreach (var countryy in tempList) { while (countryy.NumberOfTroops < 10 && numberOfTroops > 0) { turnManager.DeployTroops(countryy, 1); numberOfTroops--; } } if (numberOfTroops > 0) { foreach (var countryy in tempList) { while (numberOfTroops > 0) { turnManager.DeployTroops(countryy, 1); numberOfTroops--; } } } } }