anchor.diff:  
   
   procedure TKMayor.BuildCore;
  -var
  -  StoreBalance, SchoolBalance, InnBalance,
  -  QuaryBalance, WoodBalance, SawmillBalance,
  -  BarracksBalance: Single;
  -begin
  -  //Balance          //Exists                     //Demand
  -  StoreBalance    := HouseCount(ht_Store)       - HouseCount(ht_Any) / 35;
  -  SchoolBalance   := HouseCount(ht_School)      - 1;
  -  InnBalance      := HouseCount(ht_Inn)         - fPlayers[fOwner].Stats.GetCitizensCount / 80;
  -  QuaryBalance    := HouseCount(ht_Quary)       - 3 * Byte(HouseCount(ht_Inn) >= 1);
  -  WoodBalance     := HouseCount(ht_Woodcutters) - 4 * Byte(HouseCount(ht_Quary) >= 3);
  -  SawmillBalance  := HouseCount(ht_Sawmill)     - 2 * Byte(HouseCount(ht_Woodcutters) >= 2);
  -  BarracksBalance := HouseCount(ht_Barracks)    - Byte(fPlayers[fOwner].Stats.GetWeaponsProduced > 0);
  -
  -  if Min([StoreBalance, SchoolBalance, InnBalance, QuaryBalance, WoodBalance, SawmillBalance, BarracksBalance]) >= 0 then Exit;
  -
  +begin
  +  with fDemandCore do
     case PickMin([StoreBalance, SchoolBalance, InnBalance, QuaryBalance, WoodBalance, SawmillBalance, BarracksBalance]) of
       0:  TryBuildHouse(ht_Store);
       1:  TryBuildHouse(ht_School);
  
positive.code:   KM_AISetup;
  
  type
    TKMWareBalanceGold = record
      CoalTheory, GoldOreTheory, GoldTheory: Single;
      Production: Single; //How much do we produce
  
negative.code:   //Try to express needs
    CalculateBalance;
  
    case PickMin([0, fDemandCore.Balance * 100, fDemandGold.Balance * 10, fDemandFood.Balance * 5, fDemandWeaponry.Balance]) of
      0:  {BuildNothing};
      1:  BuildCore;
      2:  BuildMoreGold;
  