AI & coping with Infrastructure Maintenance
Moderator: OpenTTD Developers
AI & coping with Infrastructure Maintenance
I'm very fond of the Infrastructure Maintenance addition in the latest stable release of OpenTTD, 1.3.0-alpha 1. It makes the game more difficult by making money less easy. However, I am under the impression that AI companies struggle to keep up with it. This can also be related to my early starts with weak engines and the AI choosing to overload trains so I'm curious what experiences other players have.
Re: AI & coping with Infrastructure Maintenance
Are you sure it was added in 1.3.0? It's already there in 1.2.3 if I'm not misunderstanding something.
As for AIs, I'm currenty running a test with infrastructure maintenance enabled, and it doesn't make much of a difference under easy settings. SimpleAI doesn't build huge networks anyway, so I'm not really surprised. It can also run a successful company under harder settings as well, although not with 100% probability...
As for AIs, I'm currenty running a test with infrastructure maintenance enabled, and it doesn't make much of a difference under easy settings. SimpleAI doesn't build huge networks anyway, so I'm not really surprised. It can also run a successful company under harder settings as well, although not with 100% probability...
Re: AI & coping with Infrastructure Maintenance
Hmm, haven't been playing OpenTTD for a while so you might be right on the version. I haven't added SimpleAI to my AI of choices, I'll see about testing it too.Brumi wrote:Are you sure it was added in 1.3.0? It's already there in 1.2.3 if I'm not misunderstanding something.
As for AIs, I'm currenty running a test with infrastructure maintenance enabled, and it doesn't make much of a difference under easy settings. SimpleAI doesn't build huge networks anyway, so I'm not really surprised. It can also run a successful company under harder settings as well, although not with 100% probability...
Re: AI & coping with Infrastructure Maintenance
Yes, some of my favorite AIs (NoCAB, Trans etc) have big problems with Infrastructure Maintenance. Mainly because of the expensive airports. Their first action after launch is to build two or even more airports, and then instantly go bankrupt. This repeats over and over again, until they somehow try a road transport.
For those who have problems with it:
I have written a utility method which checks if a certain amount of monthly maintenance costs can be afforded. It allows 50% of our income to be spent on maintenance.
The monthly maintenance costs of airports have been found out to be roundabout 500 * AIAirport.GetMaintenanceCostFactor(airportType).
For those who have problems with it:
I have written a utility method which checks if a certain amount of monthly maintenance costs can be afforded. It allows 50% of our income to be spent on maintenance.
The monthly maintenance costs of airports have been found out to be roundabout 500 * AIAirport.GetMaintenanceCostFactor(airportType).
Code: Select all
function MoneyUtil::CanAddMaintenanceCosts(costs) {
if(costs <= 500) {
return true;
}
local railCosts = AIInfrastructure.GetMonthlyInfrastructureCosts(AICompany.ResolveCompanyID(AICompany.COMPANY_SELF), AIInfrastructure.INFRASTRUCTURE_RAIL);
local signalCosts = AIInfrastructure.GetMonthlyInfrastructureCosts(AICompany.ResolveCompanyID(AICompany.COMPANY_SELF), AIInfrastructure.INFRASTRUCTURE_SIGNALS);
local roadCosts = AIInfrastructure.GetMonthlyInfrastructureCosts(AICompany.ResolveCompanyID(AICompany.COMPANY_SELF), AIInfrastructure.INFRASTRUCTURE_ROAD);
local canalCosts = AIInfrastructure.GetMonthlyInfrastructureCosts(AICompany.ResolveCompanyID(AICompany.COMPANY_SELF), AIInfrastructure.INFRASTRUCTURE_CANAL);
local stationCosts = AIInfrastructure.GetMonthlyInfrastructureCosts(AICompany.ResolveCompanyID(AICompany.COMPANY_SELF), AIInfrastructure.INFRASTRUCTURE_STATION);
local airportCosts = AIInfrastructure.GetMonthlyInfrastructureCosts(AICompany.ResolveCompanyID(AICompany.COMPANY_SELF), AIInfrastructure.INFRASTRUCTURE_AIRPORT);
local currentMonthlyCosts = railCosts+signalCosts+roadCosts+canalCosts+stationCosts+airportCosts;
local newMonthlyCosts = currentMonthlyCosts + costs;
local incomeLastYear =
AICompany.GetQuarterlyIncome(AICompany.COMPANY_SELF, AICompany.CURRENT_QUARTER+1) +
AICompany.GetQuarterlyIncome(AICompany.COMPANY_SELF, AICompany.CURRENT_QUARTER+2) +
AICompany.GetQuarterlyIncome(AICompany.COMPANY_SELF, AICompany.CURRENT_QUARTER+3) +
AICompany.GetQuarterlyIncome(AICompany.COMPANY_SELF, AICompany.CURRENT_QUARTER+4);
local maxPercentageOfIncome = 0.5;
return newMonthlyCosts < ((incomeLastYear/12) * maxPercentageOfIncome);
}
Re: AI & coping with Infrastructure Maintenance
Hello,
Thanks for bringing this to my attention. I'm currently implementing a patch to ensure that NoCAB takes maintenance costs into account. However, is there a page which explains the formula used? Because when I use the function AIAirport.GetMaintenanceCostFactor I get the value 7 for a small airport while the cost per month for the airport is 5538 / month (at least in my case). So how do I calculate that value?
Any insights into that would be greatly appreciated! Also it would be nice if the NoAI can have a function AIAirport.GetMaintenanceCost which does all the work for you instead of returning some magic number...
Bram
Thanks for bringing this to my attention. I'm currently implementing a patch to ensure that NoCAB takes maintenance costs into account. However, is there a page which explains the formula used? Because when I use the function AIAirport.GetMaintenanceCostFactor I get the value 7 for a small airport while the cost per month for the airport is 5538 / month (at least in my case). So how do I calculate that value?
Any insights into that would be greatly appreciated! Also it would be nice if the NoAI can have a function AIAirport.GetMaintenanceCost which does all the work for you instead of returning some magic number...
Bram
Re: AI & coping with Infrastructure Maintenance
So, how can AI figure out airport maintenance cost?
Let's say i guess that(with medium infrastructure cost setting):
... but how can AI find this 'base' 625 pounds? Seems like NewGRFs can change it so i'm asking.
Let's say i guess that(with medium infrastructure cost setting):
Code: Select all
monthly_airport_cost = 625 * AIAirport.GetMaintenanceCostFactor(airport_type);
Re: AI & coping with Infrastructure Maintenance
One workaround might be to get the monthly infrastructure costs (for infra_type INFRASTRUCTURE_AIRPORT), build an airport, get the costs again and subtract to get the difference.
Re: AI & coping with Infrastructure Maintenance
On hard settings it will kill company.Core Xii wrote:One workaround might be to get the monthly infrastructure costs (for infra_type INFRASTRUCTURE_AIRPORT), build an airport, get the costs again and subtract to get the difference.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Who is online
Users browsing this forum: No registered users and 11 guests