"Real growth" GS for FIRS

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

lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

"Real growth" GS for FIRS

Post by lukasz1985 »

Description
This game script requires FIRS industry replacement set.

The goal of this game script is to make cities growth dependent upon amount of cargos delivered to them.
This cargos are:
- passangers
- mail
- goods
And cargos introduced by FIRS:
- food
- fruits
- petrol
- building materials

It's easy to deliver passangers, mail and goods to the city, but problems start when you have to deliver
food, fruits and petrol, because default city buildings dont accept this cargos. In order to be able to deliver
them you have to find industry which accepts them or fund such an industry near the town you want to grow.

After its done and cargos has been delivered to city, the next month's first day they are summed up and the
impact on the population of the previous month is calculated. The city target population is calculated by taking the average of consecutive
last three months impacts on the city population. This informations are displayed in city window:

Image

The impact is calculated based on the amount of cargo transported and the settings of a game script.
The settings allow player to adjust percentage of how much an unit of a cargo will contribute to the total population impact each month.
If the value is set to 100 then one unit of a cargo delivered will result in one person in population. This settings are available in game script / ai configuration window:

Image

At the beginning of the next month, after the target population is calculated, the city is expanded if the target population is higher than current population.
The amount of expansion is counted in houses. The difference between the target population and current population is calculated, and basing on this difference
the amount of houses to expand is calculated. For every 1000 of this difference 10 houses are expanded, what means, again that if the difference between calculated target population and current population is 1000 - the city will expand 10 houses at the beginning of the month.


Other features:
Due to the fact that this script was intended to be kind of patch for OpenTTD things I dont like and to enhance some things there are other "side effect features" which you may or may not like.
1. A "manager" that works on beside of player company:
- Rebuilds crashed vehicles in the nearest depot.
- Refunds advertising camaigns every month. In order to use this feature, player has to put a sign in the city with text:
---"Advertising - small" for small advertising
---"Advertising - medium" for medium advertising
---"Advertising - large" for large advertising campaign

2. Signs over industries with their names. I made it accidentally for debugging purposes but I've found it really usefull during game play, especially with FIRS, where there are around 50 types of industries. So it's left there :)
It is possible to disable them before new game start in the settings of a game script.

Installation
If you are interested in using this gamescript, you must download it and unpack to the "game" folder of the OpenTTD "my documents" directory.
Download link for newest version: https://dl.dropboxusercontent.com/u/403 ... rowth4.zip

Changelog

Version 6
Fixed a bug when deleting industry.

Version 5
Added french(by fabca2) and polish translation for town GUI.
Fixed a bug.
Moved to bananas.
Download link : https://dl.dropboxusercontent.com/u/403 ... rowth5.zip


Version 4
Dropped dependency upon SuperLib library so user can just download, extract and play.

Download link (version4): https://dl.dropboxusercontent.com/u/403 ... rowth4.zip

Version 3
Changes:
The target population is now calculated basing on three month of consecutive impact, the last month impact is shown among two previous months impact is now displayed in city GUI.

This solves issue with irregular deliveries, where one month the target pop would be 25000 and next only 2000, and smooths the city growth.

Download link (version3): https://dl.dropboxusercontent.com/u/403 ... rowth3.zip

Version 2
Changes:
-Now the number of houses city grows every month is calculated basing on the difference between the target population and current population. The higher this difference is the more houses are grown. Per each thousand of this difference 10 houses are added which means if for example target population is 2500 and current population is 1000, the difference is 1500 - 15 houses are built.
-The town target population is colored in red if it's below current city population, and green if above.
- Settings are changed, see below

New:
- Settings: the settings for the game script are now giving player ability to select how much impact a certain cargo has on the final target population of the city. Settings are in form "XXX impact (%, def: YYY)" , where XXX is the name of the cargo and YYY is the default impact value.
The impact is set as a perentage of how much per unit of transported cargo, the target population is impacted, so for example if the value of a setting for a cargo XXX is 435, and the transpoted amount is 100 - the effect on the population is 435 people.
- Enable/disable creating signs over industries indicating their name at game start.

Download link (version2): https://dl.dropboxusercontent.com/u/403 ... rowth2.zip


Version 1
The town target population is evaluated every month based on the amount of goods transported to the city. These goods are enumerated beneath with numbers indicating how much have been transported to the city/town last month (green number) and how much the impact the calculated target city population (yellow number). These cargos are:
- Passangers
- Mail
- Goods
- Food
- Fruits
- Building materials
- Petrol

After the target population is calculated, at the beginning of new month - if it is larger than the current city population, the city grows 5 houses, else nothing happens.

The goal is to keep the incoming cargos at high level. There are no such constraints as in other similar gamescripts where in order to grow city, player has to fullfill requirements for all cargos. Here, one cargo may cause city to grow if enough amount is delivered to it.

Download link (version1): https://dl.dropboxusercontent.com/u/403 ... Growth.zip
Dependent on SuperLib v 26 library.

