Page 17 of 25

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

Posted: 20 Apr 2010 00:11
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

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

Posted: 20 Apr 2010 00:15
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 :).

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

Posted: 20 Apr 2010 00:23
by Rubidium
Maybe it finds "old" compatability scripts first for whatever reason? Somewhere in your home directory or so?

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

Posted: 20 Apr 2010 18:27
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.

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

Posted: 20 Apr 2010 22:02
by NekoMaster
Im very sorry to say, the 2.0.6 Preview build also failed, crashing with a HasNext does not exist error.

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

Posted: 21 Apr 2010 00:07
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 :/

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

Posted: 21 Apr 2010 15:49
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.

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

Posted: 21 Apr 2010 22:51
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?

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

Posted: 21 Apr 2010 23:08
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;
		}
	}
}

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

Posted: 21 Apr 2010 23:24
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

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

Posted: 22 Apr 2010 05:31
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.

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

Posted: 22 Apr 2010 10:42
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.

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

Posted: 22 Apr 2010 10:50
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

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

Posted: 22 Apr 2010 11:36
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?

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

Posted: 22 Apr 2010 11:56
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.

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

Posted: 22 Apr 2010 12:51
by TheDarkGiganotosaur
Ah, okay.

I only thought like that because the HasNext() code appeared to be obsolete, but thanks for answering.

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

Posted: 27 Apr 2010 22:09
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. ;-)

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

Posted: 28 Apr 2010 00:43
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

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

Posted: 28 Apr 2010 20:15
by SirkoZ
Thank you. :-)

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

Posted: 02 May 2010 22:54
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.