public void Update(CGameAIManager _gameAIManager) { //this.gameAIManager_.Update(this); foreach (CFaction faction in this.factions_) { faction.Update(this.gameTurn_, _gameAIManager); } this.gameTurn_++; }
public void Execute(CGameAIManager _gameAIManager) { CArmy defendingArmy = _gameAIManager.GetDefendingArmy(this.targetCityID_, this.battle_.Armies[0]); this.battle_.AddArmy2(defendingArmy); //to implement ... // 1. Update this.battle_ until it is ended // 2. Update stats for two cities while (!this.battle_.IsBattleEnd) { } }
public void Update(int _gameTurn, CGameAIManager _gameAIManager) { if (this.controlledByPlayer_) { } else { foreach (CCity city in this.cities_) { city.PushGameCommands(_gameAIManager.GetGameCommand(city.ID)); } } foreach (CCity city in this.cities_) { city.Update(_gameTurn, _gameAIManager); } }
public void Execute(CGameAIManager _gameAIManager) { }
private void Initialize() { game_ = new CGame(); game_.CreateGame(10, 10); gameUIManager_ = new CGameUIManager(); gameAIManager_ = new CGameAIManager(this.game_); gameUIManager_.AddUI(new CUIMapRenderer(this.game_)); StreamWriter sw = new StreamWriter(new FileStream("gameMap.txt", FileMode.Create)); sw.Write(game_.ToString()); while (game_.GameTurn < 100) { //sw.Write(game_.ToString()); game_.Update(gameAIManager_); } sw.Write(game_.ToString()); sw.Close(); //CArmy army1 = new CArmy(); //army1.Faction = game_.GetFactionByIndex(0); //army1.City = army1.Faction.Cities[0]; //army1.City.CityDefence = 200; //army1.Status = 0; //CTroop troop1 = new CTroop(); //troop1.Character = army1.Faction.Characters[0]; //troop1.Faction = army1.Faction; //troop1.Soldier = 120; //troop1.Morale = 100; //troop1.InjuredSoldier = 0; //CTroop troop2 = new CTroop(); //troop2.Character = army1.Faction.Characters[1]; //troop2.Faction = army1.Faction; //troop2.Soldier = 130; //troop2.Morale = 100; //troop2.InjuredSoldier = 0; //CTroop troop3 = new CTroop(); //troop3.Character = army1.Faction.Characters[2]; //troop3.Faction = army1.Faction; //troop3.Soldier = 150; //troop3.Morale = 100; //troop3.InjuredSoldier = 0; //army1.AddTroop(troop1); //army1.AddTroop(troop2); //army1.AddTroop(troop3); //CArmy army2 = new CArmy(); //army2.Faction = game_.GetFactionByIndex(1); //army2.City = army2.Faction.Cities[0]; //army2.Status = 0; //CTroop troop4 = new CTroop(); //troop4.Character = army2.Faction.Characters[0]; //troop4.Faction = army2.Faction; //troop4.Soldier = 500; //troop4.Morale = 100; //troop4.InjuredSoldier = 0; //CTroop troop5 = new CTroop(); //troop5.Character = army2.Faction.Characters[1]; //troop5.Faction = army2.Faction; //troop5.Soldier = 500; //troop5.Morale = 100; //troop5.InjuredSoldier = 0; //CTroop troop6 = new CTroop(); //troop6.Character = army2.Faction.Characters[2]; //troop6.Faction = army2.Faction; //troop6.Soldier = 500; //troop6.Morale = 100; //troop6.InjuredSoldier = 0; //army2.AddTroop(troop4); //army2.AddTroop(troop5); //army2.AddTroop(troop6); //CBattle battle = new CBattle(); //battle.AddArmy(army1); //battle.AddArmy(army2); //sw = new StreamWriter(new FileStream("gameBattle.txt", FileMode.Create)); //while (!battle.IsBattleEnd) //{ // sw.WriteLine("========== 回合 =========="); // sw.WriteLine(battle.ToString()); // battle.Update(); //} //sw.WriteLine("========== 回合 =========="); //sw.WriteLine(battle.ToString()); //sw.Close(); }
public void Execute(CGameAIManager _gameAIManager) { throw new NotImplementedException(); }
public void Execute(CGameAIManager _gameAIManager) { if (this.city_.Gold >= this.goldCost_ && !this.character_.HasMission) { this.city_.Gold -= this.goldCost_; this.character_.HasMission = true; if (this.character_.LeaderShip <= 5) { if (this.character_.Politics <= 10) { this.city_.FoodIncreaseRate += 0.01; } else if (this.character_.Politics <= 16) { this.city_.FoodIncreaseRate += 0.02; } else if (this.character_.Politics <= 20) { this.city_.FoodIncreaseRate += 0.03; } } else if (this.character_.LeaderShip <= 9) { if (this.character_.Politics <= 9) { this.city_.FoodIncreaseRate += 0.01; } else if (this.character_.Politics <= 14) { this.city_.FoodIncreaseRate += 0.02; } else if (this.character_.Politics <= 18) { this.city_.FoodIncreaseRate += 0.03; } else if (this.character_.Politics <= 20) { this.city_.FoodIncreaseRate += 0.04; } } else if (this.character_.LeaderShip <= 12) { if (this.character_.Politics <= 8) { this.city_.FoodIncreaseRate += 0.01; } else if (this.character_.Politics <= 12) { this.city_.FoodIncreaseRate += 0.02; } else if (this.character_.Politics <= 16) { this.city_.FoodIncreaseRate += 0.03; } else if (this.character_.Politics <= 18) { this.city_.FoodIncreaseRate += 0.04; } else if (this.character_.Politics <= 20) { this.city_.FoodIncreaseRate += 0.05; } } else if (this.character_.LeaderShip <= 15) { if (this.character_.Politics <= 7) { this.city_.FoodIncreaseRate += 0.01; } else if (this.character_.Politics <= 10) { this.city_.FoodIncreaseRate += 0.02; } else if (this.character_.Politics <= 15) { this.city_.FoodIncreaseRate += 0.03; } else if (this.character_.Politics <= 17) { this.city_.FoodIncreaseRate += 0.04; } else if (this.character_.Politics <= 19) { this.city_.FoodIncreaseRate += 0.05; } else if (this.character_.Politics <= 20) { this.city_.FoodIncreaseRate += 0.06; } } else if (this.character_.LeaderShip <= 18) { if (this.character_.Politics <= 6) { this.city_.FoodIncreaseRate += 0.01; } else if (this.character_.Politics <= 8) { this.city_.FoodIncreaseRate += 0.02; } else if (this.character_.Politics <= 10) { this.city_.FoodIncreaseRate += 0.03; } else if (this.character_.Politics <= 12) { this.city_.FoodIncreaseRate += 0.04; } else if (this.character_.Politics <= 14) { this.city_.FoodIncreaseRate += 0.05; } else if (this.character_.Politics <= 16) { this.city_.FoodIncreaseRate += 0.06; } else if (this.character_.Politics <= 17) { this.city_.FoodIncreaseRate += 0.07; } else if (this.character_.Politics <= 18) { this.city_.FoodIncreaseRate += 0.08; } else if (this.character_.Politics <= 19) { this.city_.FoodIncreaseRate += 0.09; } else if (this.character_.Politics <= 20) { this.city_.FoodIncreaseRate += 0.1; } } else if (this.character_.LeaderShip <= 20) { if (this.character_.Politics <= 5) { this.city_.FoodIncreaseRate += 0.01; } else if (this.character_.Politics <= 7) { this.city_.FoodIncreaseRate += 0.02; } else if (this.character_.Politics <= 9) { this.city_.FoodIncreaseRate += 0.03; } else if (this.character_.Politics <= 11) { this.city_.FoodIncreaseRate += 0.04; } else if (this.character_.Politics <= 12) { this.city_.FoodIncreaseRate += 0.05; } else if (this.character_.Politics <= 13) { this.city_.FoodIncreaseRate += 0.06; } else if (this.character_.Politics <= 14) { this.city_.FoodIncreaseRate += 0.07; } else if (this.character_.Politics <= 15) { this.city_.FoodIncreaseRate += 0.08; } else if (this.character_.Politics <= 16) { this.city_.FoodIncreaseRate += 0.09; } else if (this.character_.Politics <= 17) { this.city_.FoodIncreaseRate += 0.1; } else if (this.character_.Politics <= 18) { this.city_.FoodIncreaseRate += 0.11; } else if (this.character_.Politics <= 19) { this.city_.FoodIncreaseRate += 0.12; } else if (this.character_.Politics <= 20) { this.city_.FoodIncreaseRate += 0.13; } } } }
public void Update(int _gameTurn, CGameAIManager _gameAIManager) { foreach (CCharacter character in this.characters_) { character.HasMission = false; } foreach (IGameCommand gameCommand in this.gameCommands_) { gameCommand.Execute(_gameAIManager); } this.gameCommands_.Clear(); // food updates int foodConsumption = (int)Math.Ceiling(this.population_ * this.foodConsumpRate_); int foodIncrease = 0; // check food increase every month (6 turns) if (_gameTurn % 6 == 0) { // food increase rate is doubled in autumn if (_gameTurn % 72 > 36 && _gameTurn % 72 < 55) { foodIncrease = (int)Math.Ceiling(Math.Min(this.population_ - this.soldier_, this.maxAgriculturePopulation_) * this.foodIncRate_ * 2); } else { foodIncrease = (int)Math.Ceiling(Math.Min(this.population_ - this.soldier_, this.maxAgriculturePopulation_) * this.foodIncRate_); } } this.food_ += foodIncrease - foodConsumption; int foodShortage = 0; if (this.food_ < 0) { foodShortage = -this.food_; this.food_ = 0; } // population increases as long as city has food remaining, // and decreases once city runs out of food if (this.food_ > 0) { // check population increase every month (6 turns) if (_gameTurn % 6 == 0) { this.population_ += (int)Math.Ceiling(Math.Min(this.population_ - this.soldier_, this.maxAgriculturePopulation_) * this.foodIncRate_ / 15.0); } } else { // check population decrease every 5 days (1 turn) this.population_ = Math.Max(this.population_ - (int)Math.Ceiling(foodShortage / 1.5), 0); this.soldier_ = Math.Max(this.soldier_ - (int)Math.Ceiling(foodShortage / 1.5), 0); } // gold updates // check gold increase every 5 days (1 turn) // gold increase rate is doubled in winter if (_gameTurn % 72 > 54 && _gameTurn % 72 <= 71) { this.gold_ += (int)Math.Ceiling(Math.Max(Math.Min(this.population_ - this.soldier_, this.maxAgriculturePopulation_) * this.foodIncRate_ / 6.0 - foodConsumption, 0) * this.goldIncRate_ * 2); } else { this.gold_ += (int)Math.Ceiling(Math.Max(Math.Min(this.population_ - this.soldier_, this.maxAgriculturePopulation_) * this.foodIncRate_ / 6.0 - foodConsumption, 0) * this.goldIncRate_); } }
public void Execute(CGameAIManager _gameAIManager) { if (this.city_.Gold >= this.goldCost_ && !this.character_.HasMission) { this.city_.Gold -= this.goldCost_; this.character_.HasMission = true; if (this.character_.LeaderShip <= 5) { if (this.character_.Politics <= 10) { this.city_.Soldier += 100; } else if (this.character_.Politics <= 16) { this.city_.Soldier += 110; } else if (this.character_.Politics <= 20) { this.city_.Soldier += 120; } } else if (this.character_.LeaderShip <= 9) { if (this.character_.Politics <= 9) { this.city_.Soldier += 100; } else if (this.character_.Politics <= 14) { this.city_.Soldier += 110; } else if (this.character_.Politics <= 18) { this.city_.Soldier += 120; } else if (this.character_.Politics <= 20) { this.city_.Soldier += 130; } } else if (this.character_.LeaderShip <= 12) { if (this.character_.Politics <= 8) { this.city_.Soldier += 100; } else if (this.character_.Politics <= 12) { this.city_.Soldier += 110; } else if (this.character_.Politics <= 16) { this.city_.Soldier += 120; } else if (this.character_.Politics <= 18) { this.city_.Soldier += 130; } else if (this.character_.Politics <= 20) { this.city_.Soldier += 140; } } else if (this.character_.LeaderShip <= 15) { if (this.character_.Politics <= 7) { this.city_.Soldier += 100; } else if (this.character_.Politics <= 10) { this.city_.Soldier += 110; } else if (this.character_.Politics <= 15) { this.city_.Soldier += 120; } else if (this.character_.Politics <= 17) { this.city_.Soldier += 130; } else if (this.character_.Politics <= 19) { this.city_.Soldier += 140; } else if (this.character_.Politics <= 20) { this.city_.Soldier += 150; } } else if (this.character_.LeaderShip <= 18) { if (this.character_.Politics <= 6) { this.city_.Soldier += 100; } else if (this.character_.Politics <= 8) { this.city_.Soldier += 110; } else if (this.character_.Politics <= 10) { this.city_.Soldier += 120; } else if (this.character_.Politics <= 12) { this.city_.Soldier += 130; } else if (this.character_.Politics <= 14) { this.city_.Soldier += 140; } else if (this.character_.Politics <= 16) { this.city_.Soldier += 150; } else if (this.character_.Politics <= 17) { this.city_.Soldier += 160; } else if (this.character_.Politics <= 18) { this.city_.Soldier += 170; } else if (this.character_.Politics <= 19) { this.city_.Soldier += 180; } else if (this.character_.Politics <= 20) { this.city_.Soldier += 190; } } else if (this.character_.LeaderShip <= 20) { if (this.character_.Politics <= 5) { this.city_.Soldier += 100; } else if (this.character_.Politics <= 7) { this.city_.Soldier += 110; } else if (this.character_.Politics <= 9) { this.city_.Soldier += 120; } else if (this.character_.Politics <= 11) { this.city_.Soldier += 130; } else if (this.character_.Politics <= 12) { this.city_.Soldier += 140; } else if (this.character_.Politics <= 13) { this.city_.Soldier += 150; } else if (this.character_.Politics <= 14) { this.city_.Soldier += 160; } else if (this.character_.Politics <= 15) { this.city_.Soldier += 170; } else if (this.character_.Politics <= 16) { this.city_.Soldier += 180; } else if (this.character_.Politics <= 17) { this.city_.Soldier += 190; } else if (this.character_.Politics <= 18) { this.city_.Soldier += 200; } else if (this.character_.Politics <= 19) { this.city_.Soldier += 210; } else if (this.character_.Politics <= 20) { this.city_.Soldier += 220; } } } }
public void Execute(CGameAIManager _gameAIManager) { if (this.city_.Gold >= this.goldCost_ && !this.character_.HasMission) { this.city_.Gold -= this.goldCost_; this.character_.HasMission = true; if (this.character_.Stratagem <= 5) { if (this.character_.Politics <= 10) { this.city_.CityDefence += 50; } else if (this.character_.Politics <= 16) { this.city_.CityDefence += 100; } else if (this.character_.Politics <= 20) { this.city_.CityDefence += 150; } } else if (this.character_.Stratagem <= 9) { if (this.character_.Politics <= 9) { this.city_.CityDefence += 50; } else if (this.character_.Politics <= 14) { this.city_.CityDefence += 100; } else if (this.character_.Politics <= 18) { this.city_.CityDefence += 150; } else if (this.character_.Politics <= 20) { this.city_.CityDefence += 200; } } else if (this.character_.Stratagem <= 12) { if (this.character_.Politics <= 8) { this.city_.CityDefence += 50; } else if (this.character_.Politics <= 12) { this.city_.CityDefence += 100; } else if (this.character_.Politics <= 16) { this.city_.CityDefence += 150; } else if (this.character_.Politics <= 18) { this.city_.CityDefence += 200; } else if (this.character_.Politics <= 20) { this.city_.CityDefence += 250; } } else if (this.character_.Stratagem <= 15) { if (this.character_.Politics <= 7) { this.city_.CityDefence += 50; } else if (this.character_.Politics <= 10) { this.city_.CityDefence += 100; } else if (this.character_.Politics <= 15) { this.city_.CityDefence += 150; } else if (this.character_.Politics <= 17) { this.city_.CityDefence += 200; } else if (this.character_.Politics <= 19) { this.city_.CityDefence += 250; } else if (this.character_.Politics <= 20) { this.city_.CityDefence += 300; } } else if (this.character_.Stratagem <= 18) { if (this.character_.Politics <= 6) { this.city_.CityDefence += 50; } else if (this.character_.Politics <= 8) { this.city_.CityDefence += 100; } else if (this.character_.Politics <= 10) { this.city_.CityDefence += 150; } else if (this.character_.Politics <= 12) { this.city_.CityDefence += 200; } else if (this.character_.Politics <= 14) { this.city_.CityDefence += 250; } else if (this.character_.Politics <= 16) { this.city_.CityDefence += 300; } else if (this.character_.Politics <= 17) { this.city_.CityDefence += 350; } else if (this.character_.Politics <= 18) { this.city_.CityDefence += 400; } else if (this.character_.Politics <= 19) { this.city_.CityDefence += 450; } else if (this.character_.Politics <= 20) { this.city_.CityDefence += 500; } } else if (this.character_.Stratagem <= 20) { if (this.character_.Politics <= 5) { this.city_.CityDefence += 50; } else if (this.character_.Politics <= 7) { this.city_.CityDefence += 100; } else if (this.character_.Politics <= 9) { this.city_.CityDefence += 150; } else if (this.character_.Politics <= 11) { this.city_.CityDefence += 200; } else if (this.character_.Politics <= 12) { this.city_.CityDefence += 250; } else if (this.character_.Politics <= 13) { this.city_.CityDefence += 300; } else if (this.character_.Politics <= 14) { this.city_.CityDefence += 350; } else if (this.character_.Politics <= 15) { this.city_.CityDefence += 400; } else if (this.character_.Politics <= 16) { this.city_.CityDefence += 450; } else if (this.character_.Politics <= 17) { this.city_.CityDefence += 500; } else if (this.character_.Politics <= 18) { this.city_.CityDefence += 550; } else if (this.character_.Politics <= 19) { this.city_.CityDefence += 600; } else if (this.character_.Politics <= 20) { this.city_.CityDefence += 650; } } } }