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

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

Re: SimpleAI v13 - trying to remake the old AI

Post by HGus »

It seems Brumi forgot to apply the fix sugested by krinn here

runningcost_limit still falls to zero when Banker.GetInflationRate() is over 6000
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v13 - trying to remake the old AI

Post by Brumi »

I wish I had been using some proper version control software, I had no idea how I missed that :) The thing is, I was aware of the inflation problem in v9, and actually did something about it in v10. But why I didn't include the fix that both krinn and SirkoZ were suggesting, I have no idea. My bad! And it's not just some integer/float conversion problem, the logic itself is bad...

So I will make a new release this week, including this fix (finally!). I still have to review SirkoZ's fix for the road deletion bug though.

I really appreciate you guys not only finding bugs in my AI, but even fixing them. Apologies for the bad code though, the bulk of SimpleAI was written before I started attending university...
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: SimpleAI v13 - trying to remake the old AI

Post by SirkoZ »

No apologies are necessary as I see it, I'm just grateful for your wonderful effort of making this AI. We'll get it right. :mrgreen:
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v14 - trying to remake the old AI

Post by Brumi »

There is a new version out!

Two things were changed:
The inflation issue in the train engine valuator is now fixed. Thanks SirkoZ and krinn for the fix!
The AI sometimes did not remove the C-shaped road pieces when failing to build a road station. I implemented a fix for that, which should work in theory (if my assumption was correct about the root cause of the problem), but as I had no reliable reproduction of the case, I could only make a best-effort fix. (for those interested, the fix is in cBuilder::BuildRoadStation, removing the remainders when AIRoad.BuildRoadStation fails)

As usual, the AI can be downloaded from BaNaNaS or the first post.
burt
Engineer
Engineer
Posts: 2
Joined: 25 Apr 2019 10:58

Re: SimpleAI v14 - trying to remake the old AI

Post by burt »

Hello !
Sorry I am new on open ttd, and I try to install AI but I have always this message.
Can you help me ?
Thanks !


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

Re: SimpleAI v14 - trying to remake the old AI

Post by Brumi »

It seems that your [OpenTTD installation directory]/ai/compat_1.2.nut file is outdated for some reason.

What version of the game are you using? 1.9.1? JGRPP? How exactly did you install this version? Did you upgrade from an older version?

Anyway, compat_1.2.nut has to contain this piece of code at the end:

Code: Select all

/* 1.9 adds parent_group_id to CreateGroup function */
AIGroup._CreateGroup <- AIGroup.CreateGroup;
AIGroup.CreateGroup <- function(vehicle_type)
{
	return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID);
}
If it's not there, try to re-install your game, and make sure that the compatibility files are also updated.
burt
Engineer
Engineer
Posts: 2
Joined: 25 Apr 2019 10:58

Re: SimpleAI v14 - trying to remake the old AI

Post by burt »

Very sorry, it was the switch version and everything work perfectly ! ^^
https://gbatemp.net/threads/openttd-tra ... 941/page-4
Thanks a lot for your work ! :)
User avatar
Wuzzy
Engineer
Engineer
Posts: 66
Joined: 18 Aug 2019 18:04

Re: SimpleAI v14 - trying to remake the old AI

Post by Wuzzy »

This is the only AI I use in my games right now. Because it's simple and works and does not crash or does strange things. So, thanks. :)

Unfortunately, it does not seem to support ships, I hope it will be added in a later version. I'm craving for a simple, yet functional and stable general-purpose AI that does not crash and does not do stupid things. Most AIs around here are experimental, broken, outright weird, too specialized (e.g. 1 vehicle type only), or have other problems, sadly.
User avatar
Wuzzy
Engineer
Engineer
Posts: 66
Joined: 18 Aug 2019 18:04

Re: SimpleAI v14 - trying to remake the old AI

Post by Wuzzy »

Sadly, SimpleAI v14 now crashed on me:

https://satoshiupload.com/images/lxtV8RqJi5.png

However, this happened in 2d7b34bc68f7fb0e707129e4d97383b18f1da55e of OpenTTD. I don't know if it is really SimpleAI's fault, or if it's actually OpenTTD's fault.
SimpleAI v14 NEVER crashed on me before, but this crash happened only after a few minutes. Is this really a bug in SimpleAI or could there be a new incompability in the AI API? What do you think?

EDIT: Okay, so it turned out I launched OpenTTD the "wrong way". This caused the compability script to fail to load, which SimpleAI apparently needs. After I started it the "right way", the compability script was loaded, and SimpleAI works again. Phew. :)
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v14 - trying to remake the old AI

Post by Brumi »

Got scared seeing this :)

But you're right, SimpleAI definitely needs those compatibility scripts, so a crash is quite much expected when they fail to load.
User avatar
RailwAI
Engineer
Engineer
Posts: 75
Joined: 22 Jul 2018 20:30
Location: Headquarters

Re: SimpleAI v14 - trying to remake the old AI

Post by RailwAI »

This AI seems to have some difficulties with the Dutch Trainset & Dutch Tracks. Simple AI decides to use high speed tracks with 3 tiles long stations, and use a high speed train (max 320km/h) combined with 2 slower carriages (max 140 km/h). The train is much longer than the platforms, such that loading/unloading takes a lot of time, and it doesn't gain advantage from using a high speed train or high speed track.
Attachments
simpleAIdutch.png
simpleAIdutch.png (223.31 KiB) Viewed 1470 times
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: SimpleAI v14 - trying to remake the old AI

Post by Brumi »

Welp, the problem of different railtypes and train sets seems to be forever haunting...

Using slower carriages with a high-speed locomotive is something I probably didn't account for, but the train being longer than the platform definitely seems to be a bug. Thanks for noticing!
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 8 guests