Have fun!
Last edited by lukasz1985 on 08 Jan 2014 16:15, edited 12 times in total.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: "Real growth" GS for FIRS

Post by Zuu »

lukasz1985 wrote:If you are interested in using this gamescript, you must download it and unpack to the "game" folder of the OpenTTD "my documents" directory.
It also requirese SuperLib v 26 due to the fact that it is made on the GameScript template authored by Zuu.
From SuperLib.Helper, you only use "Helper.Max" which is an old helper that can be substituted with the internal "max" that has been available for ages. The next version of MinimalGS will use "max" instead of Helper.Max as it is a silly example.

The other class that you actually use is SuperLib.Log. However it looks like most of your logging is made using GSLog.Info instead of (SuperLib.)Log.Info, thus you could replace the few usages of Log with GSLog and drop the second log level parameter there.

After doing these changes you can drop importing of SuperLib altogether if you don't plan to use any of the many helpers available in SuperLib.


My MinimalGS do not require you to use SuperLib. If you don't need it, you can drop it and get free of that dependency. The library is a collection of helpers that I've written over the years and since I've maintained two AIs over some time I decided to put the common parts in a library instead of fixing the same bug in two scripts. The bonus is that others can use it too if they like, but I also understand that many will want to write there own code and that is fine too.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Re: "Real growth" GS for FIRS

Post by fabca2 »

Hello,
Your script is really something I was looking for,
Thank you very much.

Do you plan to add settings for other cargo : food, fruit, BuildMat and petrol (and remove unsused coal one) ?

I have few remark if it's possible, to add a boolean setting to enable or disable :
- sign over industry -> it's true it can be usefull, but someone may not like it.
- take "fund new building" into account -> (funded) building does not have any impact anymore with your script, it can be interresting to enable default behavior.


What's your feeling about completeness of your dev ? Do you plan to add news feature/settings/changes ?
I made a translation file (that was easy, these is only one line) but I don't know if I must wait for a new version ?

I'm very interrested by your GS, and I have few idea to share with you, lets start with that one :
Figures in "target population" is always in red, can you change color like this : in green when it's lower that current city population (green=growing), and in red otherwise (red=not growing)

Thank you.
Best Regards
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

@Zuu

Thank you for that info. I will certainly look into this. Nevertheless thanks for the template you made :)

@fabca2

Nice to hear you liked this script.

Actually you pointed some things I've forgot about:
Currently the settings only work for passangers and mail, the coal is in the settings because I forgot to remove them from there.
And for settings for other kinds of materials - I will probably do this.

Other things are also possible.
Only the question I've got - I dont know what you mean by saying " (funded) building does not have any impact anymore with your script"


Yes, this GameScript can be viewed as work in progress, so I'm open to the suggestions.

Will try today to make some progress.

BTW: Does the translation work? When I was using polish version, the translation didn't appear.
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Re: "Real growth" GS for FIRS

Post by fabca2 »

lukasz1985 wrote:BTW: Does the translation work? When I was using polish version, the translation didn't appear.
Yes it does work perfectly,
you just need to give file name with .txt instead of .lang as you did.

lukasz1985 wrote:Only the question I've got - I dont know what you mean by saying " (funded) building does not have any impact anymore with your script"
it's not important, it's in local authority, on the same list you have the Advertising campain, you can fund a new building, by doing that city temporary increase growing speed.
it's just the user still have the option in local authority but nothing happens, you don't need to spend too much time on this...

lukasz1985 wrote:Yes, this GameScript can be viewed as work in progress, so I'm open to the suggestions.
I'm excited about that, can't wait for next version :D

Regards.
Last edited by fabca2 on 05 Nov 2013 11:19, edited 1 time in total.
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

Oh .. I missed the file extension.

I still cant get what you mean with funding buildings :) but I guess that you suggest that placing sign over the city with "Fund buildings" text in it will make new buildings funded every month?
Or do you mean that funding new buildings in "local authority" window doesn't work?
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Re: "Real growth" GS for FIRS

Post by fabca2 »

lukasz1985 wrote:Or do you mean that funding new buildings in "local authority" window doesn't work?
Yes, that's it... but it's not important.
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

Well this topic need some clarification:

Actually funding new buildings works with the script but not the same way as in original game. In original game this works by building new building in the city after the option is activated and shortening times between town growths for some time.

Here, in this gamescript - the only thing that is done is that new building is funded after the "fund new building" is initiated.
If you or anybody want to test it do the following:
1. Start new game with a tiny map: 64x64
2. ALT + CTRL + C for cheat menu
3. Add yourself some money.
4. Fast forward the game
5. Fund buildings every 5-6 days
Note that the town must be able to build roads or houses - it has to have spare space around it.

I was looking at this, but this is hard thing to do to shorten the times between growths in cooperation with the script itself. But I will look at this in depth.
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

So the updated version (Version2) is here :) see the original post for more info
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

And version 3 with a quick fix.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: "Real growth" GS for FIRS

