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

Baldy's Boss
Tycoon
Tycoon
Posts: 1308
Joined: 23 Feb 2014 22:02

Re: AIAI

Post by Baldy's Boss » 31 Oct 2014 06:22

HGus wrote:Hi, here another bug related to trains, AIAI was doing pretty well for about 30 years in the road/ship era, but when first train became available in 1831, it failed to build proper rail vehicles (infrastructure was right, two good connected stations with depots in right place) I was using UKRS2 train grf. You will see in the screenshot that AIAI build successfully a first train and failed at the second. The first one has six (!) engines, the second only one, with a single wagon. As the message says, both are valid consists (but rares, maybe the script tried to build one train and was splitted cause of bad calculation, settings were at 4 tiles long) BTW, I was using original v95, not my patched one (see my earlier post)
So you're not the only person for whom AIAI has built a sextuple-header!
In the attached game I spotted its only train.This is the 1890s (game started 1887,year of Queen Victoria's Jubilee,saved as of May 24th 1894,her 75th birthday).

At least the AI had the sense to name that train "stupid".
Attachments
JubileeRailGroup,24thMay1894.sav
(455.44 KiB) Downloaded 123 times

Baldy's Boss
Tycoon
Tycoon
Posts: 1308
Joined: 23 Feb 2014 22:02

Re: AIAI

Post by Baldy's Boss » 10 Mar 2015 19:15

AIAI asked for a screenshot of its debug window after a crash,along with a savegame.

(In this game it's currently my closest competitor,with HQ just a couple of blocks from mine in beautiful downtown Rartown).

It happened again,so I edit to add the new.
(I may have to buy this AI in the future to protect my supply chains,I have trains carrying steel from the Rudtown mill it supplies to a factory it also supplies,and goods from that factory to Flinham).
Attachments
RartownBrownRailroadCo.,23rdNov1985.sav
(3.98 MiB) Downloaded 102 times
Rartown Brown Railroad Co., 23rd Nov 1985.png
(1.04 MiB) Downloaded 6 times
Rartown Brown Railroad Co., 12th Jul 1987.png
(1.87 MiB) Downloaded 5 times

Baldy's Boss
Tycoon
Tycoon
Posts: 1308
Joined: 23 Feb 2014 22:02

Re: AIAI

Post by Baldy's Boss » 12 Mar 2015 06:56

Aaaand another crash-induced screenshot & savegame set.

(and since only 3 attachments per message are allowed,ANOTHER screenshot from another crash...may need to buy the AI just to stop the crashes!)
Attachments
RartownBrownRailroadCo.,17thFeb1990.sav
(4 MiB) Downloaded 94 times
Rartown Brown Railroad Co., 17th Feb 1990.png
(2.71 MiB) Downloaded 5 times
Rartown Brown Railroad Co., 21st Jun 1992.png
(2.5 MiB) Downloaded 4 times

HGus
Engineer
Engineer
Posts: 95
Joined: 12 May 2013 22:28
Location: Argentina

Re: AIAI

Post by HGus » 13 Mar 2015 13:23

This is the code causing the crashes.


Dibujo.PNG
(18.12 KiB) Downloaded 4 times

Baldy's Boss
Tycoon
Tycoon
Posts: 1308
Joined: 23 Feb 2014 22:02

Re: AIAI

Post by Baldy's Boss » 21 Mar 2015 18:39

For the record,I bought out the crashing AI in 1996 game time.

User avatar
Core Xii
Traffic Manager
Traffic Manager
Posts: 228
Joined: 08 Apr 2008 09:47
Location: Finland
Contact:

Re: AIAI

Post by Core Xii » 08 Aug 2015 20:17

Crash report.
Unnamed, Aug 8th, 1957.png
(52.1 KiB) Downloaded 1 time
Attachments
AIAI crash.sav
(440.61 KiB) Downloaded 89 times

xarick
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 26 Feb 2015 00:52

Re: AIAI

Post by xarick » 23 Apr 2016 20:52

Not much info to report, sorry. I was testing a 100 year challenge, AIAI died quite quite early, lasted about 13 years alive while the other 87 years it was dead.
- crash
dbg: [script] [0] Your script made an error: assertion failed
dbg: [script] [0]
dbg: [script] [0] *FUNCTION [abort()] aiai-iota95\util\debug.nut line [48]
dbg: [script] [0] *FUNCTION [unknown()] aiai-iota95\myAPIpatch.nut line [97]
dbg: [script] [0] *FUNCTION [sellVehicle()] aiai-iota95\main.nut line [274]
dbg: [script] [0] *FUNCTION [DeleteUnprofitable()] aiai-iota95\util\util.nut line [254]
dbg: [script] [0] *FUNCTION [RunGeneralInspection()] aiai-iota95\main.nut line [99]
dbg: [script] [0] *FUNCTION [Start()] aiai-iota95\main.nut line [89]
dbg: [script] [0]
dbg: [script] [0] [message] "Invalid vehicle 572"
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [string] "for sell unprofitable"
dbg: [script] [0] [S] [vehicle_id] 572
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [why] "unprofitable"
dbg: [script] [0] [S] [vehicle_id] 572
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [load_station_vehicle_list] INSTANCE
dbg: [script] [0] [S] [load_station_id] 30
dbg: [script] [0] [S] [vehicle_id] 572
dbg: [script] [0] [S] [counter] 6
dbg: [script] [0] [S] [vehicle_list] INSTANCE
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [time] 21
dbg: [script] [0] [S] [waiting_for_money] false
dbg: [script] [0] [S] 31
dbg: [script] [0] [S] [builders] ARRAY
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] The script died unexpectedly.
Attachments
autosave11.sav
(382.7 KiB) Downloaded 79 times
openttdCore8.cfg
(11.36 KiB) Downloaded 79 times
Formerly known as Samu

xarick
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 26 Feb 2015 00:52

Re: AIAI

Post by xarick » 12 Aug 2016 17:13

AIAI crashed while testing aircraft for 100 years.
dbg: [script] [0] 1975.11.26 21 planes skipped to next destination!
dbg: [script] [0] 1975.11.27 Powernaut Helicopter constructed! (175)
dbg: [script] [0] 1975.11.27 New industry: Aberdingham Toy Factory
dbg: [script] [0] 1975.12.4 20 planes skipped to next destination!
dbg: [script] [0] 1975.12.4 Flashbang X1 constructed! (2788)
dbg: [script] [0] 1975.12.4 Flashbang X1 constructed! (2154)
dbg: [script] [0] 1975.12.4 estimated cost of a PAX airplane connection: 120000 / available funds: 61375 (51%)
dbg: [script] [0] 1975.12.4 5 months from general check
dbg: [script] [0] 1975.12.4 ==================iteration number 238 of the main loop is now finished=================
dbg: [script] [0] [W] 1975.12.4 Desperation: 0
dbg: [script] [0] 1975.12.4 Waiting for more money: 61k / 120k
dbg: [script] [0] [I] 1975.12.4 4 planes skipped to next destination!
dbg: [script] [0] [I] 1975.12.11 21 planes skipped to next destination!
dbg: [script] [0] [I] 1975.12.11 New industry: Bretown Cola Wells
dbg: [script] [0] [I] 1975.12.11 Closing industry: Great Pafingford Toy Factory
dbg: [script] [0] [I] 1975.12.11 estimated cost of a PAX airplane connection: 120000 / available funds: 116422 (97%)
dbg: [script] [0] [I] 1975.12.11 5 months from general check
dbg: [script] [0] [I] 1975.12.11 ==================iteration number 239 of the main loop is now finished=================
dbg: [script] [0] [W] 1975.12.11 Desperation: 0
dbg: [script] [0] [I] 1975.12.11 Waiting for more money: 116k / 120k
dbg: [script] [0] [I] 1975.12.12 3 planes skipped to next destination!
dbg: [script] [0] [I] 1975.12.19 24 planes skipped to next destination!
dbg: [script] [0] [I] 1975.12.19 estimated cost of a PAX airplane connection: 120000 / available funds: 81060 (67%)
dbg: [script] [0] [I] 1975.12.19 5 months from general check
dbg: [script] [0] [I] 1975.12.19 ==================iteration number 240 of the main loop is now finished=================
dbg: [script] [0] [W] 1975.12.19 Desperation: 0
dbg: [script] [0] [I] 1975.12.19 Waiting for more money: 81k / 120k
dbg: [script] [0] [I] 1975.12.19 2 planes skipped to next destination!
dbg: [script] [0] [I] 1975.12.26 26 planes skipped to next destination!
dbg: [script] [0] [I] 1975.12.27 estimated cost of a PAX airplane connection: 120000 / available funds: 113046 (94%)
dbg: [script] [0] [I] 1975.12.27 5 months from general check
dbg: [script] [0] [I] 1975.12.27 ==================iteration number 241 of the main loop is now finished=================
dbg: [script] [0] [W] 1975.12.27 Desperation: 0
dbg: [script] [0] [I] 1975.12.27 Waiting for more money: 113k / 120k
dbg: [script] [0] [I] 1975.12.27 0 planes skipped to next destination!
dbg: [script] [0] [I] 1976.1.3 32 planes skipped to next destination!
dbg: [script] [0] [I] 1976.1.3 estimated cost of a PAX airplane connection: 120000 / available funds: 110088 (91%)
dbg: [script] [0] [I] 1976.1.3 6 months from general check
dbg: [script] [0] [I] 1976.1.3 46 vehicle(s) should be sold because are unprofitable
dbg: [script] [0] [E] 1976.1.4 Invalid vehicle 2216, last error is ERR_NONE
dbg: [script] [0] [W] 1976.1.4 Please, post savegame
dbg: [script] [0] Your script made an error: assertion failed
dbg: [script] [0]
dbg: [script] [0] *FUNCTION [abort()] aiai-iota95\util\debug.nut line [48]
dbg: [script] [0] *FUNCTION [unknown()] aiai-iota95\myAPIpatch.nut line [97]
dbg: [script] [0] *FUNCTION [sellVehicle()] aiai-iota95\main.nut line [274]
dbg: [script] [0] *FUNCTION [DeleteUnprofitable()] aiai-iota95\util\util.nut line [254]
dbg: [script] [0] *FUNCTION [RunGeneralInspection()] aiai-iota95\main.nut line [99]
dbg: [script] [0] *FUNCTION [Start()] aiai-iota95\main.nut line [89]
dbg: [script] [0]
dbg: [script] [0] [message] "Invalid vehicle 2216"
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [string] "for sell unprofitable"
dbg: [script] [0] [S] [vehicle_id] 2216
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [why] "unprofitable"
dbg: [script] [0] [S] [vehicle_id] 2216
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [load_station_vehicle_list] INSTANCE
dbg: [script] [0] [S] [load_station_id] 50
dbg: [script] [0] [S] [vehicle_id] 2216
dbg: [script] [0] [S] [counter] 22
dbg: [script] [0] [S] [vehicle_list] INSTANCE
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] [0] [S] [time] 6
dbg: [script] [0] [S] [waiting_for_money] true
dbg: [script] [0] [S] [i] 242
dbg: [script] [0] [S] [builders] ARRAY
dbg: [script] [0] [S] [this] INSTANCE
dbg: [script] The script died unexpectedly.
One of the running scripts crashed. Please report this to the script author with a screenshot of the AI/Game Script Debug Window
dbg: [script] [0] [I] Please report the error to the following URL:
dbg: [script] [0] [I] https://github.com/Bulwersator/AIAI/issues (preferred), other possibilities include http://tinyurl.com/ottdaiai (redirects to http://www.tt-forums.net/viewtopic.php?f=65&t=47298) and bulwersator@gmail.com. Thanks! [iota (95)]
Attachments
openttdCore7.cfg
server config
(12.03 KiB) Downloaded 70 times
AIAI, 1st Jan 1976.sav
last month alive
(2.46 MiB) Downloaded 67 times
AIAI, 1st Feb 1976.sav
already dead
(2.47 MiB) Downloaded 69 times
Formerly known as Samu

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut » 21 Sep 2016 18:51

Sorry for so long delay...
HGus wrote:hi kogut...

I found this bug long time ago in version iota 14, but forgot to post it here. I recently came back and found the same in version 95

At railbuilder.nut, lines 593-596 (was 475-478 in v14), there is...

Code: Select all

	//multiplier: for weak locos it may be possible to merge multiple trains ito one (2*loco + 10*wagon, instead of loco+5 wagons)
	//multiplier = how many trains are merged into one
	local multiplier = min(GetAvailableMoney()/costs.GetCosts(), route.station_size*16/AIVehicle.GetLength(engineId))
	multiplier--; //one part of train is already constructed
	for (local x=0; x<multiplier; x++) {
(note the lack of ; at end of line 595)

But it can trig an error when multiplier is not integer because with x being between 0 and 1 makes the for loop enter once, trying to build a multiple train longer than allowed by user setting also crash the AI (you do the checking for a single train, but forgot for multiple).

Here my suggested change:

Code: Select all

 	local multiplier = min(GetAvailableMoney()/costs.GetCosts(), route.station_size*16/AIVehicle.GetLength(engineId));
// Patch: Trains should not be longer than max_train_length setting, also check than multiplier is integer
	multiplier = multiplier.tointeger();
	while (multiplier>AIGameSettings.GetValue("max_train_length")*16/AIVehicle.GetLength(engineId))
		multiplier--;
// End of Patch
	multiplier--; //one part of train is already constructed
Regards.
Thanks! And sorry for a long wait. It is fixed in new version that was just released.
HGus wrote:Hi, here another bug related to trains, AIAI was doing pretty well for about 30 years in the road/ship era, but when first train became available in 1831, it failed to build proper rail vehicles (infrastructure was right, two good connected stations with depots in right place) I was using UKRS2 train grf. You will see in the screenshot that AIAI build successfully a first train and failed at the second. The first one has six (!) engines, the second only one, with a single wagon. As the message says, both are valid consists (but rares, maybe the script tried to build one train and was splitted cause of bad calculation, settings were at 4 tiles long) BTW, I was using original v95, not my patched one (see my earlier post)
This one was caused by train legth limit shorter than constructed station. At least I hope it was caused by this bug, as it is one way to cause this crash that I found.

And multiheading is done to ensur that TE is always high enough to start train. On flat maps it is a bit of overkill but calculating minimu TE needed for specific route is quite tricky so AI always assumes the worst case. For very low TE it results in hilarious many headed hydras.
Baldy's Boss wrote:AIAI asked for a screenshot of its debug window after a crash,along with a savegame.

(In this game it's currently my closest competitor,with HQ just a couple of blocks from mine in beautiful downtown Rartown).

It happened again,so I edit to add the new.
(I may have to buy this AI in the future to protect my supply chains,I have trains carrying steel from the Rudtown mill it supplies to a factory it also supplies,and goods from that factory to Flinham).
Game was saved as AI was building train, as result it got confused by train without orders. It is now fixed and AI will sell uncompleted trains on loading the game. Thanks for the report!
xarick wrote:AIAI crashed while testing aircraft for 100 years.
Wonderful! Reproducible crash for easily fixed bug. Thanks!
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 » 21 Sep 2016 19:07

New version (after over 3 years!) is on BaNaNaS!

- Tweaks, bugfixes and refactoring
- Basic support for NoCarGoal GS (disabled as default)
- Mail trucks
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

Baldy's Boss
Tycoon
Tycoon
Posts: 1308
Joined: 23 Feb 2014 22:02

Re: AIAI

Post by Baldy's Boss » 22 Sep 2016 00:22

Will download the revision!

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: AIAI

Post by Kogut » 25 Oct 2016 11:29

I am going through irc logs that mentioned AIAI and I encountered https://webster.openttdcoop.org/index.p ... 1466208000

12:53:56 <Samu> AIAI server has attracted 4 human companies
12:54:01 <Samu> he's beating them
12:54:03 <Samu> keks
12:55:35 <Samu> FastPTPAI also attracted some human players, he's still beating them yet, but... he's not that great past the early game

(...)

18:44:20 <Samu> AIAI server is having fierce human interaction
18:44:24 <Samu> interesting

(...)

21:07:51 <Samu> AIAI server is ending, last month
21:08:28 <Samu> he beat the humans in profit, i'm surprised
21:08:50 <Samu> red human surpassed him once
21:09:43 <Samu> it's over 2051!
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

xarick
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 26 Feb 2015 00:52

Re: AIAI

Post by xarick » 28 Dec 2017 17:42

Hi Kogut. I'm detecting several issues with AIAI v97 since the last version v95.

He station spreads bus and truck stations, in such a manner that it can cause jams. Look in the savegame near Invendinghead Cross and Little Munham. There's a long line of busses. Also, aesthetically, it looks weird to see unconnected roads. Compared with the previous version, the new station spreading method is causing more harm to his profits, than good. I've tested it in one of my competitions and that was the result. Less efficient use of roads, less average profit per vehicle, worse station usage ratio. See here the summary: viewtopic.php?f=65&t=74943

In the screenshots, the AIAI seems stuck after "Failed rail". After a long while, the script finally crashes.

Other issues that I've seen in other tests, not on this savegame, were:
- trains getting into a jam near narrow junctions. The one-way path signals don't allow them to reverse, so they were eternally stuck there. AIAI tried to send them to depots without success. I wish I had kept a savegame of this, or a screenshot. I forgot, sorry.

- AIAI doesn't seem to detect NoCarGoal if "clear company signs" are on.
- AIAI aircraft doesn't do as well when CargoDist is enabled. He keeps adding aircraft with full load orders, but even though there are passengers in the airports, they aren't loaded on his planes (the passengers want to go to some other destiny than the currently full loading planes go to).
Attachments
Bad Hope (DictatorAI), 1961-02-11.sav
(197.88 KiB) Downloaded 55 times
screenshot#63.png
(399.66 KiB) Not downloaded yet
screenshot#64.png
(421.1 KiB) Not downloaded yet
Formerly known as Samu

xarick
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 26 Feb 2015 00:52

Re: AIAI

Post by xarick » 03 Jan 2018 13:01

Hi again. I found the cause of trains getting stuck.

It happens during signal placement, after constructing the 2nd lane. A train is travelling in the old lane and AIAI then happens to be building the one-way path signals but in the opposite direction the train is heading to. It causes that train to stop. Then AIAI builds a second train that will end up "jamming" against the train that's waiting at the signal.
Attachments
AIAI, 1st Jul 2123.sav
(391.76 KiB) Downloaded 61 times
AIAI, 1st Jun 2123.sav
(390.87 KiB) Downloaded 52 times
screenshot#73.png
(193.46 KiB) Not downloaded yet
Formerly known as Samu

xarick
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 26 Feb 2015 00:52

Re: AIAI

Post by xarick » 23 Jan 2018 16:18

cpu evaluator crash
Attachments
Sem nome, 2004-02-04.png
(45.24 KiB) Not downloaded yet
Sem nome, 2004-02-04.sav
(73.63 KiB) Downloaded 58 times
Formerly known as Samu

xarick
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 26 Feb 2015 00:52

Re: AIAI

Post by xarick » 30 Jan 2018 16:08

Reporting one other crash. Not sure what happened this time.
Attachments
AIAI, 1943-12-30.sav
(130.8 KiB) Downloaded 65 times
screenshot#75.png
(61.28 KiB) Not downloaded yet
Formerly known as Samu

xarick
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 26 Feb 2015 00:52

Re: AIAI

Post by xarick » 31 Jan 2018 22:08

another excessive cpu evaluator crash
Attachments
AdmiralAI and co., 2046-05-14.sav
(8.32 MiB) Downloaded 55 times
screenshot#76.png
(601.53 KiB) Not downloaded yet
Formerly known as Samu

EmattpoYouRebooted
Engineer
Engineer
Posts: 5
Joined: 20 Nov 2018 00:29

Re: AIAI

Post by EmattpoYouRebooted » 23 Nov 2018 22:06

The AI randomly changes the president's face every 0.25 seconds (approximate) Is this a thing it is supposed to be doing? ?( ?( ?( ?( ?(

Brumi
President
President
Posts: 904
Joined: 18 Jul 2009 17:54

Re: AIAI

Post by Brumi » 01 Dec 2018 08:43

Well, it does not do it for me. That's a bummer, it would have been hilarious to see :)

Anything special about your game? I just started a new game with AIAI in it. Something has to be different in your game.

xarick
Transport Coordinator
Transport Coordinator
Posts: 267
Joined: 26 Feb 2015 00:52

Re: AIAI

Post by xarick » 25 Mar 2019 00:59

AIAI does not handle cargodist that well. It's even able to turn negative profits with aircraft.
Attachments
Baltic Sun, 2021-02-05.sav
(1022.69 KiB) Downloaded 18 times
screenshot#106.png
(114.14 KiB) Not downloaded yet
screenshot#107.png
(304.57 KiB) Not downloaded yet
Formerly known as Samu

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests