SimpleAI v14 - trying to remake the old AI

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
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

Uh oh!
Sindington Transport, 16th Aug 1991.png
Sindington Transport, 16th Aug 1991.png (45.94 KiB) Viewed 2770 times
Looks like a bambi crossing, better watch for 'em. :mrgreen:

SimpleAI v1 of course.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: SimpleAI v1 - trying to remake the old AI

Post by Zuu »

Have you verified that SimpleAI is available on the in-game content downloader?

I can't find it neither using 1.0.0 beta 1 nor using last nightly r18698. What version limits did you set in BaNaNaS?
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

It's not on the content server yet, from what I've seen.

BTW - an observation - 3 trains on a long "two-train" line - very nice, more profit without any blockages.
Attachments
Sindington Transport, 5th Jan 2007.png
Sindington Transport, 5th Jan 2007.png (101.53 KiB) Viewed 2764 times

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

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

SirkoZ wrote:Looks like a bambi crossing, better watch for 'em.
I really have no idea how that happened. If the AI had tried to remove the station, it would have removed the whole line. And I have a check not to remove stations in use... :? I think that has to do something with save/load.
Zuu wrote:Have you verified that SimpleAI is available on the in-game content downloader?
I can't find it neither using 1.0.0 beta 1 nor using last nightly r18698. What version limits did you set in BaNaNaS?
I set 'nightly' as the maximum version but forgot to add a number there. Now I set '(none)' and now it's available in 1.0.0-beta1 as well. Thanks for notifying, I only checked it in 0.7.5.
SirkoZ wrote:BTW - an observation - 3 trains on a long "two-train" line - very nice, more profit without any blockages.
Another strange one, most likely some problems with vehicle renewal, or some corrupted internal data. Is there a case when a trains cannot be sold for some reason, apart from not being in a depot? (but that one is very unlikely, as vehicle renewal is triggered by AIEventVehicleWaitingInDepot.)

If you happen to have savegames of these please post them here.
Thank you for the reports! :)

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

I'll attach the save-game from which upper two screen-shots were made.
To be formal - I used:
1.) more_diesel_smoke patch with it (it's not necessary/just for looks),
2.) av8 v 1.501 new .grf,
3.) statically loaded better_veh_names .grf (again not necessary/just for looks),
4.) only_decrease_neutraliser .grf (which in non-temperate disables itself which makes it unnecessary).

That about bambi crossing - well - I really didn't know what to say there. I wasn't exactly there when the AI made that messy track - so I can't say when exactly it decided to place depot off the mainline.
As for the 3 trains - from what I've tested and even tried to modify the old_AI back in the day - 3 trains is nothing bothersome on such longer tracks, trains never get stuck or wait excessively on each-other so you could perhaps consider it a feature for really crowded end-stations...

Anyways only now I re-loaded that game to make a save-game to post here. When above two issues occured - the game was running without any interruptions (since 1950 -> this save (2022)). Wraston and Senningbury are the towns near the "problems" and nightly ver. r18709.
Attachments
Sindington Transport, 8th Nov 2022.sav
save-game r18709(M - if with diesel_smoke)
(584.57 KiB) Downloaded 82 times

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI v1 - trying to remake the old AI

Post by petert »

Absolutey fantastic work, Brumi, I'm amazed.
A few little bugs, if you can even call them that.

Here is the first bug. One of SimpleAI's trains were lost and this text was displayed in red.
train_lost_SimpleAI.png
train_lost_SimpleAI.png (37.92 KiB) Viewed 2723 times
Maybe it was just coincidence, but two SimpleAIs built the same route, which caused a small dilemma. Yellow was just initiated in-game with "start_ai" in console.
double_SimpleAI.png
double_SimpleAI.png (57.14 KiB) Viewed 2723 times
As seen here, there is the classic "passing lane" used by the old AI. The only problem being that it is drive-on-left when my signals are set to drive-on-right. Could you make a detection for SimpleAI so it can build accordingly?
passing_lane_detection.png
passing_lane_detection.png (46.74 KiB) Viewed 2723 times
Last edited by petert on 05 Jan 2010 03:11, edited 1 time in total.

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI v1 - trying to remake the old AI

Post by petert »

Along with drive-on-right/left signal detection, could you also add an option to enable or disable the use of this type of passing lane with the (very) old double signaled passing lane?
passing_lane_double_signals.png
passing_lane_double_signals.png (35.96 KiB) Viewed 2723 times
There is a very small typo in this group name, it is called OIL_ instead of OIL.
Edit: It seems you wanted to have fours letters for each group name, and to be consistent, you had to include the underscore. Sorry about that.
typo_OIL_.png
typo_OIL_.png (11.81 KiB) Viewed 2723 times
And finally... :D (Pink and Yellow are SimpleAI)
Attachments
profit_company_value_SimpleAI.png
profit_company_value_SimpleAI.png (11.66 KiB) Viewed 2723 times
Last edited by petert on 05 Jan 2010 03:13, edited 2 times in total.

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI v1 - trying to remake the old AI

Post by petert »

Here is the save game:
Attachments
SimpleAI testing.sav
(49.25 KiB) Downloaded 76 times

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

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

Thank you for the savegames.
Still no idea about the bambi crossing, but I can verify that a depot was standing in the correct place. It is still a mystery how it got deleted and how the other one was built... ?(
For the 3-train line, I have an explanation:
One of the AI's vehicles crashed. If its vehicleID is still valid, the AI tries to clone it. But the AI was busy when the event occured, the vehicle was cleared from the way, and one of the trains got its ID, so the train was cloned. So I have to check whether the given vehicle has crashed or not.
One more picture from that game, still building in the spirit of the old AI: :)
Sindington Transport, 3rd Dec 2022.png
Sindington Transport, 3rd Dec 2022.png (153.17 KiB) Viewed 2712 times
petert wrote:Here is the first bug. One of SimpleAI's trains were lost and this text was displayed in red.
The red text is always displayed when the AI gets a 'vehicle lost' notification because I don't know how to handle that. But there is no problem with that train line in your savegame, so really nothing serious.
petert wrote:Maybe it was just coincidence, but two SimpleAIs built the same route, which caused a small dilemma. Yellow was just initiated in-game with "start_ai" in console.
It is either a coincidence or a subsidy. The AI only ignores industries where the 'last month transported' is higher than the specified value, which is 60% in your game.
petert wrote:As seen here, there is the classic "passing lane" used by the old AI. The only problem being that it is drive-on-left when my signals are set to drive-on-right. Could you make a detection for SimpleAI so it can build accordingly?
I'd rather not if that's not that important to you, it would make the code much more jumbled and harder to modify later.
I will make a double-way signal setting if you like, but those are a bit worse in my opinion. They certainly cannot handle 3 or more trains. (although the AI shouldn't place 3 trains there)
petert wrote:There is a very small typo in this group name, it is called OIL_ instead of OIL.
Edit: It seems you wanted to have fours letters for each group name, and to be consistent, you had to include the underscore. Sorry about that.
These names are the results of AICargo::GetCargoLabel, I have nothing to do with that.

Anyway, do you have any idea how the AI acquired these vehicles in your game?
Grintown Transport, 19th Apr 1952.png
Grintown Transport, 19th Apr 1952.png (34.31 KiB) Viewed 2712 times
Paper trucks on temperate, transporting mail at the speed of 80 mph in 1952... Really weird :D Is that a loaded scenario, or newGRF, or some patched version? Maybe we spotted a bug in OTTD.

Thanks again for your interest! :)

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI v1 - trying to remake the old AI

Post by petert »

Brumi wrote:The red text is always displayed when the AI gets a 'vehicle lost' notification because I don't know how to handle that. But there is no problem with that train line in your savegame, so really nothing serious.
Ah, ok, just in-case.
Brumi wrote:It is either a coincidence or a subsidy. The AI only ignores industries where the 'last month transported' is higher than the specified value, which is 60% in your game.
I didn't know that either.
Brumi wrote:I'd rather not if that's not that important to you, it would make the code much more jumbled and harder to modify later.
I will make a double-way signal setting if you like, but those are a bit worse in my opinion. They certainly cannot handle 3 or more trains. (although the AI shouldn't place 3 trains there)
Isn't a double way signal setting what I asked for? Ok, then, go ahead :D and Thanks.
Brumi wrote:Anyway, do you have any idea how the AI acquired these vehicles in your game?

Paper trucks on temperate, transporting mail at the speed of 80 mph in 1952... Really weird :D Is that a loaded scenario, or newGRF, or some patched version? Maybe we spotted a bug in OTTD.
I had a NewGRF and removed it in-game. Just found out the effect of that. :-)

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4554
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: SimpleAI v1 - trying to remake the old AI

Post by Zuu »

As a little tip you can issue the "gamelog" command in the console of a loaded savegame to see what weird stuff the user has done. Eg. if it has loaded/unloaded grfs in game etc. I think it is outlined in the readme exactly what information that is logged in the save game.

Regarding drive side etc. I think that is up to the AI to decide. If the AI likes it in one way it is up to the AI. It is not like you demand player in MP to follow your preferred driving side.

Nice work Brumi!
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

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

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

Thanks, I didn't know the "gamelog" command before. :)

Kerygma
Engineer
Engineer
Posts: 14
Joined: 30 Jun 2009 11:06
Location: Germany

Re: SimpleAI v1 - trying to remake the old AI

Post by Kerygma »

I was just playing around with SimpleAI. Really good work!
It even got a nice subsidy ;)
SimpleAI.png
SimpleAI.png (46.47 KiB) Viewed 2691 times
I also tried using the DBSetXL, but there were some problems with the engine selection of the trains (trying to add good carriages to a passenger train engine).

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

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

Kerygma wrote:I was just playing around with SimpleAI. Really good work!
Thanks :)
Kerygma wrote:It even got a nice subsidy
:lol: That's the shortest I've ever seen. It's because there is no minimum distance check for subsidies, I'll have to include that as well.
Kerygma wrote:I also tried using the DBSetXL, but there were some problems with the engine selection of the trains (trying to add good carriages to a passenger train engine).
The AI cannot handle NewGRF trainsets. It's designed for the original set.

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

petert - just to clarify - the double signal passing lanes were used in the TT_Original and are really not applicable for more than 2 trains. Of course with the option of double signal passing lanes there could also be the option of path-signal passing lanes which could potentially allow 4 trains on that 2-train design...

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI v1 - trying to remake the old AI

Post by petert »

SirkoZ wrote:petert - just to clarify - the double signal passing lanes were used in the TT_Original and are really not applicable for more than 2 trains.
Actually, using double signal passing lanes, you could (if the trains chooses correctly) fit up to three trains.

In this screenshot, train 3 has chosen (I made it choose) to go with train 1 to it's destination, Budtown Woods.
double_signal_passing_lane.png
double_signal_passing_lane.png (26.78 KiB) Viewed 2640 times
In this screenshot, train 2 has successfully passed train 1 and train 3, even with double signal passing lanes.
Attachments
double_signal_passing_lane_passed.png
double_signal_passing_lane_passed.png (26.31 KiB) Viewed 2642 times

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

That is true, however, again, TTOriginal had those kind of lanes and with them there's no certainty that if train reverses it won't go to the wrong station - that leading to jams/at least lost messages - I hate those. :-)

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI v1 - trying to remake the old AI

Post by petert »

It still should be an option somewhere. Also, I saw that you will implemement airport usage, how did the old AI use airports? Is there a difference between build of airports/airplanes by the old AI and of players using airports?

Would it be possible to add a feature for terraforming, where you are able to set the amount of terraforming that SimpleAI does. One setting I'm looking for is "Flattens all land". :-)

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1507
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

The old_AI simply landscaped up and down till it got enough flat squares for a wanted airport-size - this usually led to small airports and big planes [strikethrough]landing[/strikethrough] crashing on them.

Anyhow-ing - Brumi - a small inconvenience:
When trying to load a save-game with the earlier version of SimpleAI, AI crashes instantly upon load complaining that it doesn't find a track index....well here's the screenshot:
Lardston Transport, 15th Aug 2014.png
Lardston Transport, 15th Aug 2014.png (6.97 KiB) Viewed 2621 times
. I realise that is the result of the new save-load feature, but 't would be lovely to have a backward compatibility...or somesuch. :-)

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: SimpleAI v1 - trying to remake the old AI

Post by petert »

petert wrote:Would it be possible to add a feature for terraforming, where you are able to set the amount of terraforming that SimpleAI does. One setting I'm looking for is "Flattens all land". :-)
I started playing some 0.6.3 to get a better feel of the old AI's bad habits. Here is an example of the "Flattens land" category :-):
Attachments
bad_terraform_0.6.3.png
bad_terraform_0.6.3.png (70 KiB) Viewed 2618 times

Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests