Town/Town House Cargo Acceptance

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

Post Reply
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Town/Town House Cargo Acceptance

Post by Zutty »

Hi all,

More cargo based questions for you. How are people handling cargos like Gasoline in ECS Vectors?

I can find whether a cargo is produced in towns with AITown.GetMaxProduction() and I can find a sub-set of cargos accepted in towns with AICargo.GetTownEffect().

Something like the following...

Code: Select all

foreach(c, _ in AICargoList()) {
	local lbl = AICargo.GetCargoLabel(c);

	if(AICargo.GetTownEffect(c) != AICargo.TE_NONE) AILog.Info(lbl + " accepted in towns");
		
	local townprod = 0;
	foreach(t, _ in AITownList()) {
		townprod += AITown.GetMaxProduction(t, c);
	}
	if(townprod > 0) AILog.Info(lbl + " produced in towns");
}
However this does not capture the fact that Gasoline is accepted at petrol statons. If I'm not mistaken ECS allows town houses to accept or produce any cargo, just like industries. At the moment as far as I can tell an AI has no way to deal with this. Are there any plans to address this? Or am Im missing something?

Also may I ask what is meant by freight in the context of AICargo.IsFreight()? What does true from this function imply in practical terms?

Thanks :)
PathZilla - A networking AI - Now with tram support.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Town/Town House Cargo Acceptance

Post by Yexo »

Also may I ask what is meant by freight in the context of AICargo.IsFreight()? What does true from this function imply in practical terms?
The information I gave above was based on a wrong assumption. Frosch was so kind to correct me. The correct information is:

When IsFreight returns true for a cargo than the "freight train multiplier" applied to it. To determine whether you'll need a bus or a truck stop, see if the cargo is in the passenger cargo class.
Last edited by Yexo on 24 Mar 2009 18:13, edited 1 time in total.
User avatar
Zutty
Director
Director
Posts: 565
Joined: 22 Jan 2008 16:33

Re: Town/Town House Cargo Acceptance

Post by Zutty »

Thanks for the reply Yexo.

Humans CAN query tiles with the land area information tool, but I have no idea how this could be used in an API function.
PathZilla - A networking AI - Now with tram support.
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: Town/Town House Cargo Acceptance

Post by Yexo »

Zutty wrote:Thanks for the reply Yexo.

Humans CAN query tiles with the land area information tool, but I have no idea how this could be used in an API function.
If you don't mind to query per tile, you can use AITile.GetCargoAcceptance and AITile.GetCargoProduction with width=1 and height=1.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 15 guests