From 962e48c0783f6c27ad5dce51baa79b08df1529f3 Mon Sep 17 00:00:00 2001 From: Doug Hoskisson Date: Tue, 1 Nov 2022 06:45:17 -0700 Subject: [PATCH] Zillion: fix unreproducible seeds (#1166) * fix zillion unreproducible seeds * world to multiworld merge --- test/worlds/test_base.py | 2 +- test/worlds/zillion/TestReproducibleRandom.py | 29 +++++++++++++++++++ worlds/zillion/__init__.py | 1 + worlds/zillion/requirements.txt | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 test/worlds/zillion/TestReproducibleRandom.py diff --git a/test/worlds/test_base.py b/test/worlds/test_base.py index 22e92c6f..82c3d167 100644 --- a/test/worlds/test_base.py +++ b/test/worlds/test_base.py @@ -9,7 +9,7 @@ from worlds.AutoWorld import call_all class WorldTestBase(unittest.TestCase): options: typing.Dict[str, typing.Any] = {} - world: MultiWorld + multiworld: MultiWorld game: typing.ClassVar[str] # define game name in subclass, example "Secret of Evermore" auto_construct: typing.ClassVar[bool] = True diff --git a/test/worlds/zillion/TestReproducibleRandom.py b/test/worlds/zillion/TestReproducibleRandom.py new file mode 100644 index 00000000..707f2635 --- /dev/null +++ b/test/worlds/zillion/TestReproducibleRandom.py @@ -0,0 +1,29 @@ +from typing import cast +from test.worlds.zillion import ZillionTestBase + +from worlds.zillion import ZillionWorld + + +class SeedTest(ZillionTestBase): + auto_construct = False + + def test_reproduce_seed(self) -> None: + self.world_setup(42) + z_world = cast(ZillionWorld, self.multiworld.worlds[1]) + r = z_world.zz_system.randomizer + assert r + randomized_requirements_first = tuple( + location.req.gun + for location in r.locations.values() + ) + + self.world_setup(42) + z_world = cast(ZillionWorld, self.multiworld.worlds[1]) + r = z_world.zz_system.randomizer + assert r + randomized_requirements_second = tuple( + location.req.gun + for location in r.locations.values() + ) + + assert randomized_requirements_first == randomized_requirements_second diff --git a/worlds/zillion/__init__.py b/worlds/zillion/__init__.py index 91e19c6c..0b9b0e51 100644 --- a/worlds/zillion/__init__.py +++ b/worlds/zillion/__init__.py @@ -133,6 +133,7 @@ class ZillionWorld(World): self.zz_system.make_patcher(rom_dir_name) self.zz_system.make_randomizer(zz_op) + self.zz_system.seed(self.multiworld.seed) self.zz_system.make_map() # just in case the options changed anything (I don't think they do) diff --git a/worlds/zillion/requirements.txt b/worlds/zillion/requirements.txt index 62f66899..c0cd15a1 100644 --- a/worlds/zillion/requirements.txt +++ b/worlds/zillion/requirements.txt @@ -1 +1 @@ -git+https://github.com/beauxq/zilliandomizer@c97298ecb1bca58c3dd3376a1e1609fad53788cf#egg=zilliandomizer==0.4.5 +git+https://github.com/beauxq/zilliandomizer@10549a126b3293595ddb6816b896c1f88ce344c5#egg=zilliandomizer==0.4.6