Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First patient takes too long to appear #649

Open
Andy51 opened this issue Jan 31, 2015 · 14 comments · May be fixed by #1986
Open

First patient takes too long to appear #649

Andy51 opened this issue Jan 31, 2015 · 14 comments · May be fixed by #1986

Comments

@Andy51
Copy link
Contributor

Andy51 commented Jan 31, 2015

What steps will reproduce the problem?

  1. Start a new game
  2. Open the hospital right away (green timer button) at 1st of Jan
  3. Build a reception

What is the expected output? What do you see instead?
In the original TH the first patient would come to the hospital around 11th of Jan
In CorsixTH it may take forever for the first patient to appear. Initially I thought the game was broken as no one was coming for two months.

I have comapred the date when the first patient appears in the lower left corner as shown on the screenshot (this is the furthest spot i can obsrerve in the original)

screenshot3

Original:
12 Jan; 11 Jan; 11 Jan; 11 Jan
CorsixTH:
21 Jan; 2 Feb; 8 Mar; 8 Feb; 28 Jan

What version of CorsixTH are you using (e.g. "0.30", "4c66e39985")?
9cc1254

What operating system / compile settings are you using?
Win7 x64, buit with MSVC2013CE, SDL 2.0.3, SDL_mixer 2.0.0, Lua 5.1.5, all defaults

What level was this on (e.g. "Demo level", "Full game level 12")?
Full level 1

@ghost
Copy link

ghost commented Jul 26, 2015

I could confirm that the first patient in TH is coming shortly after opening the hospital. In CorsixTH it takes much to long.

@MarkL1961
Copy link
Contributor

How long it takes for the first patient to arrive can depend on where on the map they spawn as some points are further away from the entrance than others

@Alberth289346
Copy link
Contributor

Perhaps spawn the first patients preferably closer to the entrance?

@MarkL1961
Copy link
Contributor

Sounds good to me

@TheCycoONE
Copy link
Member

Is it just the spawn that causes this, because it's months later than in the original on the first campaign level. If someone can verify side by side? (If not then eventually I will)

@Lego3
Copy link
Contributor

Lego3 commented Sep 8, 2015

One idea I had just now is that maybe the spawn rate is so low in the beginning that sometimes the number of patients for that month is simply 0? As it has a certain amount of randomness in it. Maybe we should have some kind of lower limit, like at least one patient per month, or that the likelihood of at east one patient increases for each "0" month?

@TheCycoONE
Copy link
Member

It is consistent that the patient enters the hospital a lot later in CorsixTH than Theme Hospital at the start of level 1. I don't think that comes down to a random 0 spawn.

@mugmuggy
Copy link
Contributor

mugmuggy commented Jan 9, 2018

CorsixTH spawns on edge of map, whereas the original as the view is limited, spawns much closer to the entry of the hospital. The original allows for up to 4 spawn points on each level (for each player in multiplayer) from what I can ascertain and there is a handful of levels where there is more than 1 spawn point.

Here this screen shot is the original level file altered to allow more camera movement, capturing the position of the spawn point for level 1 - this patient just spawned. The lamps are the ones that are just visible in bottom left corner of the earlier screen capture in this issue, this was a subsequent spawn and not the first, but they all use the same point.
image

The spawn date, is also controlled differently than in the original, and this probably has some affect also. How Corsix calculates the dates of a spawn is slightly flawed. World:updateSpawnDates uses math.n_random, which can produce very low (negated with ceil) and even negative numbers. When its negative, ceil doesn't help, as that will move the first spawn to the next month.

  local no_of_spawns = math.n_random(self.spawn_rate, 2)
  -- Use ceil so that at least one patient arrives (unless population = 0)
  no_of_spawns = math.ceil(no_of_spawns*self:getLocalPlayerHospital().population)
  self.spawn_dates = {}
  for _ = 1, no_of_spawns do
    local day = math.random(1, month_length[self.month % 12 + 1])
    self.spawn_dates[day] = self.spawn_dates[day] and self.spawn_dates[day] + 1 or 1

Then if it does get a count 1 or greater, when it randomly chooses the date for that spawn, it could be the end of the month, leaving the patient arriving well into the next month. This combined with a -ve no_of_spawns initially leads to first patient potentially much later, like in March. Corsix uses the population allocation factor (default 0.25) where as whilst the game month is less than gbv.AllocDelay, the original would round robin

The original more evenly spreads the spawn dates around, at least for local player, as it occurs when 2 conditions are met and its located closer to the hospital entry so is more predictable also, I'm still finalising that analysis.

The other spawn issue, which isn't yet an issue as much is when gbv.AllocDelay has passed and it becomes reputation based. To ensure the ai hospitals stay active and potential for the player to recover, I assume, gbv.AllocRand starts to be used. When it is used, it will randomly - given by random() % gbv.AllocRand == 0) - choose a random hospital given by random() % hospitalcount - 0 being local player.

@mugmuggy
Copy link
Contributor

I've also found the spawn_rate calculation to be off. When the popn.Change value takes affect is at the end of that index month, not the end of the next month.

#popn[0].Month.Change		0		3
#popn[1].Month.Change		1		1

With the above example, start of level, 3 spawns will occur in Jan, at the end of month processing for Jan, the calculation currently takes the '1' value and adds to 3 totalling 4 spawns in Feb, when it should take the '0' value again, and have a total of 6 spawns for Feb, then when end of month for Feb, comes in, add 1 for 7 total spawns in Mar.

The original TH has potentially less spawns in Feb, as the spawn interval is calculated from a static 30 days - 1500 ticks, and there is only 1400 in Feb and likewise on the 31 day months, 1550, you can get extra spawns in depending on the calculations.

@mugmuggy mugmuggy linked a pull request Jul 1, 2021 that will close this issue
@Alberth289346
Copy link
Contributor

Another point is that a patient spawned when the hospital is still closed is discarded. At low rates of spawning it may take a long time before the next spawn. One trick could be to move the arrival to the next day in that case, so a patient will be spawned close after a player opened the hospital.

@Alberth289346
Copy link
Contributor

A simpler solution is to spawn a patient the first day that a hospital is open.

Technically we should then also remove a planned patient. We could do that immediately or the next month or so, although I am not sure it's worth the trouble.

@lewri
Copy link
Member

lewri commented Feb 14, 2024

A simpler solution is to spawn a patient the first day that a hospital is open.

Technically we should then also remove a planned patient. We could do that immediately or the next month or so, although I am not sure it's worth the trouble.

Probably not worth the trouble. Just pop a patient on open.

@Alberth289346
Copy link
Contributor

  • Re-reading this topic, I found a nice other direction in the comment by MugMuggy above ( First patient takes too long to appear #649 (comment) ):

    CorsixTH spawns on edge of map, whereas the original as the view is limited, spawns much closer to the entry of the hospital ...
    ... this patient just spawned. The lamps [in the picture of the comment] are the ones that are just visible in bottom left corner of the earlier screen capture in this issue ...

    So this raises the question I think: "What is the value of being able to see as many of the tiles as possible?". Not sure that will help much, as our screens are much bigger nowadays so we may need more space around the hospital to make everything viewable.

  • What is wrong with arriving patients earlier. Sure, the original didn't do this, but we've always added useful features to the program to improve on the user experience, so why not here?

  • Spawn rate in the first level is awful, can that be changed (as an improvement feature to the game)? Might be somewhat tricky, new users may get overwhelmed.

@Alberth289346
Copy link
Contributor

  • Mugmuggy also found our spawn rate computation to be off above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants