示例#1
0
		protected void AddArmyAttackVariant(AIVariantPackage variants, Context context, PlayerInfoCM player, AIOptions options, int restUnits)
		{
			List<IslandCM> enemyNeibourIslands = Library.Map.GetEnemyNeibourIslands(context.map, player.ID, true);
			float maxAttackVP = 0;
			IslandCM maxVPenemyIsland = null;
			for (int i = 0; i < enemyNeibourIslands.Count; ++i)
			{
				IslandCM enemyIsland = enemyNeibourIslands[i];
				float vp = Library.Map.GetIslandPriceVP(context.map, enemyIsland.ID, player.ID, options);
				if (vp > maxAttackVP)
				{
					maxAttackVP = vp;
					maxVPenemyIsland = enemyIsland;
				}
			}

			if (maxAttackVP > 0)
			{
				int needForce = Library.Map.GetForceNeedToCapture(context.map, maxVPenemyIsland.ID, options.coefficients.MinProbToAttackIsland);
				int needGold = Library.Common.CostOfArmy(needForce, context.turn.TurnActionCounter) + Constants.moveArmyCost;
				if (needForce <= restUnits && needGold <= player.Gold)
				{
					List<IslandCM> ourIslands = context.map.GetBridgetIslands(maxVPenemyIsland.ID, player.ID);
					int islandFromID = ourIslands.First().ID;

					AIArmyAttackVariant attackVariant = new AIArmyAttackVariant(islandFromID, maxVPenemyIsland.ID, needForce, needForce);
					attackVariant.offer = new VariantOffer(needGold, maxAttackVP);

					variants.AddVariant(attackVariant);
				}
			}
		}
示例#2
0
		protected void AddArmyVariant(AIVariantPackage variants, Context context, PlayerInfoCM player, AIOptions options)
		{
			int restUnits = Math.Min(Constants.maxArmyCount - context.map.Army.Where(e => e.OwnerID == player.ID).Count(), Constants.armyPrices.Count - context.turn.TurnActionCounter);
			if (restUnits < 1)
				return;

			AddArmyAttackVariant(variants, context, player, options, restUnits);
			AddArmyDefenceVariant(variants, context, player, options, restUnits);
		}
示例#3
0
		protected void AddNavyAttackIslandVariant(AIVariantPackage variants, Context context, PlayerInfoCM player, AIOptions options, int restUnits)
		{
			List<IslandCM> enemyNeibourIslands = Library.Map.GetEnemyNeibourIslands(context.map, player.ID, false);
			float maxAttackVP = 0;
			IslandCM maxVPenemyIsland = null;
			for (int i = 0; i < enemyNeibourIslands.Count; ++i)
			{
				IslandCM enemyIsland = enemyNeibourIslands[i];
				float vp = Library.Map.GetIslandPriceVP(context.map, enemyIsland.ID, player.ID, options) * options.coefficients.BridgeToIslandPriceCoeff;
				if (vp > maxAttackVP)
				{
					maxAttackVP = vp;
					maxVPenemyIsland = enemyIsland;
				}
			}

			if (maxAttackVP > 0)
			{
				int needForce = 1;
				int needGold = Library.Common.CostOfNavy(needForce, context.turn.TurnActionCounter);
				if (needForce <= restUnits && needGold <= player.Gold)
				{
					List<IslandCM> neibourIslands = Library.Map.GetNeibourIslands(context.map, maxVPenemyIsland.ID);
					List<Hex> seas = context.map.GetSeasNearIsland(maxVPenemyIsland.ID);
					Hex h = null;

					for (int i = 0; i < neibourIslands.Count && h == null; ++i)
					{
						IslandCM island = neibourIslands[i];
						if (island.OwnerID != player.ID)
							continue;

						List<Hex> ourSeas = context.map.GetSeasNearIsland(island.ID);
						List<Hex> cells = seas.Intersect(ourSeas).ToList();
						for(int t = 0; t < cells.Count; ++t)
						{
							if (context.map.GetNavyCountByCell(cells[t]) == 0)
							{
								h = cells[t];
								break;
							}
						}
					}

					if (h != null)
					{
						AIBuyNavyVariant attackVariant = new AIBuyNavyVariant(h);
						attackVariant.offer = new VariantOffer(needGold, maxAttackVP);
						variants.AddVariant(attackVariant);
					}
				}
			}
		}
示例#4
0
		protected void AddBuyPriestVariant(AIVariantPackage variants, Context context, PlayerInfoCM player, AIOptions options)
		{
			if (context.turn.TurnActionCounter >= Constants.priestPrices.Count)
				return;

			int cost = Constants.priestPrices[context.turn.TurnActionCounter];
			if (cost > player.Gold)
				return;

			AIVariant variant = new AIVariant(new Cyclades.BuyPriest());

			VariantOffer offer = new VariantOffer(cost, options.coefficients.PriestVPT * options.turnsToEnd);
			variant.offer = offer;

			variants.AddVariant(variant);
		}
示例#5
0
		protected void AddArmyDefenceVariant(AIVariantPackage variants, Context context, PlayerInfoCM player, AIOptions options, int restUnits)
		{
		}
示例#6
0
		protected void AddMoveNavyVariant(AIVariantPackage variants, Context context, PlayerInfoCM player, AIOptions options)
		{
			variants.AddVariant(new AIVariant(new StopMoveNavy()));
		}
示例#7
0
		protected void AddNavyAttackHornVariant(AIVariantPackage variants, Context context, PlayerInfoCM player, AIOptions options, int restUnits)
		{
			Hex horn = Library.Map.GetAccessibleSeaHorns(context.map, player.ID, false, false).FirstOrDefault();
			if (horn == null)
				return;

			int needForce = 1;
			int needGold = Library.Common.CostOfArmy(needForce, context.turn.TurnActionCounter) + Constants.moveNavyCost;
			float vp = options.coefficients.HornVPT * options.turnsToEnd;

			if (needForce <= restUnits && needGold <= restUnits)
			{
				List<Hex> ourCoasts = context.map.GetAllPlayerCoast(player.ID);
				List<Hex> path = Library.Map.GetSeaPathToAnyPoint(context.map, player.ID, horn, ourCoasts);				

				if (path != null && path.Count > 0)
				{
					AINavyAttackVariant attackVariant = new AINavyAttackVariant(path, needForce, needForce);
					attackVariant.offer = new VariantOffer(needGold, vp);
					variants.AddVariant(attackVariant);
				}
			}
		}