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

Post Reply
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

Well, the main obstacle of adding plane support is terraforming, I have no clear ideas for that. So that is something I cannot include in the near future.

About backward compatibility, my intention was that this would be the first 'official' version, so there are no more versions to be backward compatibile with... :mrgreen: Anyway, I'll try to avoid 'index doesn't exist' crashes.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

Brumi wrote:About backward compatibility, my intention was that this would be the first 'official' version, so there are no more versions to be backward compatibile with... :mrgreen: Anyway, I'll try to avoid 'index doesn't exist' crashes.
:lol:
Indeed. We can then call it the AI testers' old version compatibility check - limited edition. :D
Av_Vulcan
Engineer
Engineer
Posts: 17
Joined: 09 May 2008 15:57

Re: SimpleAI v1 - trying to remake the old AI

Post by Av_Vulcan »

Hi, Trying to run SimpleAI on a new trunk (18804) build, and having a rather odd problem.

Every time the AI tries to build a road route this happens, no idea why. I can't remember seeing it happen before, so I assume this was a new issue, maybe a grf?

Attached Screenshot and savegame, anyway.
AI built the formation of roads under the cursor:
AI built the formation of roads under the cursor:
Attachments
Allan & Co., 1985-10-29.sav
(448.37 KiB) Downloaded 138 times
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

I tried to open your savegame with the latest nightly (r18814), but OpenTTD crashed.
Then I tried to start a new game with your NewGRF configuration. Why does OpenGFX show up as a NewGRF in your list? Anyway, I downloaded the others and started a new game, but SimpleAI didn't show this strange behaviour. But OpenTTD acted weirdly, when I select a NewGRF to be added to the list, all NewGRFs beneath it are automatically added. Plus, I managed to crash OpenTTD from the NewGRF settings window. :?
Based on your screenshot, most likely the AI doesn't build roads correctly.
road building examples.png
road building examples.png (23.35 KiB) Viewed 4491 times
The AI builds roads first, then places the station and the depot over them, like the top row in the picture. But when connecting two tiles, it builds like the right one in the second row, not like the one on the left. It results in the road formation seen in your screenshot, and the station cannot be placed over that. Anyway I have no idea why the AI builds roads that way.
Do the other road building AIs have this problem? And have you tried without NewGRFs?
Thank you for your report! :)
Av_Vulcan
Engineer
Engineer
Posts: 17
Joined: 09 May 2008 15:57

Re: SimpleAI v1 - trying to remake the old AI

Post by Av_Vulcan »

With a newer version, I've loaded it up, reloaded the AI, and it worked, first time. No idea what the problem was, then.

OpenGFX shows up there likely because I haven't updated the GRF list since before the graphics set was made selectable in the main options screen. I've removed it now, I presume this bug was just a weird one from that earlier revision.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: SimpleAI v1 - trying to remake the old AI

Post by Rubidium »

There was a bug with the road building API introduced a few days ago and was fixed yesterday.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

With the latest trunk revision, SimpleAI v1 gets stuck building unbuildable connection indefinitely. So much so that it doesn't even replace old vehicles:
.
Attachments
Fondinghead Transport, 24th Jun 1987.png
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

I've already seen my AI doing something like that earlier, but I didn't find the place where it was stuck. I can't figure out the intended route here, either it is something with the pathfinder or the endpoints given to the pathfinder are wrong. Anyway, saving and reloading the game should work here.
The correction of the road is done recursively, so if I don't find any other solution, I may have to include some recursion depth check.
I'll try to test this issue further.
Thank you for the report!
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: SimpleAI v1 - trying to remake the old AI

Post by planetmaker »

Brumi wrote:I've already seen my AI doing something like that earlier, but I didn't find the place where it was stuck. I can't figure out the intended route here, either it is something with the pathfinder or the endpoints given to the pathfinder are wrong. Anyway, saving and reloading the game should work here.
The correction of the road is done recursively, so if I don't find any other solution, I may have to include some recursion depth check.
I'll try to test this issue further.
It's always a good idea to have recursion also stop at a certain depth - regardless what the recursion endpoint is. Restarting, e.g. is not an as easy option, if you run an AI server-side.

I just got the funny idea to have AIs play against eachother on a head2head server ;-)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

Brumi wrote:I've already seen my AI doing something like that earlier, but I didn't find the place where it was stuck. I can't figure out the intended route here, either it is something with the pathfinder or the endpoints given to the pathfinder are wrong. Anyway, saving and reloading the game should work here.
The correction of the road is done recursively, so if I don't find any other solution, I may have to include some recursion depth check.
I'll try to test this issue further.
Thank you for the report!
You're welcome.
Perhaps you could make it so - if the AI can't build the road/rail, it goes back (possibly deleting its built road/rail like the old_AI did :-) ) and then at the first square that is clear/sloped right continue in the right direction (I realise it could be difficult to implement).
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

The route correcting algorithm is completely different for roads and rails. For rails, the AI deletes the last three tiles if obstructed and then tries again, this time from the other end. When obstructed while building a road, first the AI just 'ignores' it, and then tries to correct the holes. This works fairly well, so I don't intend to change it. Both algorithms are recursive, so I'll have to check the depth in both of them.
I tried to recreate the case in your screenshot using the scenario editor, but didn't experience this bug. Most probably the endpoints are given wrong when correcting the road, but I don't know why.
I'm planning a bugfix release when OpenTTD 1.0.0 is ready, because there are some slight changes to the subsidy system.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
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 see.
Well - it probably wouldn't do much good if I send the save game. It was just a quick game (on fast forward of course) where I build a few basic things and then look at what AI makes from time to time - perhaps you can re-create the situation with my settings (I now usually call AI's when in-game, e.g. start_ai SimpleAI)...
Attachments
Fondinghead Transport - settings.png
Fondinghead Transport - settings.png (34.4 KiB) Viewed 4285 times
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: SimpleAI v1 - trying to remake the old AI

Post by Zuu »

SirkoZ wrote:With the latest trunk revision, SimpleAI v1 gets stuck building unbuildable connection indefinitely. So much so that it doesn't even replace old vehicles:
.
You (Brumi) might want to checkout if this is related to the issue I found when I checked some of the bug reports I got for CluelessPlus. (See my response here: http://www.tt-forums.net/viewtopic.php?p=852991#p852991 )
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

Thanks for that, that might be the issue, but as far as I remember I have seen this one earlier in one of my games as well. But only this could be a valid reason why the AI cannot build something that is buildable according to the pathfinder :?
Anyway, planetmaker has a point there, so I will insert the recursion depth check. It should not take 10 or more tries to build a connection under normal conditions.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

Looks like terkhen solved the road/rail building getting stuck when encountering an obstacle. Very nice indeed. Haven't tested it with SimpleAI though...
Attachments
r18986-87_terkhen_NoAI_fix.png
r18986-87_terkhen_NoAI_fix.png (2.42 KiB) Viewed 4210 times
Timmaexx
Transport Coordinator
Transport Coordinator
Posts: 301
Joined: 03 Jan 2009 17:55

Re: SimpleAI v1 - trying to remake the old AI

Post by Timmaexx »

He's Dev? Since when?
My congrats!
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 »

Timmaexx wrote:He's Dev? Since when?
My congrats!
Since ~r18939, http://hg.openttd.org/openttd/trunk.hg/rev/e22eee302585
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v1 - trying to remake the old AI

Post by SirkoZ »

Brumi - despite terkhen fixes for AI's to stop building when reaching an obstacle I still caught SimpleAI trying indefinitely while crying out ERR_LAND_SLOPED_WRONGLY. :-)
That was yesterday with build r19053. And it happened quite late in the game, somewhen after 2020...
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v1 - trying to remake the old AI

Post by Brumi »

Thanks :) I've already encountered this problem before that particular change in the OpenTTD, so this is rather a bug in my code. I will try to make a bugfix release after 1.0.0 stable is ready, because there are some changes in trunk, like the ability to change AI parameters ingame, so I will add support for that.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
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's nice. Perhaps you could look at (the only/example AI that used to be included with the trunk back when NoAI was first introduced) the WrightAI. It only builds air-routes and perhaps you could use some of its methods for SimpleAI.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 40 guests