[GS] CityController v8

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

hpfx
Engineer
Engineer
Posts: 43
Joined: 09 Nov 2013 00:19

[GS] CityController v8

Post by hpfx »

Hello,

I would like to present you my Game Script : City Controller (CTCT)

Main behaviors

- Town growth based on cargo delivered. non-linear, dynamic rate (logarithm alike)
- Simple display on town screen (don't flood user with many figures, just highlight levels)
- Automatic and progressive cargo acceptance, based on installed newGRF, tested with ECS and FIRS (any economy mode)
- Two game types : collaborative or competitive [new V4]
- Town stabilizer (rebuild user buldozed town tile to avoid decreasing) [new V6]
example with goals
example with goals
exe4.png (128.7 KiB) Viewed 33198 times
examples
examples
examples.png (99.43 KiB) Viewed 33194 times

Download
download in game


Version history


Version 8 (March 2023) Back in the game !!!
compatibility release, stay tune for better release...
- fix crash when no cargo recognized for unlocking, prevent future cases.
- fix do not rely on old cargo id anymore to recognize cargo
- town effect is not used by FIRS and ECS, better use cargo code
- recognize 2 new cargos : vehicle and farm supply
- display completion year for cargo unlock goals
- add "quick Achievement" option to make goals faster to achieve (divide goals quantities from 2 to 5)


Version 7 (May 2015 : rev 164)
- fix a small issue with town increase indicator when town no cargo are delivered.

Version 6 (August 2014 : rev 162)
- add city stabilizer : new option
- fix loading big map issue

Version 5 (May 2014 : rev 147)
- fix a bug at industry sign
- fix a bug at town funding
- change text color

Version 4 (April 2014 : rev 141)
- new game type : competition (claimed city)
- display company or manager name at claimed city
- add company goal for claimed city
- add leader notes on global goals
- fix a bug at industry sign

Version 3 (April 2014 : rev 127)
- new cargo mode : start with few cargo, unlock others.
- display town thresholds as global goals, show goal progress (checked twice a year)
- town goal scales on number of accepted cargos
- yearly update of map inhab/house.

Version 2 (April 2014 : rev 115)
- fix : avoid unwanted house creation on gameload
- better inhab per house computation
- smoother town growing
- now on bananas !

Version 1 (March 2014 : rev 103)
- non linear growing rate
- only 1 game type for now : "Every towns are free, Collaborative Town growing", other types will come later...
- compatible FIRS, ECS and builtin economies
- town cago acceptance : 3 modes
- display industry name option
- cargo bonus when all cargo types are delivered
- two languages : EN, FR
- based on Minimal GS 2 from Zuu


Notes

- non linear growing
see next post for picture.
we can have different kind of curves depending on cargo classes.


- town acceptance.
the script does not change cargo town acceptance,
it just change how it's took into account.
in normal mode, town will took into account only basic cargos (depending on newGRF)
when your town is growing it will took into account more and more cargo.
the number of accepted cargo depends on town size.


- unlocking cargos.
depending on mode you choose, you can play with every cargo unlocked from the begining, or with a progressive approach.
on progressive mode, cargos are unlock when a given number of town reach a given size.


- bonus.
by delivering all expected cargo type to a town, a growing bonus is given.
you can reach higher bonus by unlocking cargo to deliver.


- delivered cargo
Picked up cargo is not took into account, but only delivered to town does count.
in multiplayer, in collaborative mode (other mode aren't developed yet) : every player cargos are summed up for each town.

- stabilizer.
when user buldoze town tiles, city is decreasing, this script has option to avoid it.
if script detect the number of house difference and trigger an house creation.

Compatibility

- no dependancy required.
- scripts tested with each 4 builtin climats, FIRS (any economy), ECS vectors, and it will be compatible with upcoming ones, because it take towneffect cargo indicator.
- multiplayer compatible.
- savegame compatible.
- It's compatible with openttd v1.3 and higher : 1.4, 1.5, trunk...

note : if you play without economy newGRF, you will at least enjoy impact for valuable cargo.



Thank you.
Attachments
ctct-v7.zip
ctct-v7
(26.5 KiB) Downloaded 729 times
Last edited by hpfx on 21 Mar 2023 22:11, edited 28 times in total.
hpfx
Engineer
Engineer
Posts: 43
Joined: 09 Nov 2013 00:19

Re: [GS] CityControl

Post by hpfx »

Non linear growing rate graph :
curves example
curves example
courbes1.png (12.77 KiB) Viewed 33589 times
Damrus
Engineer
Engineer
Posts: 21
Joined: 23 Apr 2014 14:23

Re: [GS] CityController v4

Post by Damrus »

Pretty cool Gs you have there : ]

Btw, would future builds allow for editing the None liniar grow rate curve?
Mojhave
Engineer
Engineer
Posts: 10
Joined: 11 Dec 2010 17:44

Re: [GS] CityController v4

Post by Mojhave »

Hi, gave this a try and it looks really nice. However, i couldn't quite figure what exactly happens when i change the difficulty. Second, is there a bonus for delivering more than one cargo?

thx
fabca2
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 14 Apr 2004 15:18
Location: Fr

Re: [GS] CityController v4

Post by fabca2 »

Hello,
there is a bonus when town is expecting 3 cargos for example, and if you delivers 3 cargo a bonus is provided.
But not more, I think you have to unlock new cargo first.
hpfx
Engineer
Engineer
Posts: 43
Joined: 09 Nov 2013 00:19

Re: [GS] CityController v4

Post by hpfx »

Hi,
thank you for your post,
Damrus wrote:Btw, would future builds allow for editing the None liniar grow rate curve?
Not at the moment, maybe later, but that's not easy.
By the way it took months of playing to adjust rate and curve : it make passenger interresting to start with, but you need to focus on goods to have your town growing more... and so on. (depends on ecs-vector/firs...)
Mojhave wrote:Hi, gave this a try and it looks really nice. However, i couldn't quite figure what exactly happens when i change the difficulty.
Changing difficulty makes harder/easier to make your towns growing.
setting to very hard will require you to deliver much more to allow your town growing.

And btw, as it's non linear it's even harder when your town is getting bigger.
Mojhave wrote: Second, is there a bonus for delivering more than one cargo?
If you deliver cargo that is not (yet) required, there are no bonus.
you must first unlock cargo, that's the chalange of this script.

Bonus is given on delivering all expected cargos (at medium level).
lcd_47
Engineer
Engineer
Posts: 78
Joined: 27 Sep 2006 18:04

Re: [GS] CityController v7

Post by lcd_47 »

I seem to have found a bug:

Code: Select all

dbg: [script] [18] [S] Your script made an error: wrong number of parameters
dbg: [script] [18] [S] 
dbg: [script] [18] [S] *FUNCTION [extendWithCargo()] city_controller-7/towns.nut line [371]
dbg: [script] [18] [S] *FUNCTION [checkNextCargo()] city_controller-7/towns.nut line [337]
dbg: [script] [18] [S] *FUNCTION [HalfAYear()] city_controller-7/main.nut line [222]
dbg: [script] [18] [S] *FUNCTION [Start()] city_controller-7/main.nut line [86]
dbg: [script] [18] [S] 
dbg: [script] [18] [S] [info] INSTANCE
dbg: [script] [18] [S] [user] true
dbg: [script] [18] [S] [type] 3
dbg: [script] [18] [S] [rate] 5
dbg: [script] [18] [S] [nbtown] 30
dbg: [script] [18] [S] [limite] 21000
dbg: [script] [18] [S] [cargo] 29
dbg: [script] [18] [S] [this] INSTANCE
dbg: [script] [18] [S] [added] TABLE
dbg: [script] [18] [S] [nbtown] 30
dbg: [script] [18] [S] [all_towns] INSTANCE
dbg: [script] [18] [S] [nbtoreach] 1
dbg: [script] [18] [S] [limite] 21000
dbg: [script] [18] [S] [this] INSTANCE
dbg: [script] [18] [S] [this] INSTANCE
dbg: [script] [18] [S] [month] 1
dbg: [script] [18] [S] [year] 2036
dbg: [script] [18] [S] [current_date] 743637
dbg: [script] [18] [S] [loop_start_tick] 1482
dbg: [script] [18] [S] [last_loop_date] 743632
dbg: [script] [18] [S] [this] INSTANCE
dbg: [script] The script died unexpectedly.
More information and/or savegame available upon request.
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: [GS] CityController v7

Post by krinn »

lcd_47
when API change, a compatiblity script is use to let "older" script/ai running with "old" api feature.
so if you lack the compatibility script file, the needed changes aren't set, and script will use new api feature using old style, and crash.

you should seen at start (in console log) a "missing compatibility version 1.x" message, way to fix that is make sure your package is using the needed file.

look for game/compat_1.x.nut files (take it from any packages, well, take it from a linux version or source as windows version may have an installer and may have its files pack into some installer exe)
Where these files should be put depend on your arch, so i couldn't tell you (i think the openttd wiki have an entry telling you per arch directory/location).

If you are totally lost : if the script allow you to disable news (in its options), ask the script to stop trigger a news item to avoid the crash ; or wait for hpfx to add support 1.5 gs api.
lcd_47
Engineer
Engineer
Posts: 78
Joined: 27 Sep 2006 18:04

Re: [GS] CityController v7

Post by lcd_47 »

@krinn There seems to be an installation problem with one of the patches I'm using, but your post pointed me in the right direction. Thank you for the hints!
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [GS] CityController v7

Post by Zuu »

Furthermore you should not grab the compat files from a random OpenTTD version, but the same one as you installed. Both a newer and an older may cause trouble. This is why these files must not be placed in the shared script directory in Docements\OpenTTD (or equivalent in your OS). But should reside in the installation folder of that OpenTTD version.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
lcd_47
Engineer
Engineer
Posts: 78
Joined: 27 Sep 2006 18:04

Re: [GS] CityController v7

Post by lcd_47 »

@Zuu Sadly, they are not installed on Linux. For what it's worth: make install creates a folder bundle that contains, among other things, ai/compat_*.nut and game/compat_*.nut, but only ai/compat_*.nut are actually installed. Copying bundle/game to /usr/local/share/games/openttd solves the problem.
krinn
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 29 Dec 2010 19:36

Re: [GS] CityController v7

Post by krinn »

lcd_47 wrote:@Zuu Sadly, they are not installed on Linux. For what it's worth: make install creates a folder bundle that contains, among other things, ai/compat_*.nut and game/compat_*.nut, but only ai/compat_*.nut are actually installed. Copying bundle/game to /usr/local/share/games/openttd solves the problem.
That would be for http://bugs.openttd.org/ then
But last time i check the provide linux binaries was having it, must be distro specific, something for their own bugzilla so
lcd_47
Engineer
Engineer
Posts: 78
Joined: 27 Sep 2006 18:04

Re: [GS] CityController v7

Post by lcd_47 »

@krinn I'm compiling from sources, thus no distro to whine at. :)
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [GS] CityController v7

Post by planetmaker »

lcd_47 wrote:@krinn I'm compiling from sources, thus no distro to whine at. :)
Excellent find, it went unnoticed for years. r27399 should fix this. The 'install' target indeed never ever seemed to install the game dir. Distros probably do their own stuff there anyway, using the pre-built bundle and not caring about our own install target.
lcd_47
Engineer
Engineer
Posts: 78
Joined: 27 Sep 2006 18:04

Re: [GS] CityController v7

Post by lcd_47 »

planetmaker wrote:r27399 should fix this.
It does, thank you!
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: [GS] CityController v7

Post by Wahazar »

Interesting and challenging script.
Maybe a little bit to much challenging (maybe it is my fault, playing with ECS without ECS town - no tourist available in town but counted).
It is hard to get four 11k towns, because there are often 'deadlocks' - town is not growing because there is no sufficient pass/mail,
there is no sufficient pass/mail because town is too small.
Is 'fund buildings' option working? Maybe funding buildings would decrease temporarily amount of required cargo, for example 50% less?
If town (or cluster of towns) is 'deadlocked', it would be the option to jump off.

Another question concern goal window - one town reach 11k, but there is still [0%] of goal reached:
cityctrl.jpg
cityctrl.jpg (131.08 KiB) Viewed 28463 times
Is it a bug?
Save game is attached, all newgrfs are available online.

EDIT: not a bug, it was not refreshed or smth.
Attachments
McTest59, 15th Sep 1963.sav
(1.53 MiB) Downloaded 271 times
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: [GS] CityController v4

Post by Wahazar »

hpfx wrote: Changing difficulty makes harder/easier to make your towns growing.
...
And btw, as it's non linear it's even harder when your town is getting bigger.
I found, that even on very easy level it is hard to initialise town growth, in case of small towns
(not sufficient to grow with pax/mail generated itself).
Maybe there should be a minimal offset of impact to help small towns growing?

Another issue - in arctic climate there is disambiguation - town above snow line, without food, display 'no growth', but is growing.
I propose to fix it in towns.nut:

Code: Select all

if ( (GSTile.GetTerrainType(GSTown.GetLocation(town)) == GSTile.TERRAIN_SNOW) && (GSTown.GetLastMonthReceived(town, GSCargo.TE_FOOD)==0) )  /* snow line, food req     */
	{
		impact/=10;
	}
If food is not delivered during winter, regardless to other cargoes level and acceptance, growth will be suppressed (I divided by 10 to estimate, how large is original impact).

Another proposal is to give player opportunity to make pulse growth, if town is stalled.
My first idea was to use 'fund buildings', but have no idea how to check it on GS level.
Currently I'm using 'fund local road reconstruction':

Code: Select all

impact*=(3+GSTown.GetRoadReworkDuration(town))/3;
If impact factor is just below town population, it would give burst of new houses.
At least this silly option is use-able :)
Formerly known as: McZapkie
Projects: Reproducible Map Generation patch, NewGRFs: Manpower industries, PolTrams, Polroad, 600mm narrow gauge, wired, ECS industry extension, V4 CEE train set, HotHut.
Another favorite games: freeciv longturn, OHOL/2HOL.
Wahazar
Tycoon
Tycoon
Posts: 1451
Joined: 18 Jan 2014 18:10

Re: [GS] CityController v7

Post by Wahazar »

hpfx wrote: Version 7
I think I found a bug, running your script on multiplayer server:

Code: Select all

dbg: [script] [18] [S] Your script made an error: the index '2' does not exist
dbg: [script] [18] [S]
dbg: [script] [18] [S] *FUNCTION [endorse_RemoveHQ()] .openttd/game/TileLabel-CityCotroller/companies.nut line [140]
dbg: [script] [18] [S] *FUNCTION [DelCompany()] .openttd/game/TileLabel-CityCotroller/companies.nut line [33]
dbg: [script] [18] [S] *FUNCTION [HandleEvents()] .openttd/game/TileLabel-CityCotroller/main.nut line [213]
dbg: [script] [18] [S] *FUNCTION [Start()] .openttd/game/TileLabel-CityCotroller/main.nut line [116]
dbg: [script] [18] [S]
dbg: [script] [18] [S] [cid] 2
dbg: [script] [18] [S] [this] INSTANCE
dbg: [script] [18] [S] [cid] 2
dbg: [script] [18] [S] [this] INSTANCE
dbg: [script] [18] [S] [deadcompany] 2
dbg: [script] [18] [S] [ev_type] 11
dbg: [script] [18] [S] [ev] INSTANCE
dbg: [script] [18] [S] [this] INSTANCE
dbg: [script] [18] [S] [loop_start_tick] 39361
dbg: [script] [18] [S] [last_loop_date] 713953
dbg: [script] [18] [S] [this] INSTANCE
Seems, that it appear after company removal/bankruptcy.

any idea, how to fix it?
foxthib
Engineer
Engineer
Posts: 8
Joined: 22 Jul 2017 21:40

Re: [GS] CityController v7

Post by foxthib »

Hello,

I play with your script and I really apprciate it, thanks :)

I recently tried the "WIRES" and "FIRS" grf but when I deliver electricity (produce like 4MW with alcool), the city grwoth too much. With only electricity of an powerplant, the city growth up to 15 000 pop. It's really too easy to growth a city with this kind of ratio.
I don't know if it's a problem from your grf, WIRES or FIRS one but the mix of this three break the growth city system.

Thanks again for your work !
nexitem
Engineer
Engineer
Posts: 1
Joined: 21 Nov 2017 21:57

Re: [GS] CityController v7

Post by nexitem »

Is this still compatible with 1.7.1? Cause I used to play with it in 1.6 and had no problems afaik.
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 4 guests