function Analyzer::getInterestRate(%player)
{
   // get opponent
   %opponent = %player.getOpponent();
   
   // get all resource fields
   %allResourceFields = resControl.getResourceFields();
   %allResourceFieldCount = getWordCount(%allResourceFields);

   
   // determine interest rate for each field
   %maximumInterestRate = 0;
   %maximumInterestField = "";
   for(%i = 0; %i < %allResourceFieldCount; %i++)
   {
      // initialize data for this field
      %currentField = getWord(%allResourceFields, %i);
      %interestRateInCurrentField = 0;
      
      // get field owner
      %fieldowner = %currentField.getOwner();
      %fieldownerId = "";
      if(isObject(%fieldowner))
         %fieldownerId = %fieldowner.getId();
         
      if(%fieldownerId == %player.getId())  // the field is owned by this player
      {
         if(%currentField.getOwningTimeLeft() <= mMax($pref::Game::ResourceGainTick - resControl.getResourceBonus(%player) SPC $pref::Game::MinimumResourceGainTick) * ($pref::Game::ResourceLimit - %player.getResource()))  // this field is about to run out of owning time
            %interestRateInCurrentField = $pref::Game::OpponentAIRefreshInterestRate;
         else  // enough owning time left, determine maintenance interest
         {
            // determine closest opposing field name
            %closestOpposingField = Pathfinding::getClosestOpposingField(%player, %currentField);
            %distanceToOpposingField = Pathfinding::getFieldDistance(%currentField, %closestOpposingField);
            
            // calculate maintenance interest in field
            %neighborAssistDiff = %currentField.getCountOfOwnedNeighbors(%opponent) - %currentField.getCountOfOwnedNeighbors(%player);
            %interestRateInCurrentField = $pref::Game::OpponentAIBaseResourceMaintenanceInterest - %distanceToOpposingField * $pref::Game::OpponentAIResourceMaintenanceDistanceModifier + %neighborAssistDiff * $pref::Game::OpponentAIResourceMaintenanceAssistModifier;
         }
      }
      else if(%fieldownerId == %opponent.getId())  // the field is owned by the opponent
      {
         // determine closest owned field and distance
         %closestOwnedField = Pathfinding::getClosestOwnedField(%player, %currentField);
         %distanceToOwnedField = Pathfinding::getFieldDistance(%currentField, %closestOwnedField);
         
         // calculate economic interest in field
         %muliplier = 1;
         switch$(%currentField.getSpecial())
         {
            case "resource1":
               %muliplier = $pref::Game::OpponentAIResource1InterestMultiplier;
               
            case "resource2":
               %muliplier = $pref::Game::OpponentAIResource2InterestMultiplier;
            
            case "resource3":
               %muliplier = $pref::Game::OpponentAIResource3InterestMultiplier;
         }
         
         %playerResourceTick = mMax($pref::Game::ResourceGainTick - resControl.getResourceBonus(%player) SPC $pref::Game::MinimumResourceGainTick);
         %opponentResourceTick = mMax($pref::Game::ResourceGainTick - resControl.getResourceBonus(%opponent) SPC $pref::Game::MinimumResourceGainTick);
         %resourceTickRatio = %playerResourceTick / %opponentResourceTick;
         
         %interestRateInCurrentField = mMax((($pref::Game::OpponentAIBaseResourceInterest * %muliplier - %distanceToOwnedField * $pref::Game::OpponentAIResourceInterestDistanceMalus) * %resourceTickRatio) / 2 SPC 0);
      }
      else  // neutral field
      {
         // determine closest owned field and distance
         %closestOwnedField = Pathfinding::getClosestOwnedField(%player, %currentField);
         %distanceToOwnedField = Pathfinding::getFieldDistance(%currentField, %closestOwnedField);
         
         // calculate economic interest in field
         %muliplier = 1;
         switch$(%currentField.getSpecial())
         {
            case "resource1":
               %muliplier = $pref::Game::OpponentAIResource1InterestMultiplier;
               
            case "resource2":
               %muliplier = $pref::Game::OpponentAIResource2InterestMultiplier;
            
            case "resource3":
               %muliplier = $pref::Game::OpponentAIResource3InterestMultiplier;
         }
         
         %playerResourceTick = mMax($pref::Game::ResourceGainTick - resControl.getResourceBonus(%player) SPC $pref::Game::MinimumResourceGainTick);
         %opponentResourceTick = mMax($pref::Game::ResourceGainTick - resControl.getResourceBonus(%opponent) SPC $pref::Game::MinimumResourceGainTick);
         %resourceTickRatio = %playerResourceTick / %opponentResourceTick;
         
         %interestRateInCurrentField = mMax((($pref::Game::OpponentAIBaseResourceInterest * %muliplier - %distanceToOwnedField * $pref::Game::OpponentAIResourceInterestDistanceMalus) * %resourceTickRatio) SPC 0);
      }
      
      // update maximum threat
      if(%interestRateInCurrentField > %maximumInterestRate)
      {
         %maximumInterestRate = %interestRateInCurrentField;
         %maximumInterestField = %currentField;
      }
   }
   
   
   // rate interest in own base
   %playerMainBase = %player.getMainBase();
   
   // determine closest opposing field name
   %closestOpposingField = Pathfinding::getClosestOpposingField(%player, %playerMainBase);
   %distanceToOpposingField = Pathfinding::getFieldDistance(%playerMainBase, %closestOpposingField);
            
   // calculate maintenance interest in field
   %neighborAssistDiff = %playerMainBase.getCountOfOwnedNeighbors(%opponent) - %playerMainBase.getCountOfOwnedNeighbors(%player);
   %interestRateInCurrentField = $pref::Game::OpponentAIBaseMainBaseMaintenanceInterest - %distanceToOpposingField * $pref::Game::OpponentAIMainBaseMaintenanceDistanceModifier + %neighborAssistDiff * $pref::Game::OpponentAIMainBaseMaintenanceAssistModifier;
   
   // update maximum threat
   if(%interestRateInCurrentField > %maximumInterestRate)
   {
      %maximumInterestRate = %interestRateInCurrentField;
      %maximumInterestField = %playerMainBase;
   }
   
   
   // rate interest in opponent base
   %opponentMainBase = %opponent.getMainBase();
   
   // eliminate opponent whenever possible
   if(%opponentMainBase.areConquerRequirementsMet(%player)
      && %opponentMainBase.getConquerCost(%player) <= %player.getActions())
   {
      %maximumInterestRate = $pref::Game::OpponentAIDeathStrikeInterest;
      %maximumInterestField = %opponentMainBase;
   }
   else  // no direct strike possible
   {
      // determine closest owned field and distance
      %closestOwnedField = Pathfinding::getClosestOwnedField(%player, %opponentMainBase);
      %distanceToOwnedField = Pathfinding::getFieldDistance(%opponentMainBase, %closestOwnedField);
               
      // calculate maintenance interest in field
      %playerResourceTick = mMax($pref::Game::ResourceGainTick - resControl.getResourceBonus(%player) SPC $pref::Game::MinimumResourceGainTick);
      %opponentResourceTick = mMax($pref::Game::ResourceGainTick - resControl.getResourceBonus(%opponent) SPC $pref::Game::MinimumResourceGainTick);
      %resourceTickRatio = %playerResourceTick / %opponentResourceTick;

      %neighborAssistDiff = %playerMainBase.getCountOfOwnedNeighbors(%opponent) - %playerMainBase.getCountOfOwnedNeighbors(%player);

      %interestRateInCurrentField = ($pref::Game::OpponentAIBaseAttackInterest - %distanceToOwnedField * $pref::Game::OpponentAIBaseAttackInterestDistanceModifier + %neighborAssistDiff * $pref::Game::OpponentAIBaseAttackInterestAssistModifier) * %resourceTickRatio;

      // update maximum threat
      if(%interestRateInCurrentField > %maximumInterestRate)
      {
         %maximumInterestRate = %interestRateInCurrentField;
         %maximumInterestField = %opponentMainBase;
      }
   }
   
   return %maximumInterestRate SPC %maximumInterestField;
}