NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.1.3

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
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by NekoMaster »

I dunno why, but Admiral AI works in nightlies, but NoCAB doesnt, even though I have both 0.0.7 and 1.0.0
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by Morloth »

NekoMaster wrote:I dunno why, but Admiral AI works in nightlies, but NoCAB doesnt, even though I have both 0.0.7 and 1.0.0
Could you maybe try this version? I've updated NoCAB to the 1.0 API version. Hopefully this will work better... somehow :).
Attachments
NoCAB.tar
NoCAB 2.0.6 (preview)
(420 KiB) Downloaded 92 times
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by Rubidium »

Maybe it finds "old" compatability scripts first for whatever reason? Somewhere in your home directory or so?
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by NekoMaster »

Rubidium wrote:Maybe it finds "old" compatability scripts first for whatever reason? Somewhere in your home directory or so?
No, since i need to keep openttd portable everything is in my openttd directory on my flash drive. There is no OpenTTD directory in my home folder.
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by NekoMaster »

Im very sorry to say, the 2.0.6 Preview build also failed, crashing with a HasNext does not exist error.
Attachments
NoCAB 2.0.6 Preview<br />OpenTTD r19683
NoCAB 2.0.6 Preview
OpenTTD r19683
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by Morloth »

NekoMaster wrote:Im very sorry to say, the 2.0.6 Preview build also failed, crashing with a HasNext does not exist error.
This makes less and less sense... Like I said before the HasNext is in the core API and hasn't changed (as far as I know...). It seems like something is really messed up with your build. Could you test it with any other AI like AdmiralAI, as I'm sure you should experience similar kinds of problems. This is just very weird :/
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by NekoMaster »

Morloth wrote:
NekoMaster wrote:Im very sorry to say, the 2.0.6 Preview build also failed, crashing with a HasNext does not exist error.
This makes less and less sense... Like I said before the HasNext is in the core API and hasn't changed (as far as I know...). It seems like something is really messed up with your build. Could you test it with any other AI like AdmiralAI, as I'm sure you should experience similar kinds of problems. This is just very weird :/
Admiral AI works in Nightlies, but NoCAB doesn't work. Im using builds downloaded form the website, i rarely compile regular nightlies from source.
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
User avatar
Michiel
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 13 Jul 2008 00:57
Contact:

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by Michiel »

Just a thought (didn't look at the source) - are you invoking HasNext() on a different kind of object than you were expecting? Maybe a single object, or a Squirrel array, instead of an AIList?
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by Morloth »

Michiel wrote:Just a thought (didn't look at the source) - are you invoking HasNext() on a different kind of object than you were expecting? Maybe a single object, or a Squirrel array, instead of an AIList?
Well... The piece of code the error is founds is the following. It is the same as the code of Rondje to construct a HQ. If someone can find a flaw I'd very happy to fix it :).

Code: Select all

function NoCAB::BuildHQ()
{
	// Check if we have an HQ.
	if (AICompany.GetCompanyHQ(AICompany.COMPANY_SELF) != AIMap.TILE_INVALID) {
		Log.logDebug("We already have an HQ, continue!");
		return;
	}
	Log.logInfo("Build HQ!");
	
	// Find biggest town for HQ
	local towns = AITownList();
	towns.Valuate(AITown.GetPopulation);
	towns.Sort(AIAbstractList.SORT_BY_VALUE, true);
	local town = towns.Begin();
	
	// Find empty 2x2 square as close to town centre as possible
	local maxRange = Sqrt(AITown.GetPopulation(town)/100) + 5; //TODO check value correctness
	local HQArea = AITileList();
	
	HQArea.AddRectangle(AITown.GetLocation(town) - AIMap.GetTileIndex(maxRange, maxRange), AITown.GetLocation(town) + AIMap.GetTileIndex(maxRange, maxRange));
	HQArea.Valuate(AITile.IsBuildableRectangle, 2, 2);
	HQArea.KeepValue(1);
	HQArea.Valuate(AIMap.DistanceManhattan, AITown.GetLocation(town));
	HQArea.Sort(AIList.SORT_BY_VALUE, true);
	
	for (local tile = HQArea.Begin(); HQArea.HasNext(); tile = HQArea.Next()) {
		if (AICompany.BuildCompanyHQ(tile)) {
			return;
		}
	}
}
User avatar
NekoMaster
Tycoon
Tycoon
Posts: 4001
Joined: 16 Aug 2008 22:26
Skype: neko-master
Location: Oshawa, Ontario, CANADA

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by NekoMaster »

If the hasnext is related to build a HQ, why not just remove the code for HQ building? I could go for years and forget to build a HQ untill after 10 to 50 years of game play
Image Proud Canadian Image
Nekomasters Projects! (Downloads available on BaNaNaS!) \(>^w^<)/
# NARS ADD-ON SET 2CC | 2cc Rapid Transit For Me! (2ccRTFM) | 2cc Wagons In NML (2ccWIN)
# NML Category System (Organize your GRFS!) <- TT-Forums Exclusive Download!
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by Zuu »

NekoMaster wrote:If the hasnext is related to build a HQ, why not just remove the code for HQ building? I could go for years and forget to build a HQ untill after 10 to 50 years of game play
With that attitude, high quality code is not created. I can see workarounds for his code to not use HasNext() that would probably make his AI invulnerable to this error, but that does not solve the root problem.

Edit: This would probably work regardless of API version:

Code: Select all

   foreach (tile in HQArea) {
      if (AICompany.BuildCompanyHQ(tile)) {
         return;
      }
   }
But as said above, it hardly solves the root problem.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
TheDarkGiganotosaur
Engineer
Engineer
Posts: 33
Joined: 24 Mar 2010 15:49
Location: Portugal

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by TheDarkGiganotosaur »

I, for one, prefer the HQ (Headquarters.) to be built. Even though the HQ has no purpose whatsoever, that building is still essential and important for the companies as it is their center of operations.

As for the HasNext() code problem, if there is no solution, why not check the other AI scripts for different HQ building method codes? But permission must be asked first before copying the code, of course.
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 - Trains, Trucks, Busses, Aircraft and Ships! v2.0.5

Post by Morloth »

I agree, also this isn't the only place in the code where HasNext() appears. Since it is part of the core API for NoAI one can only guess what other features are not working on your platform. So I could try to revamp my code to work around this, but the bottom line is that the code should work and in all tests I've done it does work... Unless someone else turns up with the same problem the only thing I can conclude is that the problem is somehow at your end. I find if quite weird AdmiralAI does work for you at it contains the same HasNext function so it should crash on that as well when that piece of code is hit upon.

However, in NoCAB 2.0.6 I've made the construction of the HQ optional. So if you turn it off it won't execute that piece of code, but I won't be too surprised if a couple of lines down another problem will pop up :/. But have a look and hopefully it will work :).
- Bram
User avatar
TheDarkGiganotosaur
Engineer
Engineer
Posts: 33
Joined: 24 Mar 2010 15:49
Location: Portugal

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.6

Post by TheDarkGiganotosaur »

Well, I guess that each time a new version of OpenTTD is out, the AI scripts whose codes worked before will no longer work...

I could be wrong but what if this is the case?
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 - Trains, Trucks, Busses, Aircraft and Ships! v2.0.6

Post by Morloth »

TheDarkGiganotosaur wrote:Well, I guess that each time a new version of OpenTTD is out, the AI scripts whose codes worked before will no longer work...

I could be wrong but what if this is the case?
Luckily this is not the case. The API is more or less stabilized which means that most changes between new versions of OpenTTD will be the inclusion of new functions which allow the AI to gain more information of the game world (like the option to get the maximum speed trains can travel over rails). Besides Yexo included compatibility scripts which will guarantee that even if the AI uses an API which is out of date it will continue the function correctly. The above issue is, as far as I know, quite unique and not related to newer versions of OpenTTD.

But the API 1.0 which is the one in use by OpenTTD 1.0.x will be supported for quite a while so for the next couple of years(?) AIs build on top of that should continue to function with no problems.

Hope this answers your question, otherwise Yexo will be able to give a better answer as he is actually the developer of NoAI.
User avatar
TheDarkGiganotosaur
Engineer
Engineer
Posts: 33
Joined: 24 Mar 2010 15:49
Location: Portugal

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.6

Post by TheDarkGiganotosaur »

Ah, okay.

I only thought like that because the HasNext() code appeared to be obsolete, but thanks for answering.
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
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.6

Post by SirkoZ »

Morloth - please mend the ship depot building fashion - mostly they are built with one end to the dock or the coast, however, very quickly they wind up being trapped from one side by the other depot, from another by the coast or the dock. The most part of the 100 ships I allow in my games get trapped in such depots till the point they are sent back to the same depot, yet can't quite reach it by not being able to peek out of it even one yard. ;-)
Morloth
Transport Coordinator
Transport Coordinator
Posts: 378
Joined: 07 Feb 2008 14:06
Location: Glasgow

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.6

Post by Morloth »

SirkoZ wrote:Morloth - please mend the ship depot building fashion - mostly they are built with one end to the dock or the coast, however, very quickly they wind up being trapped from one side by the other depot, from another by the coast or the dock. The most part of the 100 ships I allow in my games get trapped in such depots till the point they are sent back to the same depot, yet can't quite reach it by not being able to peek out of it even one yard. ;-)
Good point, fixed in the newest version :).

Version update:
* Better depot placement of ships (thx SirkoZ).
* Vehicles are build quicker.

Cheers,
Bram
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: NoCAB - Trains, Trucks, Busses, Aircraft and Ships! v2.0.7

Post by Zuu »

While running a test game I noticed your vehicles do not use non-stop orders.

If you use the order flag AIOrder.AIOF_NON_STOP_INTERMEDIATE it will enable go non-stop. Using this flag your vehicles will not stop at stations they pass on the way to their next destination. With drive through bus/truck stops and if you build drive-through rail stations that some trains will just pass by, using this flag the vehicles will no longer stop shortly at the intermediate stations.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 7 guests