News:

SimuTranslator
Make Simutrans speak your language.

Chance parameter for city attractions

Started by Combuijs, December 05, 2010, 01:01:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Combuijs

Can anybody tell me how exactly the chance parameter works for city attractions?

Say an attraction has building time = 1000 and chance = 30, I was under the impression that at the moment that the number of inhabitants gets greater than 1000 there is a 30% chance that the attraction is built. But I've seen (in 102.2.2) that the attraction is usually built later.

And what happens if you have 3 city attractions:
A: building time = 1000, chance = 30
B: building time = 1000, chance = 30
C: building time = 1000, chance = 40

If it's too difficult to explain, perhaps a developer can point me to the right place in the source code?

Dwachs

Quote from: Combuijs on December 05, 2010, 01:01:11 PM
Say an attraction has building time = 1000 and chance = 30, I was under the impression that at the moment that the number of inhabitants gets greater than 1000 there is a 30% chance that the attraction is built. But I've seen (in 102.2.2) that the attraction is usually built later.
Imho the building is built with a 30% chance if the city has exaclty 1000 inhabitants: However, these number of inhabitants is an internal counter, which is not displayed, which only increases over time.
Quote
And what happens if you have 3 city attractions:
A: building time = 1000, chance = 30
B: building time = 1000, chance = 30
C: building time = 1000, chance = 40

If it's too difficult to explain, perhaps a developer can point me to the right place in the source code?
At first one of these building is chosen randomly based on the chance, then another random test is done to built the building according to its chance.

You can find everything in simcity.cc. The internal counter is stadt_t::bev, the routine to build is stadt_t::check_bau_spezial, the selection of buildings happens in bauer/hausbauer.cc routine hausbauer_t::get_special.

Combuijs

Thanks for your explanation and code directions, Dwachs. I understand now how it works.

The internal counter might indeed be different than the shown population, which explains why sometimes the attraction is built later.

I have always thought that in the case of the 3 city attractions always one was chosen, with 30% chance of building A or B and 40% chance of building C. But that's clearly not the case. In fact it is 9% for building A or B, 16% of building C and 75% of building nothing at all.