NoCAB - Bleeding Edge edition Version 2.2a4

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

Zaludek13
Engineer
Engineer
Posts: 2
Joined: 25 Feb 2010 17:44

Re: NoCAB - Bleeding Edge edition - Version 2.0a15

Post by Zaludek13 »

Hi,

I wanted to try this.. but I got few errors:

http://imagefra.me/view.php?img=/2/3/16 ... &srv=img38


Do I need some additional files to run this AI? My OpenTTD version : r19410 (latest nightly).
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Bleeding Edge edition - Version 2.0a15

Post by Morloth »

Zaludek13 wrote:Hi,

I wanted to try this.. but I got few errors:

http://imagefra.me/view.php?img=/2/3/16 ... &srv=img38


Do I need some additional files to run this AI? My OpenTTD version : r19410 (latest nightly).
You do actually. The file you need is: http://noai.openttd.org/downloads/Libra ... p.1.tar.gz. Make sure you save it in the following path $openttd/content_download/ai/library/. After that things should work fine :).

Good luck and let me know if you still have any trouble.
Zaludek13
Engineer
Engineer
Posts: 2
Joined: 25 Feb 2010 17:44

Re: NoCAB - Bleeding Edge edition - Version 2.0a15

Post by Zaludek13 »

Thanks, it's working now :)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: NoCAB - Bleeding Edge edition - Version 2.0a15

Post by Zuu »

I encountered a problem that your AI did not build any train engines. Probably becaues of the year. But I also noticed that I only had version 350. So I did save the game (attached), went to online content download and fetched the last NoCAB and then loaded the savegame. Now the attached error came up.

Not sure if you were just lucky or if you did some landscaping, but it was a nicely fit railway connection into a big town with lots of existing roads.
Attachments
Brown & Co., 24th Jun 2055.png
Clueless.sav
Saved by 1.0.0-RC3
(118.62 KiB) Downloaded 160 times
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
viblo
Engineer
Engineer
Posts: 2
Joined: 21 Mar 2010 13:04

Re: NoCAB - Bleeding Edge edition - Version 2.0a15

Post by viblo »

Got this error when playing with nocab 2.0a15:
save_error.png
I have 3 nocabs in the game, only the last one generated the exception..

Another one:
serving same ind twice.png
The AI created the "Gronnpool Mines"-line a long time ago. Recently it created the other line, Gronnpool East collecting coal from the same mine. I read in changelog that the AI shouldnt do this?
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Bleeding Edge edition - Version 2.0a15

Post by Morloth »

viblo wrote:Got this error when playing with nocab 2.0a15:
save_error.png
I have 3 nocabs in the game, only the last one generated the exception..
Thanks for the report, this issue should be fixed in the upcoming version.
viblo wrote: Another one:
serving same ind twice.png
The AI created the "Gronnpool Mines"-line a long time ago. Recently it created the other line, Gronnpool East collecting coal from the same mine. I read in changelog that the AI shouldnt do this?
Very true, but at the moment the code is a little bit of a mess so this won't be fixed in NoCAB 2.0.0. I'm planning to rewrite a significant portion of the code for release 2.1 so this issues should be fixed by then.
Zuu wrote:I encountered a problem that your AI did not build any train engines. Probably becaues of the year. But I also noticed that I only had version 350. So I did save the game (attached), went to online content download and fetched the last NoCAB and then loaded the savegame. Now the attached error came up.

Not sure if you were just lucky or if you did some landscaping, but it was a nicely fit railway connection into a big town with lots of existing roads.
This can very well be because the savegame versions don't match. I notice I made a little mistake in checking this which is fixed now :). But I'm not sure how NoCAB got to build a single line rail station over there as I only build rail stations with 2 platforms, but it seems it finds its way :).

New version coming up very soon, just need to fix 1 little bug... I'll keep you posted!
- Bram
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Bleeding Edge edition - Version 2.0a16

Post by Morloth »

Yesss!!! I finally solved the bugs which were bugging me for the last 2 weeks :). After running a couple of test games with no crashes and very good results I think this one will be the release candidate for the final version 2.

Changelog:
- Fixed a problem where NoCAB didn't detect that rails were shared if there were bridges / tunnels involved.
- Improvements to the pathfinder.
- Some other smaller bugfixes.

There is still a lot to be done, but I think I'll postpone these issues for version 2.1 as I want to do a complete overhaul of the current code base. That's why I'm going to change the version numbers from now on. This version (if no other bugs are detected) will be released as 2.0.0, all the bug fixes to that release will be numbered 2.0.x. I will not change the save games in these minor bug fixes. Anything bigger, will be added to the 2.y.x release and I won't guarantee that the save games from previous version will work for different version of y.

Good, I'm going to bed now. Enjoy the new - hopefully bug free - release! :)
- Bram
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: NoCAB - Bleeding Edge edition - Version 2.0a16

Post by Zuu »

You're doing a great work!

If you know that you will break save game compatibility it is good if you in your info.nut set a minimum save game version that it accepts. This way OpenTTD will not try to load a too old save game with your newest AI, instead it will use an older version of your AI if the user has that present.

As you might know there was a change so that OpenTTD will take the last AI version that accepts a save game when loading from a save game. Before it always used the same version as in the save, if that version was present. These changes makes it easier for users to upgrade to the new versions that we release, but put a higher responsibility to signalize when the compatibility has been broken.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: NoCAB - Bleeding Edge edition - Version 2.0a16

Post by Dezmond_snz »

Bridges are still very slow. I spotted bug: it always build second bridge by speed, not the fastest one. So i looked at code (RailPathBuilder.nut: line 169) and found error, i hope:

Code: Select all

local bridgeTypes = AIBridgeList_Length(length);
local bestBridgeType = null;
for (bridgeTypes.Begin(); bridgeTypes.HasNext(); ) {
	local bridge = bridgeTypes.Next();
	assert (AIBridge.IsValidBridge(bridge));
	if (bestBridgeType == null || AIBridge.GetMaxSpeed(bridge) >= AIBridge.GetMaxSpeed(bestBridgeType))
		bestBridgeType = bridge;
}
This enumeration will always skip first element of bridgeTypes list. Better to wrote like this:

Code: Select all

local bridgeTypes = AIBridgeList_Length(length);
local bestBridgeType = null;
for (local bridge = bridgeTypes.Begin(); bridgeTypes.HasNext(); bridge = bridgeTypes.Next()) {
	assert (AIBridge.IsValidBridge(bridge));
	if (bestBridgeType == null || AIBridge.GetMaxSpeed(bridge) >= AIBridge.GetMaxSpeed(bestBridgeType))
		bestBridgeType = bridge;
}
Russia
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: NoCAB - Bleeding Edge edition - Version 2.0a16

Post by Zuu »

Dezmond_snz wrote:This enumeration will always skip first element of bridgeTypes list. Better to wrote like this:
Code:
local bridgeTypes = AIBridgeList_Length(length);
local bestBridgeType = null;
for (local bridge = bridgeTypes.Begin(); bridgeTypes.HasNext(); bridge = bridgeTypes.Next()) {
assert (AIBridge.IsValidBridge(bridge));
if (bestBridgeType == null || AIBridge.GetMaxSpeed(bridge) >= AIBridge.GetMaxSpeed(bestBridgeType))
bestBridgeType = bridge;
}
If this is wanted you can use the foreach loop instead of the long for-statement above.

Code: Select all

foreach (bridge, _ in bridgeTypes) {
   assert (AIBridge.IsValidBridge(bridge));
   if (bestBridgeType == null || AIBridge.GetMaxSpeed(bridge) >= AIBridge.GetMaxSpeed(bestBridgeType))
      bestBridgeType = bridge;
}
Or why not use Valuate and then pick the bridge with highest speed?

Code: Select all

bridgeTypes.Valuate(AIBridge.GetMaxSpeed);
bridgeTypess.KeepTop(1);
bestBridgeType = bridgeTypes.IsEmpty() ? null : bridgeTypes.Begin();
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Bleeding Edge edition - Version 2.0a17

Post by Morloth »

Update! :)

Thank you very much Dezmond_snz, I was actually looking at that this very morning figuring out what was going on. But your code fixed it right away! :D. Thanks for the comments Zuu :), for now I've used Dezmond_snz's approach but after this release I plan to rewrite a large part of the codebase and probably make better use of valuators and such. For now I'm just happy it works :).

Changelog:
- Always build and upgrade to the fastest bridges (thx Dezmond_snz!) :)
- Make use of autoreplace to auto replace vehicles.
- We now upgrade rails inplace if all the trains have power and can run on the new rail type.
- Improve the construction of buoys so ships can find their way better.
- Fixed a bug which allowed the pathfinder to build stations outside the reach of the accepting industry.
- Make the rail pathfinder build more straight paths.

Known issues:
None! :D

Enjoy the release!
- Bram
Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: NoCAB - Bleeding Edge edition - Version 2.0a17

Post by Kogut »

Nocabs love bridges!
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (129.72 KiB) Viewed 5080 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
User avatar
TheDarkGiganotosaur
Engineer
Engineer
Posts: 21
Joined: 24 Mar 2010 15:49
Location: Portugal

Re: NoCAB - Bleeding Edge edition - Version 2.0a17

Post by TheDarkGiganotosaur »

Hello, I've been playing against computer players with this AI script (And with the others too.). And it's really fun playing with computer players that use all four types of transportations simultaneously.

Now, about the AI, every time the computer player enters the game, it takes quite a bit long before it begins constructing something. But I suppose that's normal, right?

Lastly, keep up with the great work!
The Dark Giganotosaur, the ghastly dinosaur (currently in human form)
"My favorite type of transport vehicles? Trains and streetcars/trams." | My Music | My Arts (TBA)
Windows 10 x64 (NEVER USED) | Knoppix 8.1+ x64 | Linux Mint 20.3 Xfce x64
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Bleeding Edge edition - Version 2.0a18

Post by Morloth »

Kogut wrote:Nocabs love bridges!
It sure does, Bridges are the same as normal roads / rails to NoCAB :).
TheDarkGiganotosaur wrote:Now, about the AI, every time the computer player enters the game, it takes quite a bit long before it begins constructing something. But I suppose that's normal, right?

Lastly, keep up with the great work!
Thanks for the comment. It is true that NoCAB takes some time (the bigger the map the longer it will take!) to initialize. From the way I setup the framework there is nothing I can do about that at the moment. But for the next version I'm going to completely rewrite NoCAB and possibly include a lazy evalutation strategy so I don't have to spend that much time initializing :).

Update! Found a couple of bugs and fixed some found by you (I'm looking at you Kogut ;) ). The change log is below:
- Use the API functions to calculate the costs of building a ship connection.
- Clean up some code and check where we can build airfields before we do so!
- Fixed a division by zero bug.
- [fix] Docks could be build where cargo wasn't produced / accepted (thx Kogut!).
- Make sure we go forward after exploiting an existing tunnel or bridge.
- Refit the wagons as well if necessary!
- Allow users to specify if they want trains to serve town to town connections (default = NO!).

This update also allows users to play with the NewGRF train sets which was impossible before. Do not expect good performance though, there are still some quirks because newer rail types do not always provide trains for all cargo types and NoCAB fails to cope with this. Also, town to town connections are disabled by default because the current station layout isn't ideal for that. However, you can change this behaviour with the newly included option which will come in handy if you plan to use NoCAB with NARS, CC of any of the other NewGRFs who heavily depend on passenger / mail connections.

Hopefully this will be one of the last updates before the final 2.0 release. Thanks for all your comments and especially bug reports!
- Bram
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Bleeding Edge edition - Version 2.0a19

Post by Morloth »

And bugs did happen :(.

New release with some new features and bug fixes!
- Fixed the bug which failed NoCAB to detect which rail connections were connected to each other.
- Optimized the pathfinder for rail connections.
- Fixed the possible end locations of a rail road, sometimes the end stations was placed outside the acceptance radius.
- Make sure to demolish airfields once we do not build aircraft any more who make use of it.
- Demolish connections if the producing or accepting side ceases to exists.

So we will not see old small airfields in the middle of cities with no aircraft serving them! Also whenever an industry ceases to exist the connection(s) linked to that industry are demolished making room for new opportunities.

I hope you can help me to test this version as I want to make sure the demolition of connections doesn't cause any havoc ;). Please report any bugs you find and hopefully we'll have a stable NoCAB on the 1st of April :).

Thanks for your help!
Bram
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: NoCAB - Bleeding Edge edition - Version 2.0a19

Post by Brumi »

Hi Morloth,
I was testing the newest version and it's simply amazing :)
The problem is that I had this crash:
Attachments
NoCAB crash.png
NoCAB crash.png (27.29 KiB) Viewed 4973 times
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: NoCAB - Bleeding Edge edition - Version 2.0a19

Post by Dezmond_snz »

Nice release.

NoCAB don't want to work with FIRS absolutely... It trasnports only passangers and mail sometimes - nothing else.
Gonna take a shot with standart industries. :)

(add)
And may be teach him to build statues in towns?
Russia
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Bleeding Edge edition - Version 2.0a19

Post by Morloth »

Brumi wrote:Hi Morloth,
I was testing the newest version and it's simply amazing :)
The problem is that I had this crash:
Thanks for the compliment :)

Do you use any NewGRF stuff by any chance? I remember there was a bug report when using the PBI industries. I will have a look at it tonight, see what I can do.
Dezmond_snz wrote:Nice release.

NoCAB don't want to work with FIRS absolutely... It trasnports only passangers and mail sometimes - nothing else.
Gonna take a shot with standart industries. :)

(add)
And may be teach him to build statues in towns?
You're right it doesn't work with FIRS. I'm not sure why but I'll have a look to see if I can change that. I can certainly teach him to build statues in towns but I don't think that'll be included in this version yet. Next version will include the 'Not so nice CAB' as an option which will be more actively involved with the local authority (inc. bribery, exclusive transportation rights, etc.). But I do want FIRS to work with this release!

Thanks for the bug reports and feature requests!
Bram
Brumi
President
President
Posts: 920
Joined: 18 Jul 2009 17:54

Re: NoCAB - Bleeding Edge edition - Version 2.0a19

Post by Brumi »

Morloth wrote:Do you use any NewGRF stuff by any chance?
I only use the Generic Tram Set v0.4 and the Temperate Oil Wells only_decrease neutraliser (but it was disabled because I played in the sub-arctic climate).
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Bleeding Edge edition - Version 2.0a20

Post by Morloth »

Ok, I've looked into the problem with NewGRFs. The major problem is the way that NoCAB builds a tree of industries which tells it which once it should consider first. For example at the very start only industries which do not accept anything and produce something (e.g. coal mines, oil rigs) are taken as primary industries. Also industries which accept and produce the same cargo fall under this category (e.g., towns, banks).

With NewGRFs like FIRS all industies accept engineering tools and thus are not considered to be primary industries by NoCAB. So until they are supplied with engineering tools NoCAB won't consider them. This cycle in the production / acceptance graph is the reason why NoCAB doesn't do anything with those industries. To get around this issue I've included a flag which is basically a "NewGRF compatibility" flag. By default this is OFF. By enabling it NoCAB will, in addition to the above specification of primary industries, also include those industries which produce something but nothing is transported yet.

This is a workaround with a couple of complications. If NoCAB enters the game later and other AIs have already started to transport cargo NoCAB will not consider it as a primary industry. This has to do with the rigid way in which NoCAB now handles connections, it won't move on to secondary industries unless it serves those itself. If another player, for instance, serves a steel factory and NoCAB doesn't, NoCAB won't touch that until it builds a connection itself to this factory.

So this solution is far away from full proof, but to mess with such a fundamental issue is not going to happen so close to the release of NoCAB 2.0.0. Next release might be better suited towards NewGRF but this will at least allow NoCAB to play with FIRS and related NewGRFs.
2 NoCABs in action with the NewGRF compatibility flag enabled.
2 NoCABs in action with the NewGRF compatibility flag enabled.
Issues fixed:
- Don't crash if an unknown industry is removed.
- Added a compatibility mode for NewGRFs.

Bram
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests