AIAI

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.

Moderator: OpenTTD Developers

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: AIAI

Post by planetmaker »

AIAI v87 (from GUI, though it calls itself iota14 in its output) seems to not know about aircraft range:

Code: Select all

dbg: [script] [2] [S] Your script made an error: division by zero
dbg: [script] [2] [S] 
dbg: [script] [2] [S] *FUNCTION [abort()] aiai-iota14/UTIL/debug.nut line [40]
dbg: [script] [2] [S] *FUNCTION [HandleEvents()] aiai-iota14/main.nut line [366]
dbg: [script] [2] [S] *FUNCTION [Maintenance()] aiai-iota14/main.nut line [314]
dbg: [script] [2] [S] *FUNCTION [Start()] aiai-iota14/main.nut line [51]
dbg: [script] [2] [S] 
dbg: [script] [2] [S] [tesmode] false
dbg: [script] [2] [S] [message] "AIRCRAFT_DEST_TOO_FAR 322 322 Aircraft 17"
dbg: [script] [2] [S] [this] INSTANCE
dbg: [script] [2] [S] [airplane_id] 322
dbg: [script] [2] [S] [order_event] INSTANCE
dbg: [script] [2] [S] [ev_type] 23
dbg: [script] [2] [S] [event] INSTANCE
dbg: [script] [2] [S] [this] INSTANCE
dbg: [script] [2] [S] [this] INSTANCE
dbg: [script] [2] [S] [need] 130000
dbg: [script] [2] [S] [builders] ARRAY
dbg: [script] [2] [S] [this] INSTANCE
Attachments
ogfx-landscape.tar.zip
possibly needed newgrf. Another version might do
(2.35 MiB) Downloaded 241 times
aiai_crash.sav
savegame
(375.7 KiB) Downloaded 253 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

Coding restarted!
planetmaker wrote:Likely this has been reported before... AIAI was doing quite well and then sadly died:
Thanks for the save! Also - thanks to all bug reporters.

"Count does not exist" is now fixed, it was caused by industry closed during processing list of possible candidates.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

Samu wrote:another crash found

division by zero

Using AIAI v87. Not sure what it was trying to do.
Sorry - this one was caused by AIAI not refusing to be loaded in game with incompatible version.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

BaNaNaS contains new version (iota89) - with bugfixes, tweaks and better NewGrf support (NUTS trainset is now handled properly).

Thanks to everybody who helped by reporting bugs!

known problems: https://github.com/Bulwersator/AIAI/issues?state=open
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: AIAI

Post by Wormnest »

AIAI v 89 crashes with Count does not exist.
Attachments
Unnamed, 1st Nov 2007#1.png
AIAI crash screenshot
(814.19 KiB) Downloaded 5 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

Wormnest wrote:AIAI v 89 crashes with Count does not exist.
Thanks for report - I thought that it is fixed. Can you post savegame? I have no idea what happens here, it seems to be case of weird NewGrf or my misinterpretation of API documentation. And with savegame I may check what is happening with industry number 2065.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: AIAI

Post by Wormnest »

Kogut wrote:Can you post savegame?
I'm sorry the savegame is too big for the forum.
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

New version (iota90) is available. It includes bugfixes, tweaks and refactoring (hopefully unnoticeable for players).

Anyone that encounter this .Count() - crash: please report it (report with savegame would be even more helpful).
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: AIAI

Post by Wormnest »

In a new AI test game AIAI Assertion failed with v90.
Attachments
AIAI crash, 1st Feb 2003.sav
(451.15 KiB) Downloaded 241 times
Unnamed, 1st Feb 2003.png
(261.96 KiB) Downloaded 3 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

Can you provide also dtnames.grf? File is unavailable on BaNaNaS, http://grfcrawler.tt-forums.net/index.p ... q=36347476 is a dead link and version on http://www.tt-forums.net/viewtopic.php?f=67&t=51962 have different ID.

Thanks for the report!
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

I published new version (it may collect more information about this crash).
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: AIAI

Post by Wormnest »

