MineColonies

MineColonies

57M Downloads

Happiness: unable to stabilize 'number of houses' factor

winex opened this issue · 20 comments

commented

Minecolonies version

minecolonies-1.12.2-0.9.18-ALPHA-universal.jar

Expected behavior

  • "Number of houses" is stable (yellow dot) when there are no homeless citizens

Actual behaviour

  • "Number of houses" can't be stable (yellow dot) because of #2508, no GUI for managing livings in TownHall.

Steps to reproduce the problem

  1. build townHall and at least 3 citizen huts
  2. do nothing, build nothing, only watch happiness stats
  3. ...
  4. number of houses will never be stable
  5. no profit, no fun :(

this blocks Happiness to be stable, as there are always N [=TH-level] homeless citizens, even in automatic assignment mode (should i fix this one first?).

as TownHall is now also a Citizen's Hut after #2130, it's GUI should have and allow to assign citizens.
probably even inventory button should be added because of dumping logic and w/e else.

i'm not the GUI guy, so i need some discussion where it should be placed. thanks.

commented

oh, auto-assigning works. after checking in colony1.nbt i see resident in TH, but i re-launched the game so i don't know if happiness will update w/o restarts. let's test again

commented

btw, is happiness updated at each tick here?

citizenManager.checkCitizensForHappiness();

shouldn't it be like && shallUpdate(world, CLEANUP_TICK_INCREMENT) as in above code?

commented

Definitely, it should not update each tick, if I get it correctly it gets updated when daytime turns into nighttime. Maybe we can add another check to the else brackets so it gets updated two times per day cycle

commented
commented

should be some helpers funcs like atDayStart(world) and atDayEnd(world) to cleanup this?

btw, waited 2 days, looks like it needs restart/reload to update in auto-housing mode, something is wrong somewhere else. i'm searching...

commented

@Raycoms yeah, you mean #2600, but i can find no code yet, so i'm just trying to fix little things i worried about

commented

also, i see lag here:

if (getAssignedCitizen().size() < getMaxInhabitants() && getColony() != null && !getColony().isManualHousing())

this stuff shouldn't be run each tick
in auto-housing mode, more homeless citizens = more lag

should i add this, so it will run only once per second for ex.?
world = event.getWorld() + check for null, etc
if ( (world.getTicks() % TICKS_SECOND == 0) && ...

commented
commented

@Raycoms sorry, can you point me to an example of mentioned randomizer, so i could track such possible lag issues and try to fix them? thanks.

commented
commented

for now, i found that only Home and Baker (he checks furnaces every tick)
i propose new constant to manage such cases and usage of Colony.shallUpdate() in such cases
ONWORLD_TICK_INCREMENT = TICKS_SECOND * 1;
is it ok?
/me is working on PR...

commented
commented

I wouldn't worry to much about happiness, because in the new happiness system. It has been completely rewritten.

happiness is updated based on once a day and event driven. The colony and citizens are updated once a day to figure out things that effect citizen and colony long term. Once a day events are like effect of citizen death on the colony long term, citizen without a house long term effect, no job long term and etc.... Event driven are things like the citizen gets hurt and such..

commented

damn, Baker isn't inherited from AbstractBuildingFurnaceUser... someone forgot to use that :(
btw, i thought ONWORLD_TICK_AVERAGE name is better

so, let's try how PR works :)

commented
commented

i've found that GUI is not updated probably because of:

so, it seems to be a client-side GUI/connection bug...

commented

FYI, The new happiness citizen will be ready for check in with in the week. Each citizen has their own happiness data and their gui reflects that. Many of these areas have been deleted or rewritten to handle the new system. I would hold off until the new system is checked in.

I'm in the middle of testing to make sure all the modifiers seem fair and doesn't make the game to easy or to hard.

commented

@bob0bob oh ok, i just didn't know that the code is almost done. thanks man!

commented

@Raycoms, maybe we just should add citizenManager.markCitizensDirty() after these lines?

if (!packageManager.getSubscribers().isEmpty())
{
citizenManager.checkCitizensForHappiness();
}

so at the end of each day at least citizen's data would be sync'ed to clients? if i'm right about this flag.

i'm currently testing singleplayer and noticed some of the stuff is correctly working (server-side i mean), but it's not updated in GUI

commented

We reworked the happiness, that should do it now.