Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.
There are several causes that can result in ERR_UNKOWN, but in the end for all of them the AI has made a wrong choice. (trying to build a non-aircraft at an airport, trying to build on a non-hangar tile, building planes on a heliport, etc.) If you upload an AI that reproduces the problem I'll take a look at it.
I get an assertion error. What you want to do, is not only check for AIEngine.GetCargoType(engineID) == passenger_cargo_id, but also for: AIEngine.CanRefitCargo(engineID, passenger_cargo_id) and make sure you don't return an empty list.
That should fix your problem, good luck with your AI!
Bram
Morloth wrote:What you want to do, is not only check for AIEngine.GetCargoType(engineID) == passenger_cargo_id, but also for: AIEngine.CanRefitCargo(engineID, passenger_cargo_id) and make sure you don't return an empty list.
The first parameter to a valuator function will always be taken from the list to valuate, the next parameters you send to the valuators as argument to the Valuate function.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites) Junctioneer (a traffic intersection simulator)
And I want valuate industry_list according to distance from tile pozycja.
So I want to valuate with AITile.GetDistanceManhattanToTile(AIIndustry.GetLocation( <HERE ENTRY FROM INDUSTRY LIST> ), pozycja);
How to do it?
Correct me If I am wrong - PM me if my English is bad AIAI - AI for OpenTTD
For that you need to write your own function that take am industry id and return the distance using the code you wrote. Pass this function to the valuate function.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites) Junctioneer (a traffic intersection simulator)
As argument it need station type. Unfortunatelly it is broken confused me, because various airports have various coverage (see picture, straight part of roar/canal/rail is size of catchment), and I need fuction that can tell me is (constructed) airport in one of loading tiles of industry.
Kogut wrote:As argument it need station type. Unfortunatelly it is broken,
EDIT: I have workaround, but that function is broken.
I realise English isn't your first language Kogut, but be careful telling devs that functions are "broken" when it's more likely you're just not using them correctly. It's a little bit rude...
If you have the vehicle in a depot then you can use AITestMode and AIAccounting mode togeather to get the price of a refit without actually executing it. If you want information about a vehicle before it is built then it is not a vehicle, but an engine. Engine information you get by using AIEngine. Have a look there if refit cost can be obtained. If not, that is probably because of a limitation with respect to how the NewGRF system was designed.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites) Junctioneer (a traffic intersection simulator)