[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

DeepFritz
Engineer
Engineer
Posts: 3
Joined: 20 Mar 2017 15:14

Re: [GS] Goal Based City Growth

Post by DeepFritz »

I really like this script, but I experience an unexpected behaviour:
To fulfill my major city growth goal, I connected the little village to some big "2500+" cities, to transport some passengers and mail.
The little village is now growing nicely, but all the connected 2500+ cities started shrinking and keep doing so. One of the Big Cities is down to less than 200 now. I wonder if this is some sort of a feature (I never transported any food to the Big Cities, and only a few passengers) or a bug?
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

I believe that's a feature of the original Renewed City Growth algorithm (which has been kept as is). Cities that trigger the growth algorithm (by having passengers delivered) often do it by first destroying something and then building something bigger. If you're only delivering minimum stuff, perhaps the destroying stuff is happening but the building something isn't triggering because the deliveries are too low. In my games, I've been delivering passengers/mails both ways, so as my major goal city grows, it has more passengers/mail to deliver outbound to my feeder cities, and these have always grown as well (be it more slowly however as I usually don't bother with food et al to the feeder cities).

If your major goal city is starting as a village and doesn't have enough passengers/mail to keep the feeder cities going by itself though, maybe do some links between the feeder cities to sustain them until your major goal city can do it by itself. Hopefully that helps.
DeepFritz
Engineer
Engineer
Posts: 3
Joined: 20 Mar 2017 15:14

Re: [GS] Goal Based City Growth

Post by DeepFritz »

I did some experiments now:
I unloaded all newGRFs except FIRS 2.1.3 and a train set (UKRS2). I started a new game and made a connection between two cities which were not too far apart, both about 2000 inhabitants. Then I bought two trains (both passenger+mail). I tried different start dates for the game and fiddled with the difficulty setting in the GBCG-Script Options.

I cannot make this work. Even with a difficulty of "1", the cities start shrinking as soon as the first train arrives at the station. At low difficulty, the shrinking seems to stop at about 1000 inhabitants.
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

If you have time, I wonder if the same behaviour happens if you use the original Renewed City Growth script rather than the Goal Based City Growth script. As downloading RCG gets the library installation stuff correct for GBCG, if it's fine using RCG, then revert to GBCG and see if it now works. (?)
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

Also, it might be useful to double check that the FIRS GRF economy parameter setting is identical to the GBCG AI/script economy parameter setting. If they're not identical, the game will be telling you to deliver these things, but the script will be checking for different things. (Just in case.)
DeepFritz
Engineer
Engineer
Posts: 3
Joined: 20 Mar 2017 15:14

Re: [GS] Goal Based City Growth

Post by DeepFritz »

I tried the RCG-script. I couldn't use the latest version, since the download-link doesn't work. I used standard V5, which has some problems with FIRS 2.1.3. but I guess these problems only affect industries/cargos.

The problem seems to be the same. I actually managed to keep the cities at a somewhat constant level (very volatile though, it kept shrinking and growing again). But the cities were very close together, which probably helped a lot.

I start wondering if all this behaviour is intentional, and I am just a very bad player, that I find it so hard to keep a city from collapsing. It doesn't feel right though, that people start to leave the city as soon as a train arrives. Personally, I don't know many people who moved house by train. :D
FranklinTranspo
Engineer
Engineer
Posts: 1
Joined: 10 Jun 2017 07:05

Re: [GS] Goal Based City Growth

Post by FranklinTranspo »

I just wanted to say a huge thank you for put this out there - This is EXACTLY what I was looking in Openttd. I hadn't played in nearly 7 or 8 years, and have been messing around with GRFs and other game scripts all week, but yours has had me hooked and staying up all night playing two days in a row, something I haven't done since college. Two huge things that I think really made it excellent for me - the extreme FIRS economy makes the RCG town management mechanics more fun to use because i feel like I'm using them towards the major town growth goals a lot of fun. I just finished a play through to 2050, and the ability to add new major goals via signs was fantastic, and kept it lively right up to the end. I'm very excited to try the Mars version next!


Three thoughts, one on difficulty and two suggestions, one of which I think is possible, and the other, I'm less sure of. For all I know both might be impossible to implement:

Difficulty
The mad rush of the beginning for me was compounded by it being my first FIRS extreme economy. I spent a lot of time paused and panning around the map trying to link in my head what I was learning about the industry chains with how the hell I was going to get it where it needed to go. I don't know if it was implemented as per someone else's suggestion, or possible to implement if it wasn't just luck but it seemed to me like my first few years had very little of the tertiary economic products, and that helped me a lot getting into it - by the time they showed up I was comfortable adding them to my network. Getting those first couple major goals done is tough, but by the time you can complete the growth goal, you can probably complete nearly any other goal fairly rapidly. If I do another run I might try and be a real sadist and bump the town growth up to 50k or so - getting a city to that level requires planning out the industry/transport intakes and infrastructure, as much as anything else, and was something I did somewhat poorly this time, though because I only had a 30k goal, it didn't hamper me too badly.

Region Goals
The simpler one is "intermediate goals" - minor goals that are region focused near your major town growth goal, to help force you to build the network out near your growth goal city, as time moves on perhaps expanding the radius of how far away it will look. Especially on a big map I think this would help focus the game play and help you to interact more with a specific region that grew instead of forcing you to build two tiny point to point networks on opposite sides of the map.

City to City Passenger Goals
The harder one would be some sort of city to city transit goals - ie, a minor goal like transport x number of people/mail from City A to City B, with the average distance between the cities growing over time, forcing you to really add the cities to your network instead of just permitting point to point shuttling like the current minor growth or mail dump goals do. To an extent, airports make that an easy goal later on, but if the volume increased depending on the year, it would make other forms of transit appealing. The volume would also probably need to be tied to the city size, but another cool major goal would be to add something like transport 10k/20k passengers between two cities in a 12 month period. Like the vertical integration goals, getting 20k passengers between two cities requires you to first build up the two cities to have the pop to generate enough people, which itself requires you to put work into industries around them and focus on the whole network.


Again, huge thank you for this, and for maintaining the RCG mechanics - I discovered this after failing to get the most recent RCG version to play nice with FIRS but I really do love RCG's mechanics, and how much you've added to them with this. Any idea if it would be possible to get it to work with ECS? I know the last version of RCG had ECS compatibility, but I have no idea if that makes your life any easier or harder.
Tharagon
Engineer
Engineer
Posts: 1
Joined: 03 Sep 2017 15:47

Re: [GS] Goal Based City Growth

Post by Tharagon »

There seems to be a serious problem when using other languages than English. When displaying major pickup goals, the industry type is not found.
As far as I can see this happens, because in CompanyGoal::GetIndustryTypeString() the function GSIndustryType.GetName() returns an already localized string. The following cases don't match anymore.
Asterix3
Engineer
Engineer
Posts: 1
Joined: 05 Jan 2018 00:30

Re: [GS] Goal Based City Growth

Post by Asterix3 »

This is my favourite GS so far. Great work!

Just started playing around with FIRS too, which makes this GS a good challenge for a beginner like me. However, with the release of FIRS 3 just a few days ago it seems there are compatibility issues with the industries. I suspect this is due to some of the goods and industry names being changed in the update.
srschacher
Engineer
Engineer
Posts: 41
Joined: 15 May 2017 12:48

Re: [GS] Goal Based City Growth

Post by srschacher »

First, let me thank you for creating this script. As a solo player without AIs, this is what I've been looking for.

I was playing with the Renewed City Growth script with the FIRS Extreme economy, and liked the goal (if you will) of having to deliver particular cargoes to drive city growth. Still, there were no objective goals, just the overall goal of growing cities.

Some caveats... I haven't finished a game yet, but started several. I get caught up in restarting from day 1 and trying different networks. As a result, I haven't failed any minor goals yet, because I haven't gotten that far. A new generation of map has far-flung dependent industries, but so far I have not let a minor goal expire.

My first game gave me a small town of 500 to grow, but it was in the corner of the map with only one industry (two if you count the coal mine) and one neighbor. Needless to say, the town started shrinking once I started passenger service. I tried different strategies, and finally settled on tolerating the shrinkage for awhile while I set up a food chain. Once I delivered food (not required to a < 500 town), the town did start growing again. So, food... important!

My current game has a better cluster of related industries, so it's more interesting to build and play. I'm also learning to eat the loss on rail if it enables the greater value chain of finished goods. I think...

All that said, onto my point...

One thing I look for in games is the distinction between "gamey" player inducements versus in-game character inducements. In other words, the thematic behavior. Although I haven't failed a minor goal yet, I'd like to ruminate on the 1% per month penalty on failing minor goals.

To separate the player (me) from the character (the Company boss), how is the 1% per month penalty thematic? I understand the motivation of me (the player) to not have a 1% per month penalty on the company for the rest of the game, but is there a "real world" counterpart to that penalty that the in-game Company would experience, or is it a player penalty only? Should the Company be free to ignore a minor goal if it is too costly (or not a priority for the Company's funds) for my company to implement?

I'm struggling to come up with a thematic explanation for the 1% monthly drain on my bank account. It's not a loss of market share (or a loss of growth), because that would reduce new annual income but not banked income. It's not a payment from a lawsuit, because I can't imagine being sued for not doing something the company is not obligated to do -- unless the minor goal represents some development contract with a town that the company reneged on. However, that might be a one-time penalty, but not a persistent one for the remainder of the game.

Maybe a better penalty is to assess the 1% on the annual income instead of the company balance. This is a smaller number and could reflect an opportunity loss, but it still feels "gamey" in that it takes away actual gains instead of reducing gain potential.

Which leads me to my idea...

Instead of assessing the percentage penalty, what if you made the goal-town's relationship to the Company "atrocious" instead? The town holds a grudge for being passed over by the Company, and they will block future growth in the town limits for stations near their industries, effectively cutting off parts of the map for development. If future minor goals are similarly expired, more towns will become atrocious to the Company. If the town controls a needed industry in the product chain, the player will have to look elsewhere or fund the industry to start up somewhere else. Then, the Company will have to consider bribing town officials (the monetary penalty), or maybe time will heal wounds?

Anyway, just some player thoughts to consider. Do you think that converting towns to "atrocious" would have a similar player motivation to complete minor goals?

Steve
srschacher
Engineer
Engineer
Posts: 41
Joined: 15 May 2017 12:48

Re: [GS] Goal Based City Growth

Post by srschacher »

Asterix3 wrote:This is my favourite GS so far. Great work!

Just started playing around with FIRS too, which makes this GS a good challenge for a beginner like me. However, with the release of FIRS 3 just a few days ago it seems there are compatibility issues with the industries. I suspect this is due to some of the goods and industry names being changed in the update.
If you want to fix this, take a look at the code fragments in this post: viewtopic.php?p=1201474#p1201474

If you expand the Goal Based City Growth tar file, you will find a cargo.nut file. Replace the code in the post in the relevant sections of the cargo.nut file. Take note that the code fragments refer to Case 5, but this script has the code in Case 8.

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

Re: [GS] Goal Based City Growth

Post by pbrennan »

I've updated the original post with version 4, which is an update to work with FIRS 3.0.3. The only functional change was to modify the levels at which cities will start expecting deliveries in the next higher level category - to 5000, 8000, 10000, 12000 - to stop cities that start with a decent population immediately requiring deliveries in category 2. It also seems a better balance given the goal at easy level is to get to 20000. I also moved some cargos into different categories, where they seemed a better thematic fit.

I played a Steeltown economy (1024x2048) with max 10 cities recently to test. This meant cities owned LOTS of industries and made it easy to ratchet up growth. The vertical integration goal was to deliver Coal to Coke Ovens (easy), then Sulphur to Tyre Plants (less easy given the Coke Oven produces coke/sulphur at a 75%/25% ratio), Vehicles Parts to Assembly Plants (a dog given I had to ramp up rubber everywhere), and finally Engineering Supplies from Assembly Plants (another 25% good, which was a major dog as I had to ramp up on Vehicle Bodies which required steel which required ...). Which meant most of the industries on the board had to get up and going to get there, but it felt very rewarding when it finally got there and the game was won. I then let the cities play out, and with so many goods being delivered within their spheres, they eventually popped over 200,000 people each before starting to slow. All of which is to say that growth opportunities in this script are a function of the city to industry ratio in your setup.

I really liked playing with the variable snowline btw. Thanks for the development on that one!

While here, I do wish cities at decent sizes looked like cities with suburban sprawls however, and less like a blob of skyscrapers with a two-ring block of houses around the edge. Apart from using the Swedish set, or Japanese set with shrines, (which both just limit the skyscraper look but I suspect have the same zoning issue) is there any other town-zoning solution in play?
lugo
Engineer
Engineer
Posts: 100
Joined: 12 Oct 2010 13:55

Re: [GS] Goal Based City Growth

Post by lugo »

pbrennan wrote: While here, I do wish cities at decent sizes looked like cities with suburban sprawls however, and less like a blob of skyscrapers with a two-ring block of houses around the edge. Apart from using the Swedish set, or Japanese set with shrines, (which both just limit the skyscraper look but I suspect have the same zoning issue) is there any other town-zoning solution in play?
You might want to have a look at Pikkabirds TaI.
CornMaster
Engineer
Engineer
Posts: 8
Joined: 11 Oct 2005 19:34

Re: [GS] Goal Based City Growth

Post by CornMaster »

Just found this script and am playing a game. Only a few years in, but I love it.

Just wanted to drop in and say thanks for making it.
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

You're welcome :-)

It keeps the game alive for me, coming back to it every now and then with different combos of goals, frequencies, map sizes, and city numbers for different feels.
Stoann
Engineer
Engineer
Posts: 1
Joined: 16 May 2018 21:41

Re: [GS] Goal Based City Growth

Post by Stoann »

Is it possible to get this working in multiplayer? Tried with my brother but he didn't get any goals when he joined my game and vice versa.

Incidently, there appears to be a mismatch in some of the industry string names that GBCG checks for and the ones that FIRS 3.0.8 provides. I got it working by changing the following in the GetIndustryTypeString function in companygoal.nut:

case("Scrap Yard") => case("Junk Yard")
case("Fishing Harbour") => case("Fishing Harbor")
case("Aluminium Plant") => case("Aluminum Plant")
case("Timber Yard") => case("Lumber Yard")

There might be others, those are the ones I noticed so far.
Thanks for your hard work op :)
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

Unfortunately I don't understand the code infrastructure well enough to ensure I can get multi-player working correctly. The retrieving and saving of games in particular. Basically I cobbled together some older scripts into one script and used what they had. If someone else would like to give it a go though, go for it.

I wonder if those FIRS 3.0.8 mods are an American english vs English english translation type thing, as I did test with those industries and had no issue. I'll look out for them next time I'm in and playing. Thanks.
CornMaster
Engineer
Engineer
Posts: 8
Joined: 11 Oct 2005 19:34

Re: [GS] Goal Based City Growth

Post by CornMaster »

Has anyone reported problems with goals "expiring"? Played two games so far. It my first, something weird happened to my oil refinery, and there was an invisible train or something there, so I couldn't update/delete the station, and it was transferring cargo instead of dropping it off. I also had scattered expired goal that I didn't think expired.

In my new game I haven't had any problems like that, but I have had two goals expire, but as far as I can tell should not have happened. Is there a log anywhere of the goals and their statuses?

Also, how do you grow a town when you get to the L2 goals? My city to grow is in an awful spot with no land and industries. Although using passengers and mail (and eventually an oil rig), I've got it over 5000 population. But L2 seems to require coal, iron ore or livestock. But there are no power plants, steel mills or factories allocated to the town. Also, the town seems to keep growing anyway (nearly 600 pop now) without the "General Food" category.

Thanks,
Thomas
pbrennan
Engineer
Engineer
Posts: 21
Joined: 10 Dec 2016 22:46

Re: [GS] Goal Based City Growth

Post by pbrennan »

I've had/seen no issues with goals expiring before their expiry date. If other weird stuff is happening, we'd probably want to rule out issues with the game installation before looking at the script itself. I can't recall if I logged goals in the debug script or not - that'd be the place to look. You'd want to set the debug script to high (3 iirc) in the script's parameters.

Re city growth, all you can do is maximise the receipt of goods that it can receive. It doesn't need goods in all levels to grow, it'll grow with just passengers and mail. To reduce the number of days it takes a town to grow as much as possible and as quickly as possible (maximising its speed of growth), you'll want to deliver the required amount in each required level. The town will still grow without doing that, but slower. Eventually growth may slow to a halt as the monthly good requirements grow and you miss them by more and more, but in my experience that's usually been in the tens of thousands. One mid-game solution at this point is to fund new industry within the city limits.

If town growth is the aspect you enjoy most, one approach I've played with is to start on a big map with FIRS Extreme and only 10 or so towns. Each town then has plenty of industries to work with and I've been able to reach multiple hundreds of thousands in multiple towns that way. To me it feels more realistic this way anyway. But I'm Aussie ... towns are far apart here :-)
srschacher
Engineer
Engineer
Posts: 41
Joined: 15 May 2017 12:48

Re: [GS] Goal Based City Growth

Post by srschacher »

I was always slightly put off by the penalty system for letting goals expire, so I finally made the effort to try to add code to the script to make the changes I would like to play.

Currently, for each goal that expires, the company is penalized 1% of their current balance each month for the rest of the game, or 12% per year per missed goal. What I don't like is 1) the penalty lasts for the rest of the game, and 2) the penalty increases each month because the company grows each month.

I wanted to try an approach that was more like defaulting on a contract and paying a penalty clause. I recoded the penalty sections of the script to do the following:

1. When a goal expires, a penalty is calculated at 10% of the current company balance. Each subsequent expired goal increases the penalty by 5%, so the second expired goal is penalized at 15%, the third at 20%, etc.

2. The penalty is spread out over seven years of monthly payments (84 months). The penalty ends after the 84th payment.

3. If a penalty is still being paid when another goal expires, the remaining penalty balance is added to the new penalty and spread out over a new seven year period.

It will be awhile before I get to fully test it because I'm enjoying the game I have running now and don't want to mess it up with forced penalties just to test the code. However, once I finish this game I will focus on testing this out. I should look into making the duration of the penalty a script parameter, as well as the starting penalty percent and penalty growth rate.

Thoughts?

Steve
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 4 guests