[GS] Goal Based City Growth

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

pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

[GS] Goal Based City Growth

Post by pbrennan »

I discovered OpenTTD a month or two back and have been enjoying re-exploring the Transport Tycoon world. I've always thought the town growth aspect of the original too artificial though, so I started exploring town growth limiter scripts, and quite liked the Renewed City Growth script. I also prefer a focus rather than be pure sandbox, and explored the Busy Bees script to that end. But I wanted both, and I wanted to introduce other concepts like penalties for not meeting a goal, having town growth goals, a win/loss condition to prompt me to go to bed, and other such.

Before I go any further, my thanks to everyone who's worked on these, and other scripts, in the past - they've amped the game considerably!

Anyway, I took on the task of merging the Renewed City Growth and Busy Bee scripts, and then tailoring it to taste. The following is an extract from Readme which describes how the script works:

This script is a blend of Renewed City Growth and a re-worked version of the Busy Bee goals concept. It supports three Baseset industries (Temperate, Arctic, Tropical) and the 5 FIRS economies provided in v2.1.3.

You may define much of how you'd like the goals to work via the parameter settings, allowing you to construct the type of game you enjoy the most. Goals come in two forms - major and minor. Major goals do not expire and generate no penalties. Minor goals have an expiry date, and each expired goal will cost you 1% of your balance each month.

The goals page will keep a count of goals met and expired. It will declare the game "won" if:
- all major goals have been met (if you've chosen to have them), and
- the requisite number of minor goals (if you've chosen to have them) have been completed (10/20/30 at easy/medium/hard level), and
- more goals have been completed than have expired.

MAJOR TOWN GROWTH GOALS:
A number of major town growth goals will be created at the start of the game equal to the setting you choose. Each will randomly pick a town
and require you to build it to a population of 20k (at easy level), 30k (medium) or 40k (hard).

MAJOR RAW MATERIAL CARGO PICKUP GOALS:
A number of major raw material cargo goals will be created at the start of the game equal to the setting you choose. Each such goal will choose an industry type that generates a cargo at the start of the game that doesn't require input cargo (eg Coal Mines produce coal without requiring an input). It will sum up the total production of all industries in that industry type (eg all Coal Mines) and require you to deliver, over a 12 month period, an average of 50% of that total production. To anywhere you like. Also ...

If you choose to have vertically integrated goals (which is the next setting), the game will then attempt to generate a major goal for a "processing" industry type that accepts the initial goal's raw material (eg a Steel Mill requiring coal). It will choose one of its output cargoes
(eg metal) and generate a major goal requiring you to deliver a bunch of that cargo anywhere on the board (75% of the initial goal's figure).

If you choose to have 2 vertically integrated goals, it will then attempt to create a third major goal, finding a processing industry that accepts the cargo from the second goal, and generating a goal to deliver output from this new industry type. And if you choose 3 vertically integrated goals, it will attempt to create a fourth major goal, along the same lines.

In other words, it's leading you to (for example) get coal to the steel mill, the steel mill's metal to a metal workshop, the workshop's goods to a port, and the port's engineering supplies to ... vertical integration. It doesn't restrict you to that specific chain, but it'll make each
vertical integration goal easier to achieve if you configure your transport network along those lines.

If you choose to have more than one raw material cargo pickup goal, each such goal will generate its own chain, meaning there could be up to 3
extra goals generated on top of each raw material goal.

Each industry type can only have one cargo pickup goal associated with it (we wouldn't want to make it too easy), meaning the more goals you generate, the fewer vertical chains will be found.

Note that this process completely ignores the map and how close / far apart industries are from each other. The bigger the map, the longer and harder each cargo pickup goal will be. In this way, you choose your own difficulty level, in the same way that choice of terrain hilliness affects the difficulty of all goals.

MINOR GOALS:
If you've chosen to have minor goals, these are constructed using the original Busy Bee process. It takes map distance and existing production into account, and asks you to deliver this much cargo (set randomly within a range of 250-2500) to an accepting site by a given date (which is
semi-random, and will be a year earlier on hard mode and a year slower on easy mode). If some goals prove impossible ... c'est la vie.

Minor town growth goals will ask you to grow a random town by 10-20%. If they aren't of interest, you can adjust the weighting settings so as to generate cargo delivery goals only by setting the percentage chance of a goal being a town growth goal setting to 0. If you want all goals to be
town growth goals, set it to 100.

MODES:
Some of the modes of play available through the settings therefore are:
- Major town growth goals only
- Major vertical integration pickup cargo goals only
- Minor goals only
- A mix of any and all of the above, in any proportion you like.

Note that there's a limit of 32 goals at any one time, which is apparently a hard-wired limit in the game.

SIGNS
Once a game is underway, you can manipulate the creation of goals by creating signs (anywhere on the map). At year end, it'll look for these
as follows:

- If there's a sign with the exact text "stop minor goals", it won't create any minor goals at year end. This state will continue as long as the sign
exists. When you're ready for them to start up again at future year ends, destroy the sign.

- For each sign with the exact text "create major town goal", it will create one major town growth goal.

- For each sign with the exact text "create major cargo goal", it will create one major raw material cargo pickup goal, plus associated vertical integration goals per the original parameter setting.

Remember to destroy the signs after year end, otherwise they'll trigger again at the following year end ... unless that's what you want. I included these features because once the game was "won" I usually wanted to ditch the minor goals but get another major goal and take advantage of my network. But given the game is a sandbox, I think it's a nice feature to be able to modify the game after it's started to how you'd most like to enjoy it, without being over restrained by the original settings or by my hardcoding it how I like it.

The RCG town growth aspect is identical to the original, so I won't repeat what it does here.

Personal notes: I've developed this for personal satisfaction and play. I don't play multiplayer or with AIs so haven't tested it under those conditions. Nor have I strenuously tested it for all test-cases. But it's been working for me and for how I play, so hopefully it will do the same for you. Anyway, I freely donate it to all. If anyone wants to pick it up and develop it further, or officialise it / upload it to bananas / whatever, please feel encouraged to do so. If anyone has an idea for a feature I think I'll enjoy, and I have time, I'm open to spending more time on the script. But it's also now at a point I'm happy with.

As such, if you'd like to try/test, I've attached a zip file of the directory (and its content) that's to be placed in the c:program files\openTTD\game\ ... directory. You'll probably need to download/install RCG first because it installs the superlib thing that's required. Other than that, I have little idea about how all this stuff works, being a newbie, so hopefully more experienced guides can help.

Version 2: incorporates cargo pickup and associated vertical integration goals

Version 3: incorporates terraforming Mars scenario, and increased parameterisation

Version 4: updated to work with FIRS. Also:
- modified the parameters for city growth to start wanting new categories at 5000, 8000, 10000, and 12000 (to stop the free pass in the first category for cities that start at a decent size, and making it more size-appropriate for a goal of 20000).
- some modifications to what cargos go into which category, for better thematic matching.
Attachments
Goal Based City Growth.zip
version 3
(48.96 KiB) Downloaded 400 times
Goal Based City Growth.zip
version 4
(50.3 KiB) Downloaded 391 times
Last edited by pbrennan on 12 Mar 2018 06:38, edited 6 times in total.
Magitex
Engineer
Engineer
Posts: 5
Joined: 14 Dec 2016 03:43

Re: Goal Based City Growth

Post by Magitex »

Nice work on the script, I've played a couple games and it's been fun.

If you're still working on the script, here are my thoughts on it and some ideas for the future:

Initial difficulty
:
It felt like the start of the game was incredibly hard with FIRS because the goal immediately required multiple industries working in a very short period of time. I did actually manage to win my first two games on easy, but it was more like playing competitive Starcraft than Transport tycoon as it required very quick planning. I admit it wasn't quite the play I was expecting.

I really think you should encourage the player to build a good network, rather than doing point to point transport goals as quickly as possible.

Difficulty:
As the game progresses, it should require more of you - either more goals (rather than a fixed per-year amount), or more complicated industry. There's a variety of FIRS industries that are fairly easy to get going, and some that require a lot more work.
Ultimately I think you should be building a proper logistics network rather than brute force point to point because it's a lot more interesting to plan and build.
Perhaps the goals could be generated for primary industries and work its way up to more complicated things. Or the goal script could choose a product line to focus on. For example:

Major Oil/Chemical goal:
Major Goal 1 (~15 years): Oil well to Refinery (Chemical or Petroleum now become a possible minor/random goal choice)
Major Goal 2 (~15 years): Refinery (chemicals) to Fertilizer plant (Farm supplies now become a possible minor/random goal choice)
Major Goal 3 (~15 years): Fertilizer to Arable Farm (The Arable Farm products Sugar refinery / Flour Mill / Brewery / Biorefinery become a possible minor/random goal choice)

After x amount of minor goals, perhaps the script could then choose a different product line to focus on, while maintaining previous minor goal requirements. Or perhaps it could ask you to service multiple industries from that industry (i.e chemicals to multiple locations).

There's probably a bunch of complications implementing this but I think it'd be great for a more logical goal system.

Goal failure:
I'm not too sure about losing all your money when failing goals; I think I'd prefer that we lose a small percent of money per month per goal unfulfilled that is past it's scheduled date until you're bankrupt, or have reached the victory condition. It encourages you to not cherry pick jobs and just buy/sell trains as virtual currency to avoid the big bankruptcy that eliminates unfulfilled goals each year.

Winning scenario
:
I think the game should only be won when you complete a victory condition that is available from the start of the game, like town growth before xxxx date. The rest of the goals will eventually feed back into that goal since most of the products are required for town growth and the player should be shipping them to their town to win the game before other players.

I really love playing TTD but it's very lacking for goals so your work to combine these scripts is appreciated.
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: Goal Based City Growth

Post by pbrennan »

All good thoughts, and they're pretty much mirroring my own want-list after playing it a bit more. Yep, the first years feel very much about speed play - the script is pretty much using Busy Bee's semi-random point-to-point goal generator which makes it get like that. And yep, for me too, there comes a point when you're just knocking them off asap, or letting them slide, so you can get back to building the network you need to meet the major town growth goal, and that's where the satisfaction is for me as well.

As such, I really like your improvement ideas re new major industry based goals, with the unlocks, and more gradually ramping up of the number of goals. I also like the idea about changing the penalty approach after playing with it a bit more. If I knew I was about to lose all my money, I was spending it all on raising water next to my growth town in the month before year-end before the script blew it all away - funny, but aberrant.

I think I'll take a look and see what I can do. Thanks for the feedback and the great ideas!
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: Goal Based City Growth

Post by pbrennan »

As an fyi, I've made a version 2 of this script which I'm currently testing, featuring vertically integrated cargo "pickup and deliver" goals, and changed the penalty system per the suggestion above as it wasn't really working how I first envisaged. I've also increased the customisation quite a bit, so the player can specify exactly what type of goals they want to play with, and generate more (or stop them) intra-game if they wish. I'm enjoying the game-play more than the first version. Once I'm happy, I'll post it up.
User avatar
supermop
Tycoon
Tycoon
Posts: 1104
Joined: 21 Feb 2010 00:15
Location: Fitzroy North - 96

Re: Goal Based City Growth

Post by supermop »

pbrennan wrote:As an fyi, I've made a version 2 of this script which I'm currently testing, featuring vertically integrated cargo "pickup and deliver" goals, and changed the penalty system per the suggestion above as it wasn't really working how I first envisaged. I've also increased the customisation quite a bit, so the player can specify exactly what type of goals they want to play with, and generate more (or stop them) intra-game if they wish. I'm enjoying the game-play more than the first version. Once I'm happy, I'll post it up.

Sounds very interesting - maybe post what you have on bananas to get some more play-testing?
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: Goal Based City Growth

Post by pbrennan »

For anyone who's interested, I've placed version 2 in the original post, with details on the changed game play. I've been enjoying this version and the ability to craft a game to taste more than version 1. As before, open to other suggestions, but happy with it as is as well.
Last edited by pbrennan on 22 Dec 2016 14:06, edited 1 time in total.
Magitex
Engineer
Engineer
Posts: 5
Joined: 14 Dec 2016 03:43

Re: [GS] Goal Based City Growth

Post by Magitex »

Thanks for the updates pbrennan. The new system is much more interesting.

I've made a couple adjustments to the script for an OpenGFX Mars Industries Terraforming scenario, for something a bit different from my usual TTD games.

Changes:
OpenGFX Mars Industries support for City Growth and Goals.
Terraforming Mars Victory goal. You only win after completing ALL major goals AND successfully terraforming Mars.
It requires that you supply and fund Terraforming Plants to win the game, as well as the completing the major goals.
Tree growth occurs naturally as terraforming occurs so it's recommended to play without trees when generating a map.
Minor goal dynamic difficulty was added. Goals get more frequent and larger over a hundred years and slightly less frequent when failing goals.
Major goals are much larger as the scenario is intended to be played from 2000 - 2100.
An option added to the script configuration to control how common minor goals are.

Required GRFs:
OpenGFX Mars Industries.
OpenGFX Mars Habitats. (required to be able to ship Goods to cities.)

Recommended GRFs:
NUTS and vactrain set.
Toyland to Mars Convertion.
OpenGFX Mars Rovers and Roads.
Martian Town Names.
BaseCosts GRF for higher rail infrastructure and higher raise/lower costs.

Check the readme for more specific scenario settings.

The additions are not well tested, but I've yet to see any issues. Hopefully the tree growth won't cause any issues.
Attachments
Goal Based City Growth Mars.zip
(48.68 KiB) Downloaded 261 times
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

My baby grows wings :-)

The weird thing is ... I was just watching The Martian today!

Can we play normal games (ie normal terrain with FIRS) with this Mars version? ie is it backwards compatible and this becomes the new base script, or is it a standalone fork and the original script remains the base for normal games? (I haven't explored scenarios yet, so I'm a bit unfamiliar with the environment.)

If the latter, I know it was one of your wants to integrate dynamic minor goal frequency into the core script. I wasn't sure it was worth it, but happy to have it included if you definitely think it's an improvement.
Magitex
Engineer
Engineer
Posts: 5
Joined: 14 Dec 2016 03:43

Re: [GS] Goal Based City Growth

Post by Magitex »

I tried to leave it compatible, but it does look like I broke something related to FIRS, but I can probably fix it up (edit: missed a break statement). The terraforming goal only activates when Mars industries is selected so the terrain shouldn't be any problem.
I can't say whether my changes are an improvement or not, I haven't had any time to actually playtest them :cry:
Magitex
Engineer
Engineer
Posts: 5
Joined: 14 Dec 2016 03:43

Re: [GS] Goal Based City Growth

Post by Magitex »

Here's a proper FIRS/Baseset compatible version with all the Mars options.
I reverted some of the variables to more nomimal values to better match the original settings. I also added a major goal cargo scale.

It should work with and without any mars stuff, although the mars specific version is tuned slightly better for Mars Industries.
Attachments
Goal Based City Growth.zip
(48.6 KiB) Downloaded 200 times
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

The "major scale" addition needs the following to ensure cargo goals are generated correctly:

amountfloat = (production.tofloat() * (major_scale.tofloat()/100));

There's a couple of other small changes I'd like to make. Let me do those on your Mars version and I'll post a version 3 to the OP.
Magitex
Engineer
Engineer
Posts: 5
Joined: 14 Dec 2016 03:43

Re: [GS] Goal Based City Growth

Post by Magitex »

pbrennan wrote:The "major scale" addition needs the following to ensure cargo goals are generated correctly:

amountfloat = (production.tofloat() * (major_scale.tofloat()/100));

There's a couple of other small changes I'd like to make. Let me do those on your Mars version and I'll post a version 3 to the OP.
Thanks, I should have tested this bit more thoroughly - I threw it in at the last minute when I still wanted higher major cargo goals but didn't want to set it above the normal value because it might not work on small maps or low industry settings.
You're welcome to change or use anything from these scripts.

edit: I should mention the Scrap yard major goal text definition seems to not be found when using FIRS Extreme, I'm not sure if it was a problem with the original script or something I nipped by accident.
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

I've taken the Mars version as the new baseline, and added some more paramaterisation, allowing the player to:
- choose the average duration of minor goals (+/- 1 or 2 years randomly) and
- choose the population target for major town growth goals

Hopefully this means we can now define the Mars scenario using the parameter settings without having to hardcode too many variances. I've modified the readme accordingly, and created a new section outlining some potential game settings for first-time players. It might be useful to include a section there listing recommended settings for the terraforming mars scenario.

Anyway, I formally hand the code back out to anyone who'd like to take it a step further ... :-)

(edit: Wrecking Yard should be fine now ...)

Patrick
bouchacha
Engineer
Engineer
Posts: 14
Joined: 04 Dec 2015 03:47

Re: [GS] Goal Based City Growth

Post by bouchacha »

Thank you so much for making this script! I wanted to check if it's working properly but the goals don't seem to be showing up. I even set up a rudimentary bus route to deliver passengers (in case that was the trigger)
I'm using JGR's patch pack and FIRS if that matters

Image
HGus
Engineer
Engineer
Posts: 120
Joined: 12 May 2013 22:28
Location: Argentina

Re: [GS] Goal Based City Growth

Post by HGus »

bouchacha wrote:Thank you so much for making this script! I wanted to check if it's working properly but the goals don't seem to be showing up. I even set up a rudimentary bus route to deliver passengers (in case that was the trigger)
I'm using JGR's patch pack and FIRS if that matters
Goal is shown in "Goals" list:

Image
Attachments
Trimmed screenshot showing the location of "Goals" button
Trimmed screenshot showing the location of "Goals" button
Unnamed, 12th Jan 1950.png (174.25 KiB) Viewed 2208 times
Last edited by HGus on 18 Jan 2017 07:07, edited 1 time in total.
bouchacha
Engineer
Engineer
Posts: 14
Joined: 04 Dec 2015 03:47

Re: [GS] Goal Based City Growth

Post by bouchacha »

Ah ok! So it doesn't have the RCG growth options? I was confused from the description above "The RCG town growth aspect is identical to the original"

Image
bouchacha
Engineer
Engineer
Posts: 14
Joined: 04 Dec 2015 03:47

Re: [GS] Goal Based City Growth

Post by bouchacha »

Nevermind, it looks like the RCG script takes 2 months to kick in. It appears to be working as expected after that. Very excited to play around with this, thank you!
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

You're welcome! Let us know if you think of any improvements or additional functionality that might be interesting.
Lollipop
Engineer
Engineer
Posts: 26
Joined: 01 Feb 2011 10:09

Re: [GS] Goal Based City Growth

Post by Lollipop »

Excellent job! The only thing I'm missing is the ability to cancel minor goals (for a penalty). Maybe via signs? Too many fishing harbor without fish. Now once aircraft come around, anything goes, but I'd like to keep the illusion of economic meaningfulness.

And sometimes goals are *really* challenging....
Attachments
Unnamed, Jan 1st, 1940.png
(98.66 KiB) Not downloaded yet
HGus
Engineer
Engineer
Posts: 120
Joined: 12 May 2013 22:28
Location: Argentina

Re: [GS] Goal Based City Growth

Post by HGus »

Lollipop wrote:
And sometimes goals are *really* challenging....
LOL, you still can build bridges to nearest coast (to let it grow there) and feed the city with boats (avoiding the jams!)

Post a savegame please :)
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: Exabot [Bot] and 3 guests