Kogut wrote:Can you provide also dtnames.grf?
I hope I am allowed to post it here but since it's gpl it shouldn't be a problem I think so here it is.
Attachments
Dutch_Town_Names-2.tar
(80 KiB) Downloaded 225 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

It is newgrf with id 44544E32. This save wants one with 36347476 (information from load menu). Can you try to find the one used in this game?

Why some authors prefer to not upload their work to BaNaNaS? This situation would be so easier, search would require around 3 second (by one person), not around 30 minutes (by two people).
Attachments
Bez tytułu.png
Bez tytułu.png (37.67 KiB) Viewed 12739 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: AIAI

Post by Steffl »

Hi Kogut,
I found a bug in AIAI iota 89.
The savegame is before the bug occurs and it was made a nightly (version r25522).
I didn't watch what your AI did, but the profit of it was good until it crashed.


And as I waited to upload the savegame above I found another bug.
This time in version iota 91.
Look at screenshot Nr. 2.
OpenTTD version was 1.3.1. You use a API-function which is too new for 1.3.x versions.

Someone posted a very clever piece of code how you can check if a function is available.

I think it was if(HasCargoRating in AIStation){....

In older versions AIStation.GetCargoRating returns the value 69 when there this station has no rating for this cargo type.
You can try if this works:

Code: Select all

if((HasCargoRating in AIStation&&!AIStation.HasCargoRating(station,cargo))||
(!HasCargoRating in AIStation&&AIStation.GetCargoRating(station,cargo)==69&&AIStation.GetCargoWaiting(station,cargo)<1)){
Attachments
AIAIv89bug.png
AIAIv89bug.png (24.8 KiB) Viewed 3772 times
Unbenannt, 24. Sep 1957.sav
first crash
(1.78 MiB) Downloaded 226 times
Unbenannt, 12. Apr 1942.png
second crash
(37.1 KiB) Downloaded 3 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

I published version iota92 without too new NoAI API calls. Thanks for reports!

EDIT: It seems that first one happened because AIAI unexpectedly was in test mode.

EDIT2: And iota93, finally something crashed in my test.
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Wormnest
Engineer
Engineer
Posts: 117
Joined: 14 Jul 2013 12:33
Location: Netherlands

Re: AIAI

Post by Wormnest »

Found it in the data folder.
Attachments
dtnames.grf
(46.55 KiB) Downloaded 251 times
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

Wormnest wrote:Found it in the data folder.
Thanks! This crash and one reported by Steffl (in v89) are fixed in iota94. Thanks again for reports!
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
mart3p
Tycoon
Tycoon
Posts: 1030
Joined: 31 Oct 2005 21:00
Location: UK

Re: AIAI

Post by mart3p »

Using AIAI iota94 with the latest development version or ISR (r221), I noticed that AIAI always builds the same type of station (the type intended for the source) for both source and destination. ISR r221 should be available for download from the usual place in the next few hours.

Your debugging AI does build the correct source and destination types.

From a quick look at the code in AIAI Railbuilder.nut it seems that the source_station parameter of BuildNewGRFRailStation is always set to true:

Code: Select all

if(!AIRail.BuildNewGRFRailStation(location, direction, platform_count, trasa.station_size, AIStation.STATION_NEW,
      trasa.cargo, source_industry, goal_industry, distance, true)) {
Image
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut »

Thanks for bug report (and even debugging!).

It is now fixed in development version: https://github.com/Bulwersator/AIAI/com ... a7ef6def3b
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
Steffl
Engineer
Engineer
Posts: 103
Joined: 23 Feb 2010 15:44

Re: AIAI

Post by Steffl »

Hi Kogut,
here's a new bug I found.
I played with AIAI version iota93 and Openttd 1.3.1.

I add the savegame, too. AIAI played good in the beginning of the game, but later it had to pay much for its infrastructure maintainance and it seems it tried to sell vehicles when it crashed.
screenshot.png
screenshot.png (41.8 KiB) Viewed 3770 times
Attachments
AIAIv93crash.sav
(905.09 KiB) Downloaded 248 times
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 13 guests