Peter1138's Towngrowth Challenge

This is the project page for the Towngrowth Challenge, based on the [Openttd Challenge Spinoff] by Korenn. Hopefully, this project will allow the gameplay to be viable for trunk inclusion.

Contents

Towngrowth Challenge (TC) gameplay goals:

Each game started with TC has a population goal set, which can be defined at the beginning of the game and is immutable once the game has started. Once a company's claimed population reaches the population goal, that company wins the game. After the game is won, play can continue in the normal fashion but without scoring (like in regular ttd). The normal ttd game rules still count, so construction still costs money and a company losing too much money will go bankrupt.

additional rules and definitions:

With these rules the challenge becomes to make the towns you have claimed grow. But other than in normal ttd, the towns do not grow unless their demands are met.

TC introduces 7 classifications for towns: The cargo deliveries mentioned are on a per month basis.

community

  • A small settlement of up to 300 inhabitants.
  • Communities demand either passengers or mail delivered to grow.
  • When a community is smaller than 150, it will grow on its own to make sure passenger transport is possible.
village

  • A village has 300 up to 600 inhabitants.
  • Villages require both passengers and mail delivered to grow.
township

  • Townships are villages on the edge of becoming a town, they have from 600 up to a 1000 inhabitants.
  • Townships require a larger amount of passengers and mail delivered, plus either a supply of water or food before they'll grow
town

  • Towns are small larger concentrations of people of 1000 to 3000 inhabitants.
  • Towns require even more passengers and mail, plus both food and water to grow.
city

  • A city can have from 3000 up to 6000 inhabitants.
  • Cities require large amounts of passengeers and mail, larger amounts of food and water, and either goods or valuables to grow.
metropolis

  • A metropolis is a thriving hub of civilization with a minimum of 6000 and a maximum of 15000 inhabitants.
  • A metropolis requires all cargo: large amounts of passengers and mail, serious amounts of food and water and both goods and valuables before it will grow.
capital

  • A capital is the largest size a town can be in TC.
  • It allows for a small amount of growth under the same requirements as a metropolis up to 15500 inhabitants, to avoid a town bouncing between metropolis and capital.
  • Once at or over 15500 inhabitants, it can no longer grow.

Towns track how many units of cargo they have received from all companies since start of game. The company with the highest amount has claim of the town and its population counts towards this company's population total. Cargo supplied to a power station belonging to a town counts as power for the town. A town with sufficient power (power demand depends on town size) grows 4 times faster than a town without power.

Cargo and industries

there are 3 types of industries in TC, internally classified as primary, secondary and tertiary industries.

Only secondary industries can be funded (in fact, they will not start on their own). Tertiary industries can be funded through the town authorities, who will then decide on their own where to build that industry.

Only primary industries start as new random industries during the game.

Oilwells act like other primary industries, so they do not forcibly close down.

Overview generated by pts for OCS:

<graphviz>
digraph G {
graph [	fontname = "Helvetica-Oblique",
		fontsize = 12,
                label = "Industry Overview",
		size = "8,6" ];

node [	shape = polygon,
		sides = 4,
		distortion = "0.0",
		orientation = "0.0",
		skew = "0.0",
		color = white,
		style = filled,
		fontname = "Helvetica-Outline" ];

"Bank" [ color=green ];
"Coal mine" [ color=gold ];
"Copper ore mine" [ color=gold ];
"Diamond mine" [ color=gold ];
"Factory" [ color=cyan ];
"Farm" [ color=gold ];
"Food processing plant" [ color=cyan ];
"Fruit Plantation" [ color=gold ];
"Forest" [ color=gold ];
"Gold mine" [ color=gold ];
"Iron ore mine" [ color=gold ];
"Jewellery" [ color=cyan ];
"Metal foundry" [ color=cyan ];
"Oil refinery" [ color=cyan ];
"Oil wells" [ color=gold ];
"Paper mill" [ color=cyan ];
"Power station" [ color=green ];
"Shopping mall" [ color=green ];
"Town" [ color=orange ];
"Water supply" [ color=gold ];
"Water tower" [ color=green ];

"Bank" -> "Bank" [label="valuables"];
"Coal mine" -> "Metal foundry" [label="coal"];
"Coal mine" -> "Power station" [label="coal"];
"Copper ore mine" -> "Metal foundry" [label="copper ore"];
"Diamond mine" -> "Jewellery" [label="diamonds"];
"Factory" -> "Shopping mall" [label="goods"];
"Factory" -> "Town" [label="goods"];
"Farm" -> "Food processing plant" [label="grain"];
"Farm" -> "Food processing plant" [label="livestock"];
"Food processing plant" -> "Shopping mall" [label="food"];
"Food processing plant" -> "Town" [label="food"];
"Forest" -> "Paper mill" [label="wood"];
"Water supply" -> "Paper mill" [label="water"];
"Fruit Plantation" -> "Food processing plant" [label="fruit"];
"Gold mine" -> "Jewellery" [label="gold"];
"Iron ore mine" -> "Metal foundry" [label="iron ore"];
"Jewellery" -> "Bank" [label="valuables"];
"Jewellery" -> "Shopping mall" [label="valuables"];
"Metal foundry" -> "Factory" [label="metal"];
"Oil refinery" -> "Factory" [label="chemicals"];
"Oil wells" -> "Oil refinery" [label="oil"];
"Oil wells" -> "Power station" [label="oil"];
"Paper mill" -> "Bank" [label="paper"];
"Paper mill" -> "Factory" [label="paper"];
"Town" -> "Town" [label="passengers"];
"Town" -> "Town" [label="mail"];
"Water supply" -> "Power station" [label="water"];
"Water supply" -> "Water tower" [label="water"];
}
</graphviz>

Bank (#12)

Coal mine (#0)

Copper ore mine (#10)

Diamond mine (#17)

Factory (#6)

Farm (#9)

Food processing plant (#13)

Forest (#3)

Fruit plantation (#19)

Gold mine (#15)

Iron ore mine (#18)

Jewellery (#7)

Metal foundry (#8)

Oil refinery (#4)

Oil wells (#11)

Paper mill (#14)

Power station (#1)

Shopping mall (#30)

Town (#37)

Water supply (#21)

Water tower (#22)

There are 19 types of cargo:

Name Bit Number Cargo Label
Passengers 00 PASS
Coal 01 COAL
Mail 02 MAIL
Oil 03 OIL_
Livestock 04 LVST
Goods 05 GOOD
Grain 06 GRAI
Wood 07 WOOD
Iron Ore 08 IORE
Metals** 09 STEL*
Valuables 0A VALU
Paper 0B PAPR
Food 0C FOOD
Fruit 0D FRUT
Copper Ore 0E CORE
Water 0F WATR
Chemicals*** 10 RFPR
Diamonds 11 DIAM
Gold 12 GOLD

* For compatibility this is in Steel's cargo slot. ** Metals use the steel cargo graphics. *** Chemicals use the oil cargo graphics.

Toys do not provide any function other than to create an easy type of cargo to earn some money with by transporting it from a factory to a shopping mall, which can be invaluable while setting up a large distribution network. To lessen code impact, Toys and Rubber were scrapped.

Sample of Town Growth Challenge Cargo GRF working with Pikkabird's UKRS

Playable implementation of cargo and industries:

Required Programming Changes

The goal with these changes is to do them in modules, and try and make them as minimally invasive as possible. Module definitions so far:

Town classification

Display a classification for the town, depending on its size Could be done even for normal games?

a) "Community of {TOWN}"
b) "Village of {TOWN}"
c) "Township of {TOWN}"
d) "Town of {TOWN}"
e) "City of {TOWN}"
f) "Metropolis of {TOWN}"
g) "Capitol of {TOWN}"
if size < 300 display (a)
if size >= 300 && size < 600 display (b)
if size >= 600 && size < 1000 display (c)
if size >= 1000 && size < 3000 display (d)
if size >= 3000 && size < 6000 display (e)
if size >= 6000 && size < 15000 display (f)
if size >= 15000 display (g)

Town growth

Make growth of towns depend on the cargo delivered as described above.
Question:
Should this be made generic? allowing all cargos to potentially influence town growth, and setting demands through a newgrf interface? It would require some sort of newtown construction, with appropriate properties and callbacks.

Note: This module will bump the savegame version for TC, due to storing of delivered cargo last month and this month for each town.

cargo delivered is added to its slot in Town
at end of month, this data is saved in the corresponding cargo_last_month slots
compare cargo_last_month with demands defined by current town class. if sufficient -> town grows
when allowed, towns grow significantly faster than in vanilla ottd

Town gui

below normal cargo supply text, show amount of cargo delivered to this town last month. Highlight in red any amount that is insufficient for town growth. Highlight in yellow any amount that is sufficient for growth.
If made generic, entries should be automatically generated depending on the cargos that influence town growth

Town claiming

Changes to allow a company to claim a town.

Note: This module will bump the savegame version for TC, due to storing of cargo delivery and claimant ID for each town

Town logic

Add a claimant variable; current town claimant
Add an integer entry for each possible company: holds received amount of cargo
When a company exceeds the current claimants amount of received cargo, they become the new claimant

World gui

Create a translation table from company color to string color
print town name with string "{COLOR}{TOWN}", with parameter color: ColorTranslation(GetCompanyColor(Town->claimant))
Or add a company colour marker? What about a company-colored flag before town name?
draw company icon before town string

Advantage of this approach: works together with other town-string changing patches. Disadvantage: more code changes required.

Town gui

show company logo and name of claiming company

Town directory gui

show town names in claimed colors (and gray for unclaimed)

News ticker gui

add town claiming messages (with own category)

Add a category for Town claiming messages
Add string: "{TOWN} was claimed by {COMPANY}"
When town claimant changes, generate new message

Add claimed town status messages (same category as above) may need 2 categories: own town and opponent town
The message will only be displayed on growth, to reduce amount of bouncing messages, but can be shown multiple times, to void having to store message status.

Add string: "{TOWN} has grown to the status of Village!"  could introduce new variable {TOWNCLASS}
Add string: "{TOWN} has grown to the status of Township!"
Add string: "{TOWN} has grown to the status of Town!"
Add string: "{TOWN} has grown to the status of City!"
Add string: "{TOWN} has grown to the status of Metropolis!"
Add string: "{TOWN} has grown to the status of Capital!"
When town grows to new status, generate relevant message

Map gui

color claimed towns in company color in town view

Scoring

This module takes the changes from the previous modules and gives feedback to the players. Graphs for population, information about the goal, a screen to display when someone has won the challenge.

Note: This module will bump the savegame version for TC, due to storing of graph data.

World Logic

Player company gui

(new) goal gui

(new) population graph

(new) game win gui

Finish industries

In this final module, the last grf changes should be made for houses, and optionally the power station could be introduced (power station will bump savegame version, because amount of power needs to be stored for last month and this month).

Town authority gui

Korenn 09:58, 27 June 2009 (UTC)