Page 1 of 11

[NoGo] Neighbours are important

Posted: 27 Dec 2011 20:12
by Zuu
As there were no scripts uploaded yet that set town goals, I came up with the idea of uploading a variant of of the script that TrueBrain wrote for NoGo and was used on the #openttdcoop test server.

The basis is that towns has a requirement of passengers, mail, goods, food etc. When the town size grows, the requirement grows. Thus you have to deliver more and more in order to keep growing the town.

What this variant also adds is a neighbour factor. If a town is smaller than its closest neighbours, it will have a neighbour factor < 1. If the town on the other hand is larger than its neighbours the factor will be > 1. Thus, to grow a large town to become even larger, you might want to consider growing its neighbours too, especially if they are small.

Since the script has to find out the neighbours of all towns, it takes quite some opcodes to initialize. Thankfully OpenTTD gives GameScripts 2500 ticks in the map generation process which is enough for most maps. But if you play 1024x1024 or larger with high town density, you might need to run the game in fast forward before the goals are set up.

Download
Via online content or through the bananas website

Currently no libraries are required.

Re: [NoGo] Neighbours are important

Posted: 30 Dec 2011 07:56
by Splime
This script is a lot of fun to play with! Though I was wondering, is it possible to make the supply requirements lower, or set some sort of difficulty parameter? I'd like to be able to have my cities grow a little bit faster!

Re: [NoGo] Neighbours are important

Posted: 30 Dec 2011 12:35
by Zuu
Sure, I was also thinking about adding a parameter to disable the neighbours parameter, which will make it easier and allow playing that style too.

Re: [NoGo] Neighbours are important

Posted: 30 Dec 2011 14:08
by TrueBrain
How many ticks do you need in the generation to find out the neighbour graph? (the current value is set as a: this-should-never-be-reached-but-I-have-to-input-some-value)

Re: [NoGo] Neighbours are important

Posted: 05 Jan 2012 19:18
by Zuu
With a 2048x2048 map that have high density the setup took 29510 ticks. On a different map of the size 2048x1024 it took 11079 ticks.

These measures were made with about the same amount of setup as in version 1. In version 2 there will be a new feature that will eat a few more ticks but it doesn't have any expansive neighbour lookup but a tile scanner so it is not completely free.

With the new features for version 2 enabled, the setup for a 2048x2048 map took 38863 ticks.


On IRC Eddi mentioned that the amount of towns possible is limited by the town generator. So for the record, I've used the Swedish town names that are included in OpenTTD.


Edit: And for comparison, a 512x512 with the version 2 features enabled took 156 ticks.

Re: [NoGo] Neighbours are important

Posted: 05 Jan 2012 19:46
by Zuu
Update - Version 2

Changes:
  • Towns growth can get reduced/stopped when they get congested
  • When a town gets congested, a news message is sent to all companies with road vehicles in the town area that is tested for congestion. A sign is also placed on the town tile to note that the town is congested.
  • Global goals are created for each congested town to reduce the congestion there. At the moment there is no award, not even a news message for accomplished goals. Only way to tell is that the congestion sign in the town centre is removed.
  • Settings:
    • You can now disable that neighbours town sizes affect growth goals
    • The cargo delivery goals can now be scaled by a factor.
    • What happens with congested towns: [no effect, towns grow slower, towns stop grow]
    • A scale factor to scale the limit of number of vehicles in the town centre at which point the town is considered to be congested. The actual limit depends also on the town population.
    Unnamed, 27th Apr 1950.png
    Unnamed, 27th Apr 1950.png (10.65 KiB) Viewed 43518 times
I would be happy if those of you who play with this GameScript reports back what kind of values on the two scale factors that you find good. That way I can see if I need to adjust the baseline or the recommended easy/medium/hard values.

I've not actually playtested the congestion feature, only by ether manually jamming towns with buses or using the TownCars AI.

The idea is that when you play against the cargo goals it can give some extra challenge on how you distribute your cargo from feeder stations to the towns. Currently it only consider road vehicles so I guess it could make for some interesting decisions if rail, ships and air is a bit expansive compared to road vehicles.
Oskarfors Transport, 12th Apr 1956.png
Oskarfors Transport, 12th Apr 1956.png (120.72 KiB) Viewed 43518 times
goal - neighbors-v2.tar
(20 KiB) Downloaded 877 times

Re: [NoGo] Neighbours are important

Posted: 06 Jan 2012 23:16
by nalyu
I am now playing this but after a while my town asks for water. The only problem is that the town has not build a watertower. and i can't fund one myself because when i try it says "can't construct this industry type here... ...can only be built in towns."

My parameters are set as followed:
Cargo req. depends on : Size of current town size
Cargo goal factor (in%): 150
Congested towns: disabled

2nd thing: Cargo goal is @ hard however my town has now a population of 3.626 Goal for cargo = 5 passengers, 1.000 liters of water and 2 tonnes of food i think those values are a bit low for the size of the town.

Edit 1: Now started at a town close to it that already had a watertower.

Re: [NoGo] Neighbours are important

Posted: 07 Jan 2012 12:54
by AndersI
nalyu wrote:I am now playing this but after a while my town asks for water. The only problem is that the town has not build a watertower. and i can't fund one myself because when i try it says "can't construct this industry type here... ...can only be built in towns."
I believe the water towers must be built on top of a town house. Did you try that?

Re: [NoGo] Neighbours are important

Posted: 07 Jan 2012 14:39
by nalyu
AndersI wrote:
nalyu wrote:I am now playing this but after a while my town asks for water. The only problem is that the town has not build a watertower. and i can't fund one myself because when i try it says "can't construct this industry type here... ...can only be built in towns."
I believe the water towers must be built on top of a town house. Did you try that?
That worked but it was not needed because started with a town close to it that had a watertower and that one is now much bigger.
Thanks anyway.

Re: [NoGo] Neighbours are important

Posted: 07 Jan 2012 16:20
by Zuu
nalyu wrote:My parameters are set as followed:
Cargo req. depends on : Size of current town size
Cargo goal factor (in%): 150
Congested towns: disabled

2nd thing: Cargo goal is @ hard however my town has now a population of 3.626 Goal for cargo = 5 passengers, 1.000 liters of water and 2 tonnes of food i think those values are a bit low for the size of the town.
Those low numbers are clearly a bug. I've confirmed that when you set cargo requirement to depend only on town size, you get the goals 1/100 compared to what they should be. Soon there will be a new version that fixes this issue.

Unfortunately the only way to fix your current game is to hack your version 2 of this game script so that it contains the fix that will be in version 3. For that purpose I've attached both a patch that can be applied to town.nut and a new town.nut that you can replace the old one with. To do so, find the tar file with this GameScript. Probably located in OpenTTD/content_download/game. Move that one up to OpenTTD/game. untar and preferable remove the tar file to not have two different version 2 in the search path. Then either replace town.nut or apply the attached patch.

Re: [NoGo] Neighbours are important

Posted: 07 Jan 2012 16:56
by Zuu
Update - Version 3

Changes:
  • Fixed bug that caused the goals to be 1/100 of the intended values when the neighbours factor was turned off.
  • Reduced the maximum neighbour factor from 800% to 500%. That is large towns with small neighbours can now at maximum get their goals raised by 500% compared to 800% before. Perhaps this will still give a high penalty if you don't also grow the neighbours, but not as extremely high
  • Added a readme.txt

Re: [NoGo] Neighbours are important

Posted: 08 Jan 2012 05:07
by nalyu
Zuu wrote:
nalyu wrote:My parameters are set as followed:
Cargo req. depends on : Size of current town size
Cargo goal factor (in%): 150
Congested towns: disabled

2nd thing: Cargo goal is @ hard however my town has now a population of 3.626 Goal for cargo = 5 passengers, 1.000 liters of water and 2 tonnes of food i think those values are a bit low for the size of the town.
Those low numbers are clearly a bug. I've confirmed that when you set cargo requirement to depend only on town size, you get the goals 1/100 compared to what they should be. Soon there will be a new version that fixes this issue.

Unfortunately the only way to fix your current game is to hack your version 2 of this game script so that it contains the fix that will be in version 3. For that purpose I've attached both a patch that can be applied to town.nut and a new town.nut that you can replace the old one with. To do so, find the tar file with this GameScript. Probably located in OpenTTD/content_download/game. Move that one up to OpenTTD/game. untar and preferable remove the tar file to not have two different version 2 in the search path. Then either replace town.nut or apply the attached patch.
As that town had only a population of about 4k it was easier for me to start over but thanks anyway.

Re: [NoGo] Neighbours are important

Posted: 08 Jan 2012 22:42
by mstanescu
Hello,

I am trying to run this script on a dedicated linux server with a certain scenario but i am having problems figuring out how to start.

My config has

Code: Select all

[game_scripts]
"Neighbours are important" = enable_neighbours=0
I see it is running on my local windows machine when i generate a game but script is not running when i am loading this scenario.

Is there a trick for running the script with scenarios?

Thanks
Mihai

Re: [NoGo] Neighbours are important

Posted: 09 Jan 2012 19:11
by Zuu
You will have the same problem trying to bind a save game to a Game Script after the game has been created. A scenario is basically a savegame with a different extension. To solve your problem without modifications to OpenTTD, you need create a new scenario where you set in your main menu to use this Game Script before clicking on the scenario editor button to create a new scenario.

If you find this too constraining, then that is a feature request for the NoGo framework and OpenTTD itself. For the development of the Tutorial I hope there will be a solution to be able to bind a scenario to a Game Script after the scenario has been created. But that is unfortunately not the case at the moment.

Re: [NoGo] Neighbours are important

Posted: 19 Apr 2012 10:33
by Fanatik
Aloha Zuu :)

As proclaimed in http://www.tt-forums.net/viewtopic.php?f=33&t=57431 i've extended your script a little bit and wanted to ask you if your interested in the changes. Some of your code still remains within so ofc i won't release it to the public without your review and permission. Anyway these are the changes i've implemented so far...

List o' changes

- Cities now show who their neighbouring cities are within the town GUI.

- Congestion now actually happens (rebalanced values to the point where "Hard" means hard and Easy means easy)

- Added lots of new Settings (and updated others with appropriate descriptions)

- Lots of Balancing for CargoGoals

- Implementing a CacheClass (Tables are great!) for reoccuring calculations all over the place

- Added Periodic Expansion of Cities even while their CargoGoals are not reached (very slow growth, but still ;P)

- Added Option to adjust the TimeSpan between each Periodic Expansion

- Added Option to have Cities benefit from Periodic Expansion more then Towns.

- Replaced integer (percentage) values for difficulties with named Settings. There are always quite a lot, but people wont tell the difference between 50 and 52 ingame anyway, so i think this is more intuitive.

- Added Option to switch between simple (Passengers/Mail) and complex cargoGoals.

- CargoGoals (except for Passengers) now have an offset within their calculation so they form a nice curve instead of a line ;P

- Added a small CargoGoal handicap for Cities without a neighbour if neighbours are enabled.

- Added a Compatiblity Mode for FIRS newGRF (as i love it!). Up to 5 different Goals in the normal Landscape (Passengers->Mail->CratesOfWarez->Food->Fuel)

- Added Translation for German

- Added an Option for changing the maximum amount of neighbours a town may have

- In lack of a better alternative introduced an ugly and primitive way to sort GSSettings into Categories


NextUp:

- Quality of Service: Have a town get a Expand()-boost if the Towns PercentageTransported Values stay above a certain value for at least X months.... for the perfectionist ;)

- Properly Save important values when the Game issues a save.

- Evolving Neighbourhood: Towns pick new neighbours as they grow in size.

Re: [NoGo] Neighbours are important

Posted: 19 Apr 2012 19:11
by Zuu
Looks good to me. I haven't been playing with the game script much since I created it. The reason why I had percetange settings and not a few labled values was that I didn't want to spend my time playing it through several times to figure out what settings to pick. Instead I opened it up for players to test and hopefully report back what they found as good settings.
Zuu wrote:I would be happy if those of you who play with this GameScript reports back what kind of values on the two scale factors that you find good. That way I can see if I need to adjust the baseline or the recommended easy/medium/hard values.
So, I very much welcome that you have taken your time and refine the script based on your experience with it. If you look around, you'll see that I've created more AI/GS projects than that I can possible improve all of them to higher standard very quickly.

Re: [NoGo] Neighbours are important

Posted: 21 Apr 2012 21:52
by e4e5nf3
Very fun script, it certainly adds a certain sense of realism and challenge to the game.

Growing a town starts to become a challenge once it reaches a certain size. In my current game I have practically every large city on the map "feeding" my target city (it started as a size 75 and has grown into a size 10000+). The problem I have now is that I can't send anymore passengers and goods to my target city because the feeder cities are already at maximum production, thus the target city has stopped growing. And even if I managed to grow these feeder cities, I am already producing the maximum amount of goods possible on the map, so I have no extra goods to spare to send to extra cities.

Have I reached the "end game"?

Re: [NoGo] Neighbours are important

Posted: 23 Apr 2012 15:00
by Zuu
If your advanced setting allows, you can fund new industries and also fund new towns.

You could possible also re-direct your passengers and cargo to another town B to grow that. Then when town B has grown you can go back to growing your original town and now have more passengers and mail from B to send.

Also, unless you have disabled the neighbours part of "neighbours are important", then it is beneficial to grow the 5 or so closest towns in relation to the town you try to grow. That will reduce the cargo requirements of your town.

Re: [NoGo] Neighbours are important

Posted: 09 Jun 2012 22:53
by Malaras
Fanatik wrote:Aloha Zuu :)

As proclaimed in http://www.tt-forums.net/viewtopic.php?f=33&t=57431 i've extended your script a little bit and wanted to ask you if your interested in the changes. Some of your code still remains within so ofc i won't release it to the public without your review and permission. Anyway these are the changes i've implemented so far...

List o' changes

- Cities now show who their neighbouring cities are within the town GUI.

- Congestion now actually happens (rebalanced values to the point where "Hard" means hard and Easy means easy)

- Added lots of new Settings (and updated others with appropriate descriptions)

- Lots of Balancing for CargoGoals

- Implementing a CacheClass (Tables are great!) for reoccuring calculations all over the place

- Added Periodic Expansion of Cities even while their CargoGoals are not reached (very slow growth, but still ;P)

- Added Option to adjust the TimeSpan between each Periodic Expansion

- Added Option to have Cities benefit from Periodic Expansion more then Towns.

- Replaced integer (percentage) values for difficulties with named Settings. There are always quite a lot, but people wont tell the difference between 50 and 52 ingame anyway, so i think this is more intuitive.

- Added Option to switch between simple (Passengers/Mail) and complex cargoGoals.

- CargoGoals (except for Passengers) now have an offset within their calculation so they form a nice curve instead of a line ;P

- Added a small CargoGoal handicap for Cities without a neighbour if neighbours are enabled.

- Added a Compatiblity Mode for FIRS newGRF (as i love it!). Up to 5 different Goals in the normal Landscape (Passengers->Mail->CratesOfWarez->Food->Fuel)

- Added Translation for German

- Added an Option for changing the maximum amount of neighbours a town may have

- In lack of a better alternative introduced an ugly and primitive way to sort GSSettings into Categories


NextUp:

- Quality of Service: Have a town get a Expand()-boost if the Towns PercentageTransported Values stay above a certain value for at least X months.... for the perfectionist ;)

- Properly Save important values when the Game issues a save.

- Evolving Neighbourhood: Towns pick new neighbours as they grow in size.
Zuu wrote:Looks good to me. I haven't been playing with the game script much since I created it. The reason why I had percetange settings and not a few labled values was that I didn't want to spend my time playing it through several times to figure out what settings to pick. Instead I opened it up for players to test and hopefully report back what they found as good settings.
Zuu wrote:I would be happy if those of you who play with this GameScript reports back what kind of values on the two scale factors that you find good. That way I can see if I need to adjust the baseline or the recommended easy/medium/hard values.
So, I very much welcome that you have taken your time and refine the script based on your experience with it. If you look around, you'll see that I've created more AI/GS projects than that I can possible improve all of them to higher standard very quickly.

Did you ever share this? ;)

Re: [NoGo] Neighbours are important

Posted: 12 Aug 2012 13:32
by V453000 :)
The towns funded in game seem not influenced by this script. :)
[15:30] <Zuu_> V453000, IIRC it should handle that event but it might not be working. You could try to save + load. Also report it in the thread and I'll tke a look at he code when possible (at a train at the moment)
Here you go.