Post by Zuu »

If you keep SuperLib as a dependency, I recommend updating the import statement to the last version on bananas before you upload a new version and set SuperLib as dependency. In bananas you can only mark the last version of each library as dependency*. This is why I recommend you to change the import statement to import the last version (version 36). You can see what is the last version here: http://bananas.openttd.org/en/gslibrary/

Some people use different version in bananas and in the script because they want to use eg. 0.3.2 as version (which works in bananas but not in info.nut). I always keep the same version number in both places. So version 36 means it is the 36:th release of SuperLib as there is no minor version number.


* If you really want to set older versions of a library as dependency you must use musa as upload tool because for now the web upload interface does not support this.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

I dropped the dependency for now. So it's now smoother to install this script.

I was thinking about uploading to bananas but for now I have no real feedback if it is even worth doing so (maybe I should think the other way around).
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Re: "Real growth" GS for FIRS

Post by fabca2 »

Hi,
I tested your recent version, that's very nice.

Just a question, did you notified that passengers and mail figures are not the same as the one in town screen ?
For example, in your printscreen (firs post), you compute 1046 passengers and few line before ottd compute 1601.
Do you know where does come from this difference ?
I made a test with delivering only one bus (35 passangers) to a city, your script was correct, ottd was wrong by displaying 112 !

Do you know if it's possible to hide (wrong) passangers and mail lines from town screen ? (not the lines from your screen, the ones from ottd) because it's wrong, and disturbing to have different numbers.


Here is the french language file (for when you got to bananas)

Thank you.
Attachments
french.txt
(733 Bytes) Downloaded 328 times
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: "Real growth" GS for FIRS

Post by keoz »

fabca2 wrote:Just a question, did you notified that passengers and mail figures are not the same as the one in town screen ?
For example, in your printscreen (firs post), you compute 1046 passengers and few line before ottd compute 1601.
Do you know where does come from this difference ?
That's normal. The town screen doesn't show pax/mails delivered to the city, but pax/mails delivered by the city to the stations. It becomes more clear if you check cities which have not any station.
Patch - Let's timetable depot waiting time with the Wait in depot patch.
GameScript - Searching a new way to make your cities growing ? Try the Renewed City Growth GameScript.
My screenshots thread.
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

Yes that is correct, in the current screenshot the value 925 , max 2,324 are values that the city supplies. It means that the city last month supplied 925 passangers, and could maximally supply 2,324 passangers. This values show how much passangers were generated. The value 1816 is the value indicating how many passangers were accepted by the city, and upon this value the impact is calculated (5448). The amount accepted is the sum of the cargo that was delivered to the city.

This script works that only cargos transported(delivered/accepted) to city are counted.

Thanks for the translation, now the script is in bananas.
hpfx
Engineer
Engineer
Posts: 43
Joined: 09 Nov 2013 00:19

Re: "Real growth" GS for FIRS

Post by hpfx »

Hi,
I noticed that you have a small glitch on Petrol line, you have a ":" just before the word "Petrol".
it's not important, just to make it nicer.
Regards.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: "Real growth" GS for FIRS

Post by Zuu »

Perhaps add a Story Page which documents inside the game what the different numbers in the town window are for?
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

I can't solve the glitch, somehow the ":" just appears there.
User avatar
romazoon
Tycoon
Tycoon
Posts: 1291
Joined: 20 Jun 2010 23:16

Re: "Real growth" GS for FIRS

Post by romazoon »

This script keep crashing in my game, so here is the screenshot with the hope you can do something about it ;)
i remember having an instant crash after i demolished some FIRS farm, but usually the crash happens for no apparent reason.

I use a patchpack, so i m sorry in advance if that make that report useless...if u want/need the savegame, i ll post it.

now i like a lot your script, it makes city growth really more interesting and challenging, and it allow to keep some town relatively small.

but on the matter of keeping small town, i m wondering if my small town don t stay small cause the script crashed in my game, or only cause a kind of natural growth is still active behind the script ?

also i know NAI script allow to change some settings while the game run, would it be possible too with your script ?
Attachments
St. Malo Transport, 24 Jan 1995#1.png
(144.73 KiB) Downloaded 4 times
lukasz1985
Route Supervisor
Route Supervisor
Posts: 429
Joined: 27 Mar 2013 08:58
Location: Strumien
Contact:

Re: "Real growth" GS for FIRS

Post by lukasz1985 »

Sorry for the delay I should have mark this thread to folow.

Actually I've fixed that bug for myself a long time ago :P and it was waiting for upload. Yes, unfortunately this was happening when industries were deleted. You can grab the fixed version from bananas.

About the small towns - if a script crashes - it stops working and no longer is considered in the game - so if you played after that happened - your small cities didnt grow because of settings that the script initialized at the beginning of the month your game crashed (as far as I remember it sets the steps between growths to 999999 days for cities and towns that didn't achieved any growth).

Generaly speaking if a script crashed things are not really predictable.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 5 guests