Page 3 of 6

Re: Convoy: the bus loving AI (V8)

Posted: 08 Aug 2008 10:59
by GeekToo
dbkblk wrote:Erf i can't find this savegame anywhere.
I'll try to reproduce that bug !

EDIT: The AI always do the same error (even are the difficultys parameters), i can send you my openTTD installation so you can try to find the problem ? maybe by mail ?

I have to noticed that it worked with previous versions !
If it happens in any game, then you could start a game and make a new savegame. Or you could post or PM the cfg file.

Re: Convoy: the bus loving AI (V8)

Posted: 08 Aug 2008 11:58
by dbkblk
Hmm i'm stupid, ok it's with the post.

PS: It does the same with/without eGVTRS, ECS Vectors etc...

Re: Convoy: the bus loving AI (V8)

Posted: 10 Aug 2008 13:59
by GeekToo
Thanks for the savegame. I could reproduce the problem and analysed why Convoy did not build any stations.

Seems like the problem is not in Convoy, but in the ECS town vector newgrf. For some reason this newgrf sets the cargo acceptance of passengers in towns to very low values: 0 to max 8.

Then Convoy comes to the (correct) conclusion that it is not economically feasible to build a bus line.

When you disable the ECS town vector newgrf, it works as it should.

Re: Convoy: the bus loving AI (V8)

Posted: 10 Aug 2008 14:03
by Yexo
GeekToo wrote:Thanks for the savegame. I could reproduce the problem and analysed why Convoy did not build any stations.

Seems like the problem is not in Convoy, but in the ECS town vector newgrf. For some reason this newgrf sets the cargo acceptance of passengers in towns to very low values: 0 to max 8.

Then Convoy comes to the (correct) conclusion that it is not economically feasible to build a bus line.

When you disable the ECS town vector newgrf, it works as it should.
AFAIK, ecs does not change passengers acceptance / production in towns at all. However, it does introduce a new cargo with cargo class = CC_PASSENGERS. That cargo is tourists, and is indeed not accepted by normal houses, but by certain industries.

In AdmiralAI I've solved this by checking all cargos for cargoclass = CC_PASSENGERS and then choosing the one with the highest cargo acceptance in the center of the biggest town. I hope this helps you solve the problem:

Code: Select all

		local cargo_list = AICargoList();
		cargo_list.Valuate(AICargo.HasCargoClass, AICargo.CC_PASSENGERS);
		if (cargo_list.Count() == 0) {
			/* There is no passenger cargo, so AircraftManager is useless. */
			this._cargo_id = null;
			return;
		}
		if (cargo_list.Count() > 1) {
			local town_list = AITownList();
			town_list.Valuate(AITown.GetPopulation);
			town_list.Sort(AIAbstractList.SORT_BY_VALUE, false);
			local best_cargo = null;
			local best_cargo_acceptance = 0;
			foreach (cargo, dummy in cargo_list) {
				local acceptance = AITile.GetCargoAcceptance(AITown.GetLocation(town_list.Begin()), cargo, 1, 1, 5);
				if (acceptance > best_cargo_acceptance) {
					best_cargo_acceptance = acceptance;
					best_cargo = cargo;
				}
			}
			this._cargo_id = best_cargo;
		} else {
			this._cargo_id = cargo_list.Begin();
		}
Edit: After some testing, it seems that WrightAI fails because of the vary same reason as soon as ecs town vector is loaded.

Re: Convoy: the bus loving AI (V8)

Posted: 10 Aug 2008 20:12
by GeekToo
Thanks, your solution works like a charm (copied it shamelessly). Never realized that cc_classes could be added.

It's a nice test scenario: there are no road vehicles that can transport passengers, only trams. Currently Convoy only supports roadtype vehicles, but never checks whether engines for passengers are actually available.
So adding support for trams to Convoy would be necessary to make this set work. It has some impact though:

-check if vehicles for a certain roadtype support passenger transport ( road / tram)
-take that into account when building depots
-build the correct kind of road / tramtrack when building the road

are some of the things I can see that have to modified.

So for now I'll implement a check whether road vehicles support passenger transport, but implementing tram support is a nice challenge that I will put on my todo list

Re: Convoy: the bus loving AI (V9)

Posted: 10 Aug 2008 23:25
by GeekToo
Convoy V9
===========
-Solved countless number of bugs, which boosts it's performance quite a bit, I've seen it make 6.5M in 10 years, and also importantant, reduces the number of obvious mistakes when watching it.
-Implemented some of the issues of the previous posts ( except trams)

Re: Convoy: the bus loving AI (V9)

Posted: 12 Aug 2008 13:47
by dbkblk
Hi,

What i have to show isn't really a bug, but it need to be fixed !
*Take a look at the pic*

The pink player is convoy, the red is admiralai.
Admiral has built a road with the brigde (this is a nice road :D). One month later, convoy also decided to link both towns and it has built another road. The problem is that road is really useless because it try to cross the bridge...so convoy has lost money and built a weird road. That nice to have a "curvy" path system but i think it should try if there is any road before to build !

Anyway, this is even a great AI, well done !! Keep up :D

Re: Convoy: the bus loving AI (V9)

Posted: 12 Aug 2008 21:27
by GeekToo
dbkblk,

Some time ago I replaced my own pathfinding with the library pathfinder, so I think it's not really a Convoy issue, but every AI using the library pathfinder could encounter it.

Maybe you should post it in the pathfinder.road thread.

Re: Convoy: the bus loving AI (V9)

Posted: 12 Aug 2008 21:37
by Yexo
This was a problem in trunk some time ago, but it was fixed a few weeks ago. The only reason I can think of this happening is thas convoy started pathfinding the route before AdmiralAI built it. You seem to say something in your post: AdmiralAI build the route, and one month later Convoy build another one. It's very well possible that the pathfinding from convoy took more than a month. However, in that case Convoy should have handled the failed building and started pathfinding again (It gives an ERR_UNKNOWN in this case, not sure how Convoy handles that).

Re: Convoy: the bus loving AI (V9)

Posted: 12 Aug 2008 22:09
by GeekToo
Just checked, and it handles all errors, by retrying the build (eg for vehicle in the way) or replanning. Except.... the ERR_UNKNOWN, that error is only logged, without further action. So for Convoy 10, I'll change that to retry the planning.

Thanks for the info :D

Re: Convoy: the bus loving AI (V9)

Posted: 14 Aug 2008 15:07
by GeekToo
Convoy V10
============

-Handling of the ERR_UNKNOWN, so the pathfinding issue should be gone
-Initialisation of map related data moved from constructor to after Start
-Lots of cleaning up, things were getting messy (not ready)
-Improved line handling

Known bug: sometimes, when authority refuse to let Convoy build, it tries over and over again to make the same connection, hope to solve that soon.

Re: Convoy: the bus loving AI (V9)

Posted: 14 Aug 2008 15:53
by Zutty
GeekToo wrote:...Known bug: sometimes, when authority refuse to let Convoy build, it tries over and over again to make the same connection, hope to solve that soon.
Its not really a solution, but my quick for this is to simply abort if the rating is too low, and hope that it will increase over time.

Code: Select all

	// Check that we're able to build here first
	local rating = AITown.GetRating(town, AICompany.MY_COMPANY);
	local allowed = (rating == AITown.TOWN_RATING_NONE || rating > AITown.TOWN_RATING_VERY_POOR);
	if(!allowed) {
		AILog.Error(AITown.GetName(town) + " local authority refuses construction");
		return -1;
	}
Link to code

An interesting side-effect of this is that if I see this error repeated many times in the log, it usually means that the the bus stops in that town are going un-serviced, usually due to a bug in the pathfinder.

Re: Convoy: the bus loving AI (V10)

Posted: 20 Sep 2008 16:48
by TrueBrain
Today Rubidium and I went to this TJIP challenge. It was very fun. People all excited over OpenTTD, always a good thing :) The winner was a very clear winner (4 times the value of the next one, guys, NICE JOB!), although many 'cheated' (within the guidelines). But what I have to say: Convoy, you rule. Convoy was used as 'base-line', as everyone had access to it while developing, and was added in many rounds. Convoy didn't win, that was for sure, but it came in 2nd! Well, of course not for real, as it didn't really compete, but I still wanted to say: Convoy: VERY NICE JOB! :)

Re: Convoy: the bus loving AI (V10)

Posted: 21 Sep 2008 11:31
by Roujin
Well, is there (or will there be) any site telling us more about how the challenge went? Who got first? And so on...

Re: Convoy: the bus loving AI (V10)

Posted: 21 Sep 2008 20:10
by TrueBrain
Roujin wrote:Well, is there (or will there be) any site telling us more about how the challenge went? Who got first? And so on...
That is up to TJIP to arrange that. I hope they do, no idea if they will. The winners did promise me to put their AI online, so you can all see what it does .. it has some brilliant things, I can tell you :)

Re: Convoy: the bus loving AI (V10)

Posted: 21 Sep 2008 21:39
by Misha
I hope they do, there was little chance to see their tactics. (For speed reasons the window was very small.) And I think the number 2 had an interesting way to build stations.

Re: Convoy: the bus loving AI (V10)

Posted: 16 Nov 2008 13:07
by strubbi
Hi,

i`m playing around a little bit with the different AIs.
I found a bug addressed in route buidling:

Code: Select all

xxxxxx  xxxsxx
xxcwxx  xxcwsx
wwwwwx  wwwwws
wcwwwx  wcwwws
wxxxxx  wxsssw

x land
c city
w water
s street
So Convoy builts a route around the sea and loses a lot of money and the game.

Re: Convoy: the bus loving AI (V10)

Posted: 20 Nov 2008 09:06
by bokkie
Convoy has problems with water, it seems to choose two cities to connect but doesn't take into account that it may be hard to reach the other city. In the screenshot can be seen that Convoy tries two cities on the right and two on the left but (at least for the time being ;)) fails to connect them.

Re: Convoy: the bus loving AI (V10)

Posted: 13 Jan 2009 23:19
by GeekToo
I haven't had much time lately to develop Convoy further :( , but the merging of NoAI to trunk seemed like a good time to update to the latest API version. So no new features, it just works again.

To the NoAI devs: congratulations with the big milestone! :bow:

Re: Convoy: the bus loving AI (V10)

Posted: 15 Jan 2009 20:38
by GeekToo
And updated to today's API