New AI writer needs a little help.

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

Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: New AI writer needs a little help.

Post by Dezmond_snz »

Sorry for asking (possibly) stupid question but how my AI can get value of some game setting?
AIController.GetSetting(str) is for AI setting only?

(edit)
Oh, found it... AIGameSetting :oops: Sorry again.
Russia
User avatar
Xander
Route Supervisor
Route Supervisor
Posts: 485
Joined: 18 May 2007 12:47
Location: Oxford
Contact:

Re: New AI writer needs a little help.

Post by Xander »

hehe - no worries :)

Also don't forget that some of those values are indexed like subsidy value which can be a little confusing when you're expecting something like "4" but are getting "3" :)
Real Tycoons do it on Trains!

JAMI: Just Another Moronic Intelligence
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: New AI writer needs a little help.

Post by Dezmond_snz »

And new one: how can AI check if building tree at tile will affect rating of needed town? Will AITile.GetClosestTown(...) show that?
Russia
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: New AI writer needs a little help.

Post by Yexo »

Dezmond_snz wrote:And new one: how can AI check if building tree at tile will affect rating of needed town? Will AITile.GetClosestTown(...) show that?
Two requirements:
needed_town == AITile.GetClosestTown(tile);
AIMap.DistanceManhattan(tile, AITown.GetLocation(needed_town)) < AIGameSettings.GetValue("economy.dist_local_authority");
Dezmond_snz
Engineer
Engineer
Posts: 58
Joined: 19 Apr 2009 11:50

Re: New AI writer needs a little help.

Post by Dezmond_snz »

Yexo wrote:
Dezmond_snz wrote:And new one: how can AI check if building tree at tile will affect rating of needed town? Will AITile.GetClosestTown(...) show that?
Two requirements:
needed_town == AITile.GetClosestTown(tile);
AIMap.DistanceManhattan(tile, AITown.GetLocation(needed_town)) < AIGameSettings.GetValue("economy.dist_local_authority");
Thanks.

Can town and industry have same Ids or Id is unique for all objects in game? (e.g. townId=1 and industryId=1 at same game)
Russia
User avatar
Dustin
Transport Coordinator
Transport Coordinator
Posts: 272
Joined: 07 Dec 2005 19:22

Re: New AI writer needs a little help.

Post by Dustin »

Dezmond_snz wrote:
Yexo wrote:
Dezmond_snz wrote:And new one: how can AI check if building tree at tile will affect rating of needed town? Will AITile.GetClosestTown(...) show that?
Two requirements:
needed_town == AITile.GetClosestTown(tile);
AIMap.DistanceManhattan(tile, AITown.GetLocation(needed_town)) < AIGameSettings.GetValue("economy.dist_local_authority");
Thanks.

Can town and industry have same Ids or Id is unique for all objects in game? (e.g. townId=1 and industryId=1 at same game)

They can and will. Not only that, the ID's get recycled. So Industry 1 might close and later another industry would turn up with the same ID.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 2 guests