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

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

Re: SimpleAI v6 - trying to remake the old AI

Post by Brumi »

Oh, and don't mind flyspray (the bugtracker for reporting bugs in OpenTTD, see http://bugs.openttd.org/), I already reported it, and now I'm going to request its deletion because it turned out that this is not an OpenTTD bug.
MAG101
Engineer
Engineer
Posts: 28
Joined: 14 Dec 2011 00:55

Re: SimpleAI v6 - trying to remake the old AI

Post by MAG101 »

This Ai need support range since when using range supported plane
or airplane will refuse flying




Bug 1

1. found a bug when using train grf with logic trains break AI thinks Logic trains better but cant haul wagons and freight ,

also seen in certain AIs
Attachments
Bundwood Transport, 2nd Sep 1950.png
cant haul wagons
(111.34 KiB) Downloaded 15 times
Bundwood Transport, 4th May 1951.png
Logic train breaks AI NUTS trains
(96.01 KiB) Downloaded 15 times
Unnamed, 12th Sep 1953.png
(269.5 KiB) Downloaded 15 times
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v6 - trying to remake the old AI

Post by Brumi »

Thanks for the report.
NewGRF trainsets and track sets are not (yet) supported, although I have already started some work to include NewGRF trainset support. I'll probably have some time to finish it in the summer. Range-limited planes are also not supported.
Hopefully version 7 will have both these features :)

And the third screenshot is some serious oldAI-ism :mrgreen: Luckily it doesn't occur too frequently, and it doesn't cause further problems, only the attention of the AI is drawn away for quite some time. This could be solved by adding some blacklist to the pathfinder.
Aotrs Commander
Engineer
Engineer
Posts: 25
Joined: 23 Sep 2012 17:29

Re: SimpleAI v6 - trying to remake the old AI

Post by Aotrs Commander »

Though I can see from the posts above me the issue is probably already under advisment, it was pointed out to me that I should mention that in my last game using SimpleAI, where I was using the 2CC trainset, as soon as monorails became available, the AI started trying to build them for railways exclusively, and struggled because there were no freight engines available to it. (Towards the end of the game, when there wasn't much room left, the AI stuck to using roads, fortunately.) I had a error messages a couple of times, which I think were most likely due to this - I recall it was something about "vehicle does not exist", and I think tended to come up after I'd loaded a save. I reset the AI the first time, but when it happened sometime later (I cycled through a lot of competator companies, about one every ten years, as I bought them out!) I let it alone, and it just plugged on anyway.

Actually, come to that it also showed a preference for using the "updated default" (I was using FIRS) vehicles, rather than the ones from eGRVTS NewGRF that had much lower running costs. Knowing nothing about how the scripting works, I don't know whether this is a issue that can be dealt with or not, but I thought I ought to mention it anyway, on the basis that feedback is feedback!
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v6 - trying to remake the old AI

Post by Brumi »

Thank you for your feedback. :)

The current version lacks support for NewGRF trainsets and railway track sets, so strange things may happen when using the 2CC trainset. However, FIRS is supported, so the AI will be able to play with it using the ECS & FIRS original vehicle set NewGRF, or if trains are disabled. I've started some work to include support for NewGRF trainsets, but it is currently on the hold, I was simply lazy to continue it... At the moment I'm quite busy due to assignments.
Aotrs Commander wrote:I had a error messages a couple of times
Did the AI crash? Even if NewGRF trainsets aren't supported, the AI should never crash. So if you experience that again, please send a screenshot of the AI debug window, possibly with a savegame. I'll look into the issue.
Aotrs Commander wrote:Actually, come to that it also showed a preference for using the "updated default" (I was using FIRS) vehicles, rather than the ones from eGRVTS NewGRF that had much lower running costs. Knowing nothing about how the scripting works, I don't know whether this is a issue that can be dealt with or not, but I thought I ought to mention it anyway, on the basis that feedback is feedback!
The algorithm for selecting road vehicles is quite simple, currently the AI simply picks the fastest vehicle available which can transport the given cargo. It works well with the original vehicle set and eGRVTS, there are generally no tough choices with road vehicles. If there are multiple road vehicle sets enabled, this may not the best choice, but it is sufficient as long as the AI doesn't lose money on it :)
Poppis
Engineer
Engineer
Posts: 2
Joined: 30 Oct 2012 22:20

Re: SimpleAI v6 - trying to remake the old AI

Post by Poppis »

Hi,

I'm new here so sorry if this is in the wrong place. My game just crashed and I got an error message when I loaded the game next time. I've attached a screenshot of it below. I have 2 opponents on the game, both with SimpleAI. All settings and stuff should be default, since I just installed the game a few days ago and haven't had time to explore them yet.
Attachments
AI crash.jpg
(452.12 KiB) Downloaded 14 times
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v6 - trying to remake the old AI

Post by Brumi »

Thank you for the report! It looks like I have some work to do now :)

Until I fix this problem, you can recover the AI in your game if you load an earlier savegame. The game was saved just between the construction of two road stations, which is quite rare, so noone has found this bug yet.

By the way, please send screenshots in PNG format, as it is quite hard to read the red lines in JPG format.
Poppis
Engineer
Engineer
Posts: 2
Joined: 30 Oct 2012 22:20

Re: SimpleAI v6 - trying to remake the old AI

Post by Poppis »

Yeah I noticed the screenshot didn't come out too good. Will use .PNG in the future.

Got the game running again, thanks.
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v7 beta1 - trying to remake the old AI

Post by Brumi »

I'd like to share what I've been working on today: the first beta of version 7 8)

Most importanty it has some support for NewGRF trainsets. I have tested it with URKS, UKRS2, NARS and 2CC. FIRS and ECS are supported, although the AI may have a very hard time if only trains are enabled, as the running costs of these sets are quite high. So the AI only does decently if road vehicles are also enabled, but on easy difficulty it succeeds with trains only as well.
Engine selection is made in a way that if the default train set is used, the AI makes the same choices as the previous versions. My biggest challenges were articulated wagons and express trains. Articulated wagons (like the 3x Freightliner container rake in UKRS) tend to be very long, so I tried to exclude them, but in UKRS2 and 2CC all wagons are articulated for some reason, so I cannot make a distinction. So I introduced blacklisting for wagons, and extra long wagons are put into the blacklist. (I cannot determine their length before buying one...)
Some engines cannot attach certain wagons, and this was also quite a challenge for me, again it was solved by blacklisting.
There is some minimal support for extra railtypes, so the AI won't try to build maglev all the time when there is only a passenger train available on maglev.

Range limited planes should be also supported, but I encountered some strange behaviour, I opened a topic about it. Most probaby I don't know something :)

And of course I fixed the bug Poppis reported above.

So the new version is available in the first post, please give it some time and test it :) It's been quite a time I last worked on this AI, so it will need some thorough testing before I release version 7.
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: SimpleAI v7 beta1 - trying to remake the old AI

Post by krinn »

I would say 2 errors are there :
1/ the crash because of route var
2/ choosing the train engine endup returning 0 and displaying that engine display null, obviously there's a trouble with that return value as it must be an invalid engine (line 456).
So ChooseTrainEngine need a check too :)
Attachments
Non nommé, 1994-01-28.png
(127.4 KiB) Downloaded 9 times
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v7 beta1 - trying to remake the old AI

Post by Brumi »

Thanks for your report, I'll look into it when I have some time again. :)
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v7 beta2 - trying to remake the old AI

Post by Brumi »

Finally I had some time to work on SimpleAI again, so I fixed the bugs krinn reported above and fixed the support for range-limited planes.
Krinn helped me out a lot, there is a new road vehicle selection algorithm in this version borrowed from DictatorAI :)

As always, see the first post to download beta2, any feedback is welcome! Hopefully I didn't break anything after this long pause in development 8)
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SimpleAI v7 beta2 - trying to remake the old AI

Post by 3iff »

I really like Simple-AI as it's one of the few AIs that use shared orders, so that if/when I take over an AI company, it's easy to take control of the additional vehicles.

I'm giving this a test now (14 AI having at-it).

Thanks for your efforts on this AI script - much appreciated.

I wonder if it's possible to make it aware of bigger maps for the purposes of building longer routes? For the last version, I amended a couple of values so it could build really long train routes and even road routes of 200 tiles. It worked...but it would be nice if the script could know it's playing on a large (500/1000+ tile) map and extend the possibility of longer routes...maybe also tied into available cash?
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SimpleAI v7 beta2 - trying to remake the old AI

Post by 3iff »

Oops, a problem...no idea if it's an old one or a new one.
White builds a road route that crosses an existing rail line. It builds the red bridge and thinks that completes the route...but it's not joined. It's just bought some trucks so I'll wait and see what it does.

Eventually realises the truck is lost...
Unnamed, 21st Apr 1951.png
Unnamed, 21st Apr 1951.png (116.22 KiB) Viewed 8620 times
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v7 beta2 - trying to remake the old AI

Post by Brumi »

Thank you for your feedback. Not building long routes is a design issue: First, I tried to make it similar to the old AI, which didn't build longer routes. There is also a problem with rail lines having only two passing lane sections, which is quite hard-coded at the moment, and it also heavily limits the maximum length of rail routes. And lastly, I tried to make sure that pathfinding won't take too long even on the very slow setting.
Anyway, you may freely alter these values if you want to :)

The bridge building bug is most probably an old one, I didn't change the road building code recently. It is very rare and quite hard to reproduce, but maybe I'll try to give it another go in fixing it. By the way, nothing really serious happens here, as the AI will notice that these vehicles are running unprofitable and will eventually close down the route.
Dwachs
Engineer
Engineer
Posts: 46
Joined: 02 Jun 2005 07:28

Re: SimpleAI v7 beta2 - trying to remake the old AI

Post by Dwachs »

The blue deport in the lower right of the image is not placed very efficiently, too.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SimpleAI v7 beta2 - trying to remake the old AI

Post by 3iff »

Didn't notice that blue depot...

Brumi: I agree that having just 2 passing lanes on a basic single track does have serious implications for long routes. Having longer road routes is ok though as my experiments have shown...useful for vehicles that can run at 70mph rather than 30mph at game start (or even slower!).

That company realised those trucks were loss-makers and shut them down...I shouldn't worry too much about the road/bridge issue. I guessed it was an old problem.
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v7 beta3 - trying to remake the old AI

Post by Brumi »

I uploaded the third beta which hopefully fixes the bug you reported, I was able to reproduce it by copying the screenshot :)
This bug occured if the road pathfinder wanted to build a bridge on the last tile, I had to exclude bridges to be built there.
User avatar
3iff
Tycoon
Tycoon
Posts: 1093
Joined: 21 Oct 2005 09:26
Location: Birmingham, England

Re: SimpleAI v7 beta3 - trying to remake the old AI

Post by 3iff »

I think the AI did build the bridge last...it was quite quick and I wasn't expecting it to do something strange.

Glad I could help. I'll give this version a try. Thanks.
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v7 beta4 - trying to remake the old AI

Post by Brumi »

Well, version 7 is still not ready yet, but I have uploaded the fourth beta. The previous version wasn't handling NUTS correctly because the AI couldn't handle the situation when the passenger and the mail cars had the same model. And I also had to avoid the universal railtype to prevent the AI from going bankrupt :)

Anyway, feedback is welcome, hopefully I will be able to make a release of version 7 in the near future.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests