Empty homes draw settlers: growth follows housing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-19 20:31:25 +01:00
parent 0b7e4a722f
commit 8fbab37a56
3 changed files with 33 additions and 7 deletions

View file

@ -302,11 +302,26 @@ class CityTest(unittest.TestCase):
world = world_with()
city = world["city"]
city["stockpile"] = {"bread": 5}
city["population"] = 25.0 # a full town, so nobody new arrives
world["next_fortune_at"] = None # no lucky wagon of bread
game.tick(world, T0 + 4 * game.DAY, random.Random(1))
self.assertTrue(city["starving"])
self.assertNotIn("bread", city["stockpile"])
self.assertLess(city["population"], 20)
self.assertLess(city["population"], 25)
def test_empty_homes_draw_settlers(self):
world = world_with()
city = world["city"]
city["population"] = 22.0
city["buildings"]["houses"]["level"] = 2
city["stockpile"] = {"bread": 10_000}
self.assertAlmostEqual(game.growth_per_day(world), 0.25 * 65 + 0.05 * 22)
for _hour in range(24):
game._city_hour(world, T0)
self.assertGreater(city["population"], 38)
for _hour in range(48):
game._city_hour(world, T0)
self.assertEqual(city["population"], 65)
def test_fed_city_grows_to_housing_and_pays_tax(self):
world = world_with()
@ -899,8 +914,9 @@ class ConstructionTest(unittest.TestCase):
def test_townsfolk_trickle_and_levels_help(self):
world = self.site()
world["city"]["population"] = 25.0 # houses full, so the workforce stays put
game.tick(world, T0 + 10 * game.HOUR, random.Random(1))
self.assertAlmostEqual(world["city"]["construction"]["labour"], 10 * 20 * game.TOWNSFOLK_LABOUR, delta=5)
self.assertAlmostEqual(world["city"]["construction"]["labour"], 10 * 25 * game.TOWNSFOLK_LABOUR, delta=5)
p = world["players"]["bob"]
self.assertEqual(game.labour_per_action(p), 1)
p["xp"]["construction"] = game.XP_TABLE[40]