[NoGo] Neighbours are important

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

Guvnor
Engineer
Engineer
Posts: 10
Joined: 01 Nov 2012 01:03

Re: [NoGo] Neighbours are important

Post by Guvnor »

Zuu wrote:If you figure out good settings to use with the japan set and post them back here, I could include them in the readme (which is available in-game using the readme-button). Or possible an on/off switch in the settings window that reduce only the goods cargo, but let passengers/mail/food/water/etc. remain at the usual level.
It looks to me like the Japanese set does not have a setting that will get around this issue. You will have to allow the disabling of goods entirely or just avoid the Japanese buildings.
Guvnor
Engineer
Engineer
Posts: 10
Joined: 01 Nov 2012 01:03

Re: [NoGo] Neighbours are important

Post by Guvnor »

function GoalTown::GetNeighborhoodFactor(self_population)
{
local factor = 100;

foreach(n in this.neighbors)
{
local diff = GSTown.GetPopulation(n.id) - self_population;
factor -= diff * 3;
}

factor = max(factor, 70);
factor = min(factor, 500);
Zuu,

Once towns (that are neighbors of one another) reach a size of about 9 to 10 thousand or so the cargo requirements start to oscillate between min and max. The largest town will be set at maximum requirement while the two smallest will be set to minimum. A month later, one of the smaller towns will grow and become the largest, it will then have the maximum requirement while the other two will be at minimum. This repeats forever.

I took a look at your code and I see that your NeighborhoodFactor is based on absolute numbers rather than percentages. At town sizes near 12,000 your factor resolves to numbers in the 25,000 range, which then gets 'min'ed to 500.

Example:

Month 1: Town A requires 6500 passengers, Town B requires 800, Town C requires 800
Month 2: Town A requires 800 passengers, Town B requires 6500, Town C requires 800
Month 3: Town A requires 800 passengers, Town B requires 800, Town C requires 6500
repeat
.
.
.
.

Guvnor
LSky
Traffic Manager
Traffic Manager
Posts: 170
Joined: 25 Jun 2005 10:44
Location: The Netherlands

Re: [NoGo] Neighbours are important

Post by LSky »

Guvnor wrote:
Once towns (that are neighbors of one another) reach a size of about 9 to 10 thousand or so the cargo requirements start to oscillate between min and max. The largest town will be set at maximum requirement while the two smallest will be set to minimum. A month later, one of the smaller towns will grow and become the largest, it will then have the maximum requirement while the other two will be at minimum. This repeats forever.
I believe this happens either before 9-10k since I am experiencing this with smaller cities as well, or it just happens regardless of the city size.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] Neighbours are important

Post by Zuu »

Thanks for your report. I'll have to think on a solution that fix the problem while not modifying the behaviour of existing games in unwanted ways.

One option is to mark the next version unable to load older games than its own version. Then OpenTTD will search for an older version of the GS that can load it.

Another option is to have a setting. However Im unsure if it is possible to introduce a new setting that is on by default for new games but not for old games.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: [NoGo] Neighbours are important

Post by Wasila »

I know this post may make people quite angry, but is there a way to disable this script in a running game? It's just, with such stringent requirements, I don't see any town growth happening in this game. Help much appreciated!

Wasila
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: [NoGo] Neighbours are important

Post by romazoon »

make your savegame become a scenario file, load it in the scenario editor then...u should be able to modificate the parameter for the script (and make requirement easier) and maybe to take it away... but make a copy of your savegame... cause i have no clue if it's bugsafe...
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: [NoGo] Neighbours are important

Post by Wasila »

Well, removing the script altogether kept crashing my scenario editor, so I settled with making it easier. This doesn't, however, seem to have actually affected the amount of cargo needed? I reduced it to 30%, but I'm getting the same requirements, and no growth...

EDIT: Forget that, it did actually change. Thank you! There's no way of circumventing the goods requirement, is there?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] Neighbours are important

Post by Zuu »

If you found a way to crash OpenTTD, please report it to the bug tracker.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: [NoGo] Neighbours are important

Post by Wasila »

Well, I reported it, but the problem still stands that removing the script just breaks the mechanism (as the 'Cargo needed for town growth' info remains and the towns still don't grow). I assume there's nothing I can do?
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] Neighbours are important

Post by Zuu »

You can edit the script locally on your computer. Just untar and edit the nut files. In town.nut there is a method that updates the cargo requirements. I think you can alter it to set zero as cargo requirement for all cargo types. This will however affect all your games that use this script.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Wasila
Tycoon
Tycoon
Posts: 1498
Joined: 15 Mar 2008 07:02

Re: [NoGo] Neighbours are important

Post by Wasila »

Ah, I managed to set the requirements to 0. How about the number of days it takes a town to grow? Suddenly, all my towns are growing really quickly, despite the growth speed setting under 'Economy' being set to 'Normal'.

Thanks,
Wasila
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] Neighbours are important

Post by Zuu »

Wasila wrote:Ah, I managed to set the requirements to 0. How about the number of days it takes a town to grow? Suddenly, all my towns are growing really quickly, despite the growth speed setting under 'Economy' being set to 'Normal'.

Thanks,
Wasila
  1. Remove this.ManageTowns(); from main.nut (should be in the main loop located in the Start() method)
  2. Change "Allow funding buildings" to On
The first step disable the GS completely from setting the town growth rate.

The second step should according to the GS API documentation cause OpenTTD to regulate the town growth rate actively:
API doc wrote:Note:
  • If 'Fund Building' and 'economy.town_growth_rate' is active, the game will often set a new GrowthRate.
Hopefully this is enough to return town growth to normal.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] Neighbours are important

Post by Zuu »

Can any of you who had problems with oscillate post a save game that demonstrate this behaviour? (please use either an official stable or nightly version of OpenTTD)

I have implemented a different method to compare town sizes that I hope should be less prone to extreme oscillation, however it would be useful to verify that the new method is working better. Some oscillation can probably still occur if three towns are of about equal size, but hopefully at an acceptable rate.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
nightfire_ball
Engineer
Engineer
Posts: 3
Joined: 18 Jan 2013 10:22

Re: [NoGo] Neighbours are important

Post by nightfire_ball »

hi all.
I don`t want to be offtopic too much,but since it is about town growth, i just want to ask,where can i find the script wich tells me what a town needs to grow. i seen it on multiplayer and I would like to have it.

Many 10x
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [NoGo] Neighbours are important

Post by Zuu »

You have to be more specific. This script do add requirements for town growth. However, the server that you were playing might have used this script or some other script that add town growth requirements. On BaNaNaS there are several scripts that deal with town growth which authors have published. In addition to that, there are people who keep their script to themself to have their cool and exclusive server.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
nightfire_ball
Engineer
Engineer
Posts: 3
Joined: 18 Jan 2013 10:22

Re: [NoGo] Neighbours are important

Post by nightfire_ball »

to be more specific: when i was playing on the server, if I clicked on a town,near the "town is not growin" it was written that "this town requires - water -food to grow. i feel bad now that i didn`t made screenshot to have it, but that time

i wasn`t thinking about wanting such a thing. now honestly i am curios.. many 10x
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: [NoGo] Neighbours are important

Post by krinn »

without any GS a town from desert do that:
Water: need
Food: need
Town doesn't grow

Are you sure you haven't just play a server in desert without any GS ?
nightfire_ball
Engineer
Engineer
Posts: 3
Joined: 18 Jan 2013 10:22

Re: [NoGo] Neighbours are important

Post by nightfire_ball »

yes,i think so. it was somethink like that. i recall that where some palmtrees,and yes i think it was desert ground.
for some reason i don`t know the meaning of GS,maybe you can tell me.
many 10x
User avatar
Erik1984
Traffic Manager
Traffic Manager
Posts: 151
Joined: 13 Sep 2006 15:54
Location: $HOME

Re: [NoGo] Neighbours are important

Post by Erik1984 »

nightfire_ball wrote:yes,i think so. it was somethink like that. i recall that where some palmtrees,and yes i think it was desert ground.
for some reason i don`t know the meaning of GS,maybe you can tell me.
many 10x
GS means Game Script (like "Neighbors are important") in this context I assume :P What you describe seems indeed like the standard situation in subtropical maps.

On Topic:
Thanks Zuu for fixing the problem regarding water requirements for non-desert towns. When I have my new PC I will certainly try a subtropical map with your script.
User avatar
Erik1984
Traffic Manager
Traffic Manager
Posts: 151
Joined: 13 Sep 2006 15:54
Location: $HOME

Re: [NoGo] Neighbours are important

Post by Erik1984 »

Yexo wrote:GSTile.IsDesertTile checks if the tile is empty and desert. This is most likely an oversight.
Determining if a town needs water to grow seems to go pretty well in the standard game (without GS). How does the original game determine this?
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 18 guests