[GS] Balanced City Growth: Version 3 Updated

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

kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

[GS] Balanced City Growth: Version 3 Updated

Post by kormer »

Balanced City Growth
A gamescript for OpenTTD

Balanced city growth is a game script which changes how cities grow in several ways outlined below. It is my goal with this script to challenge veteran players to diversify their networks across many different industries and move away from the mega-stations that process everything for the entire map. At the same time, I've implemented some features that I hope will make this journey a little less painful for newer players.

1. Cities now require cargo to be delivered each month. Which cargos are demanded depends heavily on if you're using the base industries, or if you're using an industry set such as ECS or FIRS. This script will work with any of those three, however you must set which one you're using in the settings first.

2. In addition to requiring cargo, cities can also stockpile cargo over an above the goal amount. The maximum amount is capped at ten times the required amount for that particular cargo. If nothing is supplied, the required amount will be deducted from the stockpile each month until the stockpile reaches zero.

3. Cargo does not need to be delivered directly to a town to count towards that town's requirements. Delivering cargo to any industry near a town will also count towards a town's requirements, and in fact this behavior is strongly encouraged. You can for example, deliver milk to a dairy outside of a town, and then deliver food from the dairy to the town. For that, you will get credit for both the food and the milk deliveries.

4. The first required cargo will always be passengers. Each month, the script will check to see if any passengers have been transported from a town, and will only procede with the rest of the calculations if this is true. This is intended to reduce the strain for larger maps where there would otherwise be lots of towns to calculate.

5. As a measure to improve performance on larger maps, the script will pause the game while processing the monthly calculations. The time this takes depends heavily on the number of towns with an active passenger network. Usually it will only be a fraction of a second, but on a 2048x2048 map with lots of towns and every single on of them connected to the network it could take several minutes. I recommend playing the game with build while paused allowed for all maps, as well as less towns if you're going to play on a large map.

6. The normal town GUI will not function anymore. Instead, a town's text box will be updated with the stockpile amount, the supplied amount(previous month), and the required amount for the next month. Below each town's name, you'll also see a sign indicating the number of days in between growths.

PERFORMANCE TIPS
* Enable build while paused at all times.
* On larger maps, select a lower setting for the number of towns.
* Balanced City Growth's main calculations take place on the first of each month, so it works well with the daylength patch.


---------------------------------------------------------------------------------------
Version 3 has been released on 3-3-2013 and can be downloaded from bananas.

Version 3 changes: http://www.tt-forums.net/viewtopic.php? ... 9#p1068759

TO-DO LIST:

* Implement a command queue to more efficiently use ticks. Primarily an issue for multiplayer maps where lots of cities are connected and the tick update is larger than 1-2.
* Implement a method to discourage players from using intra-city routes to meet the PAX requirements. I'd like to keep the PAX requirements fairly easy, but have them filled mostly from inter-city routes.
* le support de langue.
* Implement a save/load function. It is safe to save/load currently, however the script will take a few months to re-initialize after a load.
* Continue balancing cargo requirements.
Last edited by kormer on 04 Mar 2013 04:04, edited 3 times in total.
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: [GS] Balanced City Growth

Post by Hyronymus »

This sounds like a very challenging and rewarding script, let's give it a try.

EDIT:

Your gamescript doesn't appear in the list and when I follow the link in Firefox it yields:

Code: Select all

Error response

Error code 404.

Message: File Not Found.

Error code explanation: 404 = Nothing matches the given URI. 
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

Hyronymus wrote:This sounds like a very challenging and rewarding script, let's give it a try.

EDIT:

Your gamescript doesn't appear in the list and when I follow the link in Firefox it yields:

Code: Select all

Error response

Error code 404.

Message: File Not Found.

Error code explanation: 404 = Nothing matches the given URI. 
Sorry, I forgot to mention I set the required version to a relatively recent nightly of 25001, which means it won't show up in the in-game list unless you're running that version or above. I have done some testing on earlier versions, but some of the functions used may not work properly depending on how far back you go.

You can always download it directly from the bananas website and drop it into the folder \OpenTTD\content_download\game

The bananas website the file can be found in is: http://bananas.openttd.org/en/gs/
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: [GS] Balanced City Growth

Post by Hyronymus »

kormer wrote:You can always download it directly from the bananas website and drop it into the folder \OpenTTD\content_download\game

The bananas website the file can be found in is: http://bananas.openttd.org/en/gs/
Which gives me the 404 I mentioned ;).
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

Hyronymus wrote:
kormer wrote:You can always download it directly from the bananas website and drop it into the folder \OpenTTD\content_download\game

The bananas website the file can be found in is: http://bananas.openttd.org/en/gs/
Which gives me the 404 I mentioned ;).
Try this. If you're still having problems, it's probably something to do with your connection to bananas itself, in which case I probably can't help you there.

http://bananas.openttd.org/en/
User avatar
Hyronymus
Tycoon
Tycoon
Posts: 13233
Joined: 03 Dec 2002 10:36
Location: The Netherlands
Contact:

Re: [GS] Balanced City Growth

Post by Hyronymus »

kormer wrote:
Hyronymus wrote:
kormer wrote:You can always download it directly from the bananas website and drop it into the folder \OpenTTD\content_download\game

The bananas website the file can be found in is: http://bananas.openttd.org/en/gs/
Which gives me the 404 I mentioned ;).
Try this. If you're still having problems, it's probably something to do with your connection to bananas itself, in which case I probably can't help you there.

http://bananas.openttd.org/en/
I'll try it. Too bad I just started a new game with Neighbours Are Important, from a small test game (I updated to r25039) it looks rather fun to use!
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [GS] Balanced City Growth

Post by Zuu »

In reply to Hyronymus (or any user of Game Scripts or AIs)
It takes some time before newly uploaded files become available for download from the bananas website. You see this if you hold the mouse cursor over the download link (the link that states # of dowloads), it will refer to a non-existent file saying "not yet available" or so. Give it some time, or download the GS via online content in the game.

For AIs and GSes I would strongly recommend against manually downloading unless you have to. If you download via the game, you will get the correct version of all dependencies, given that the uploader have correctly marked the dependencies. If some of the dependencies update after the AI or script, Bananas will still tell OpenTTD to get the older library version. While when downloading manually you will easily try to get the last version of all libraries which will be the wrong version in case any of the libraries have updated after the AI/GS.
Last edited by Zuu on 24 Feb 2013 20:44, edited 1 time in total.
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: [GS] Balanced City Growth

Post by Zuu »

To kormer (as GS author):
Your version 2 of Balanced City Growth import version 26 of SuperLib. However, the bananas web UI only allow specifying the currently last version of a library as dependency. Thus, I would recommend to update to version 27 of SuperLib in your import statement in main.nut and upload a new version of your GS.

The current situation is this:
  • Your bananas entry tells that your GS needs version 27 of SuperLib (given that you have selected SuperLib as dependency at all in the WebUI)
  • When a user downloads your script, it can add it to a game.
  • When a user starts the game, the script will try to import version 26 of SuperLib. If the user doesn't have exactly version 26 available, then the script will crash.
So users who have downloaded some other GS that uses SuperLib 26 will not see any problems, but new users who doesn't have v26 will get v27 when they download your GS and the script will fail to work. For the upgrade from 26 to 27 see this post: http://www.tt-forums.net/viewtopic.php? ... 5#p1054385 (eg. there are nothing that should break your script in there)


In general there is no backward compatibility lost when updating an import to a newer version for SuperLib. If there are, I will announce that in its thread.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

Zuu wrote:To kormer (as GS author):
Your version 2 of Balanced City Growth import version 26 of SuperLib. However, the bananas web UI only allow specifying the currently last version of a library as dependency. Thus, I would recommend to update to version 27 of SuperLib in your import statement in main.nut and upload a new version of your GS.

The current situation is this:
  • Your bananas entry tells that your GS needs version 27 of SuperLib (given that you have selected SuperLib as dependency at all in the WebUI)
  • When a user downloads your script, it can add it to a game.
  • When a user starts the game, the script will try to import version 26 of SuperLib. If the user doesn't have exactly version 26 available, then the script will crash.
So users who have downloaded some other GS that uses SuperLib 26 will not see any problems, but new users who doesn't have v26 will get v27 when they download your GS and the script will fail to work. For the upgrade from 26 to 27 see this post: http://www.tt-forums.net/viewtopic.php? ... 5#p1054385 (eg. there are nothing that should break your script in there)


In general there is no backward compatibility lost when updating an import to a newer version for SuperLib. If there are, I will announce that in its thread.
Thanks for this. I'll have a fix uploaded in a little bit.
LSky
Traffic Manager
Traffic Manager
Posts: 170
Joined: 25 Jun 2005 10:44
Location: The Netherlands

Re: [GS] Balanced City Growth

Post by LSky »

This looks very promising!
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

I spent way too long tonight figuring out how to convert this formula into squirrel code. The good news is I got it. You should all be excited, I still have plenty more big ideas planned for this.
Attachments
math formula.JPG
math formula.JPG (22.56 KiB) Viewed 35654 times
Dwachs
Engineer
Engineer
Posts: 46
Joined: 02 Jun 2005 07:28

Re: [GS] Balanced City Growth

Post by Dwachs »

You can get rid of the sum, and just apply the formula

http://en.wikipedia.org/wiki/Geometric_series#Formula

(in case you did not know this)
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

Dwachs wrote:You can get rid of the sum, and just apply the formula

http://en.wikipedia.org/wiki/Geometric_series#Formula

(in case you did not know this)
One thing I love about the Openttd community is how it attracts all different kinds of geeks, especially math geeks. It's been decades since I've been in a calculus classroom, but in this instance, I needed to calculate and store each of the values of X=1, X=2, X=3...up to X=sqrt(mapsize)/128, so just calculating the convergence alone wouldn't be enough if I'm reading the link right.
Thor87
Engineer
Engineer
Posts: 3
Joined: 01 Mar 2013 22:03

Re: [GS] Balanced City Growth

Post by Thor87 »

Hello! I'm trying to play with ESC industries. Can u tell me, please,
1) how can i deliver industrial goods such as coal, steal and glass to towns, do i need to build curtain industry building near towns (power station etc.)?
2) at the begining of the game towns larger then 1000 population needs food, but towns cannot receive it :(.
3) what is WDPR ?
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

Thor87 wrote:Hello! I'm trying to play with ESC industries. Can u tell me, please,
1) how can i deliver industrial goods such as coal, steal and glass to towns, do i need to build curtain industry building near towns (power station etc.)?
2) at the begining of the game towns larger then 1000 population needs food, but towns cannot receive it :(.
3) what is WDPR ?

1) Deliveries to industry count towards the town's goals, so yes, finding an industry near the town that can accept those would be how to do it. I suggest playing with a very low number of towns, so the radius around each town will contain a larger number of accepting industries than usual.
2) Sorry about that, the next release should be out tomorrow night and contains a number of balancing improvements for ECS. The first few releases I only had time to playtest FIRS extensively.
3) Wood Products. That I know of, scripts do not have access to a grf's language files to give the full translated name for cargo types, instead I just get the short 4 character abbreviation. I'm considering a couple of possible fixes for this, including just ripping the language translations out of ECS and FIRS and just hardcoding them into my script, but that's clunky as clunky gets. If someone know's of a better solution, please share. In the meantime, you can check the link below for help translating the abbreviations.

http://newgrf-specs.tt-wiki.net/wiki/CargoTypes
User avatar
keoz
Transport Coordinator
Transport Coordinator
Posts: 321
Joined: 16 Jul 2009 10:04

Re: [GS] Balanced City Growth

Post by keoz »

Hey !

Thank you for this Game-Script, I like a lot the way it changes the challenge. That gives a lot more sense to all the whole industrial infrastructure transportation.

I have a little question: are calculation made in the same way for town and cities ? (that means, there is no more difference between city and town growth ?)
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.
Thor87
Engineer
Engineer
Posts: 3
Joined: 01 Mar 2013 22:03

Re: [GS] Balanced City Growth

Post by Thor87 »

kormer wrote:
Thor87 wrote:Hello! I'm trying to play with ESC industries. Can u tell me, please,
1) how can i deliver industrial goods such as coal, steal and glass to towns, do i need to build curtain industry building near towns (power station etc.)?
2) at the begining of the game towns larger then 1000 population needs food, but towns cannot receive it :(.
3) what is WDPR ?

1) Deliveries to industry count towards the town's goals, so yes, finding an industry near the town that can accept those would be how to do it. I suggest playing with a very low number of towns, so the radius around each town will contain a larger number of accepting industries than usual.
2) Sorry about that, the next release should be out tomorrow night and contains a number of balancing improvements for ECS. The first few releases I only had time to playtest FIRS extensively.
3) Wood Products. That I know of, scripts do not have access to a grf's language files to give the full translated name for cargo types, instead I just get the short 4 character abbreviation. I'm considering a couple of possible fixes for this, including just ripping the language translations out of ECS and FIRS and just hardcoding them into my script, but that's clunky as clunky gets. If someone know's of a better solution, please share. In the meantime, you can check the link below for help translating the abbreviations.

http://newgrf-specs.tt-wiki.net/wiki/CargoTypes
Thank you very much for your answers and script! Impatiently waiting for updates!
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

Thor87 wrote:Hello! I'm trying to play with ESC industries. Can u tell me, please,
1) how can i deliver industrial goods such as coal, steal and glass to towns, do i need to build curtain industry building near towns (power station etc.)?
2) at the begining of the game towns larger then 1000 population needs food, but towns cannot receive it :(.
3) what is WDPR ?
I did a little bit more research on #2, and it appears the problem isn't with town size, but with the fact that in ECS food is demanded by special buildings that ECS will build automatically, but only after a year milestone has been reached. In FIRS you have the option of building cheap "industries" such as a hotel which will jumpstart the food demand for you, but no such option appears in ECS. As such, I've replaced the food requirement until I can get a better handle on how to get towns accepting it.
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

keoz wrote:Hey !

Thank you for this Game-Script, I like a lot the way it changes the challenge. That gives a lot more sense to all the whole industrial infrastructure transportation.

I have a little question: are calculation made in the same way for town and cities ? (that means, there is no more difference between city and town growth ?)

Yes, there's currently no distinction made between a town and a city. I might add that back in at some point, but it seems so silly and arbitrary. If there were a way I could set all municipalities to a town at game start, and then selectively change some to towns based on players reaching certain goals, that might be interesting, but I don't see a way to do that right now.
kormer
Engineer
Engineer
Posts: 39
Joined: 11 Sep 2004 17:05

Re: [GS] Balanced City Growth

Post by kormer »

I've just uploaded version 3. I did not get to do as much detailed playtesting other than bug hunting with this release as I would have wanted to. If you're running into any walls with growth, please let me know and maybe send a saved game. If someone can get this onto a multiplayer server with more than a few people, I'd love to join in and see how it runs there, please PM me the details.

There was one minor bug fix in this release, as well as two major changes.

Maps now have a target number of cities which fluctuates by map size. The formula for goal cities = sqrt(# of tiles in the map) / 128. Cities are grouped together into tiers according to population. For each city, the script will compare the number of cities in the same or higher tier and adjust the goal requirements up or down depending if there are less or more cities than the target amount. The intent of this feature is to encourage players to expand their networks to grow many different cities, rather than focus on one megapolis. Players who can successfully supply many more cities above the target amount will be rewarded with vastly reduced goal amounts, however passengers and mail will not be affected positively or negatively by this.

The second change is for very large cities, the goal amounts will now be shown as signs instead of within the town's text box. There is a bug with towns that are very close to the edge bottom left or right edges of the map, so try to give them at least 15-20 tiles for room. There are a couple of new features I'd like to roll out, but all of these will require more information feedback than the standard town GUI allows, which means I'd like to make more use of the signs. I would appreciate some feedback from players on if the sign spam is too annoying or if you can live with it.

Oh yes, and cargo requirements were rebalanced again, this should be a given for all releases though.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Redirect Left and 6 guests