Convoy: train support testversion

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
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V8)

Post 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.
dbkblk
Traffic Manager
Traffic Manager
Posts: 154
Joined: 29 Mar 2008 18:38

Re: Convoy: the bus loving AI (V8)

Post by dbkblk »

Hmm i'm stupid, ok it's with the post.

PS: It does the same with/without eGVTRS, ECS Vectors etc...
Attachments
StartPointForConvoy.sav
(197.33 KiB) Downloaded 254 times
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V8)

Post 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.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Convoy: the bus loving AI (V8)

Post 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.
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V8)

Post 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
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V9)

Post 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)
Attachments
Convoy.tar
(50 KiB) Downloaded 252 times
dbkblk
Traffic Manager
Traffic Manager
Posts: 154
Joined: 29 Mar 2008 18:38

Re: Convoy: the bus loving AI (V9)

Post 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
Attachments
Convoy-WeirdRoad.png
(198.5 KiB) Downloaded 268 times
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V9)

Post 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.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Convoy: the bus loving AI (V9)

Post 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).
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V9)

Post 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
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V9)

Post 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.
Attachments
Convoy.tar
(40 KiB) Downloaded 521 times
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: Convoy: the bus loving AI (V9)

Post 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.
PathZilla - A networking AI - Now with tram support.
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: Convoy: the bus loving AI (V10)

Post 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! :)
The only thing necessary for the triumph of evil is for good men to do nothing.
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: Convoy: the bus loving AI (V10)

Post 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...
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: Convoy: the bus loving AI (V10)

Post 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 :)
The only thing necessary for the triumph of evil is for good men to do nothing.
Misha
Engineer
Engineer
Posts: 18
Joined: 21 Jul 2008 17:39

Re: Convoy: the bus loving AI (V10)

Post 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.
strubbi
Engineer
Engineer
Posts: 1
Joined: 16 Nov 2008 13:00

Re: Convoy: the bus loving AI (V10)

Post 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.
Attachments
Convoy road around the see, 1. Mai 1952.sav
Convoy building road around the see and loses
(73.34 KiB) Downloaded 262 times
bokkie
Transport Coordinator
Transport Coordinator
Posts: 327
Joined: 19 Jan 2007 19:26

Re: Convoy: the bus loving AI (V10)

Post 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.
Attachments
Geen naam, 20 Mrt 1945.png
(54.43 KiB) Downloaded 190 times
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V10)

Post 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:
Attachments
Convoy.tar
(40 KiB) Downloaded 264 times
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: Convoy: the bus loving AI (V10)

Post by GeekToo »

And updated to today's API
Attachments
Convoy.tar
Convoy v10, api 15/01/2009 r15098
(40 KiB) Downloaded 264 times
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests