From 5ede0bd75c50f2a66072d2133eacefc6e4a6203a Mon Sep 17 00:00:00 2001 From: pragmaticTNT Date: Tue, 22 Oct 2024 07:06:19 -0700 Subject: [PATCH] Copybara import of the project: -- d010a62c97dc8ae915f4ebf86996eb74c75709cd by Pragma : Modified setting of random seed for modules COPYBARA_INTEGRATE_REVIEW=https://github.com/google-deepmind/concordia/pull/101 from pragmaticTNT:main 8507f1a33d032ff585f832c4d0a9ad6b647a45d8 PiperOrigin-RevId: 688535463 Change-Id: Id25cf807f48955dcccb394712a4dda7d1853af8e --- concordia/environment/game_master.py | 2 +- concordia/environment/scenes/conversation.py | 2 +- .../environment/modules/circa_2003_american_reality_show.py | 2 +- .../environment/modules/circa_2015_british_reality_show.py | 2 +- examples/modular/environment/modules/fruitville_haggling.py | 2 +- .../environment/modules/fruitville_haggling_multi_fruit.py | 2 +- examples/modular/environment/modules/garment_factory_labor.py | 2 +- examples/modular/environment/modules/pre_state_villages.py | 2 +- .../modular/environment/modules/pub_coordination_capetown.py | 2 +- examples/modular/environment/modules/pub_coordination_london.py | 2 +- examples/modular/environment/modules/vegbrooke_haggling.py | 2 +- .../environment/modules/vegbrooke_haggling_multi_fruit.py | 2 +- .../modules/wild_west_railroad_construction_labor.py | 2 +- examples/modular/environment/utils/helper_functions.py | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/concordia/environment/game_master.py b/concordia/environment/game_master.py index 3833c9cf..6d8a79b4 100644 --- a/concordia/environment/game_master.py +++ b/concordia/environment/game_master.py @@ -134,7 +134,7 @@ def __init__( self._randomise_initiative = randomise_initiative self._player_observes_event = player_observes_event self._players_act_simultaneously = players_act_simultaneously - self._seed = seed or random.getrandbits(63) + self._seed = seed if seed is not None else random.getrandbits(63) self._rng = random.Random(seed) if isinstance(action_spec, agent_lib.ActionSpec): diff --git a/concordia/environment/scenes/conversation.py b/concordia/environment/scenes/conversation.py index eca0302d..0c471466 100644 --- a/concordia/environment/scenes/conversation.py +++ b/concordia/environment/scenes/conversation.py @@ -77,7 +77,7 @@ def __init__( self._key_question = key_question self._max_steps = max_steps self._current_steps = 0 - self._seed = seed or random.getrandbits(63) + self._seed = seed if seed is not None else random.getrandbits(63) self._verbose = verbose def name(self) -> str: diff --git a/examples/modular/environment/modules/circa_2003_american_reality_show.py b/examples/modular/environment/modules/circa_2003_american_reality_show.py index 22c9795b..36d2d65c 100644 --- a/examples/modular/environment/modules/circa_2003_american_reality_show.py +++ b/examples/modular/environment/modules/circa_2003_american_reality_show.py @@ -733,7 +733,7 @@ def sample_parameters( seed: int | None = None, ) -> reality_show.WorldConfig: """Sample parameters of the setting and the backstory for each player.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) rng = random.Random(seed) shuffled_male_names = list(rng.sample(MALE_NAMES, len(MALE_NAMES))) shuffled_female_names = list(rng.sample(FEMALE_NAMES, len(FEMALE_NAMES))) diff --git a/examples/modular/environment/modules/circa_2015_british_reality_show.py b/examples/modular/environment/modules/circa_2015_british_reality_show.py index 8761d717..b8047021 100644 --- a/examples/modular/environment/modules/circa_2015_british_reality_show.py +++ b/examples/modular/environment/modules/circa_2015_british_reality_show.py @@ -470,7 +470,7 @@ def sample_parameters( seed: int | None = None, ) -> reality_show.WorldConfig: """Sample parameters of the setting and the backstory for each player.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) rng = random.Random(seed) shuffled_male_names = list(rng.sample(MALE_NAMES, len(MALE_NAMES))) diff --git a/examples/modular/environment/modules/fruitville_haggling.py b/examples/modular/environment/modules/fruitville_haggling.py index 7a62de14..23038806 100644 --- a/examples/modular/environment/modules/fruitville_haggling.py +++ b/examples/modular/environment/modules/fruitville_haggling.py @@ -109,7 +109,7 @@ def sample_parameters(seed: int | None = None): """Samples a set of parameters for the world configuration.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) config = haggling.WorldConfig( year=YEAR, diff --git a/examples/modular/environment/modules/fruitville_haggling_multi_fruit.py b/examples/modular/environment/modules/fruitville_haggling_multi_fruit.py index f8af8b7e..ab6caf43 100644 --- a/examples/modular/environment/modules/fruitville_haggling_multi_fruit.py +++ b/examples/modular/environment/modules/fruitville_haggling_multi_fruit.py @@ -109,7 +109,7 @@ def sample_parameters(seed: int | None = None): """Samples a set of parameters for the world configuration.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) config = haggling_multi_item.WorldConfig( year=YEAR, diff --git a/examples/modular/environment/modules/garment_factory_labor.py b/examples/modular/environment/modules/garment_factory_labor.py index fec17b65..ae541346 100644 --- a/examples/modular/environment/modules/garment_factory_labor.py +++ b/examples/modular/environment/modules/garment_factory_labor.py @@ -964,7 +964,7 @@ def sample_parameters( seed: int | None = None, ): """Sample parameters of the setting and the backstory for each player.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) rng = random.Random(seed) poor_work_conditions = tuple( rng.sample( diff --git a/examples/modular/environment/modules/pre_state_villages.py b/examples/modular/environment/modules/pre_state_villages.py index 9371ee3d..519e215e 100644 --- a/examples/modular/environment/modules/pre_state_villages.py +++ b/examples/modular/environment/modules/pre_state_villages.py @@ -1794,7 +1794,7 @@ def sample_parameters( seed: int | None = None, ): """Returns a config dict for the simulation.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) rng = random.Random(seed) shuffled_village_names = list( rng.sample(VILLAGE_NAMES, len(VILLAGE_NAMES)) diff --git a/examples/modular/environment/modules/pub_coordination_capetown.py b/examples/modular/environment/modules/pub_coordination_capetown.py index 290e1074..33dffd37 100644 --- a/examples/modular/environment/modules/pub_coordination_capetown.py +++ b/examples/modular/environment/modules/pub_coordination_capetown.py @@ -199,7 +199,7 @@ def sample_parameters(seed: int | None = None): """Samples a set of parameters for the world configuration.""" pubs = random.sample(list(PUB_PREFERENCES.keys()), NUM_PUBS) pub_preferences = {k: PUB_PREFERENCES[k] for k in pubs} - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) config = pub_coordination.WorldConfig( year=YEAR, diff --git a/examples/modular/environment/modules/pub_coordination_london.py b/examples/modular/environment/modules/pub_coordination_london.py index 8341b1f8..e5e0682d 100644 --- a/examples/modular/environment/modules/pub_coordination_london.py +++ b/examples/modular/environment/modules/pub_coordination_london.py @@ -282,7 +282,7 @@ def sample_parameters(seed: int | None = None): """Samples a set of parameters for the world configuration.""" pubs = random.sample(list(PUB_PREFERENCES.keys()), NUM_PUBS) pub_preferences = {k: PUB_PREFERENCES[k] for k in pubs} - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) config = pub_coordination.WorldConfig( year=YEAR, diff --git a/examples/modular/environment/modules/vegbrooke_haggling.py b/examples/modular/environment/modules/vegbrooke_haggling.py index d3415845..b591b21b 100644 --- a/examples/modular/environment/modules/vegbrooke_haggling.py +++ b/examples/modular/environment/modules/vegbrooke_haggling.py @@ -109,7 +109,7 @@ def sample_parameters(seed: int | None = None): """Samples a set of parameters for the world configuration.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) config = haggling.WorldConfig( year=YEAR, diff --git a/examples/modular/environment/modules/vegbrooke_haggling_multi_fruit.py b/examples/modular/environment/modules/vegbrooke_haggling_multi_fruit.py index 7f205487..b81a864a 100644 --- a/examples/modular/environment/modules/vegbrooke_haggling_multi_fruit.py +++ b/examples/modular/environment/modules/vegbrooke_haggling_multi_fruit.py @@ -109,7 +109,7 @@ def sample_parameters(seed: int | None = None): """Samples a set of parameters for the world configuration.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) config = haggling_multi_item.WorldConfig( year=YEAR, diff --git a/examples/modular/environment/modules/wild_west_railroad_construction_labor.py b/examples/modular/environment/modules/wild_west_railroad_construction_labor.py index d508b167..0da3fa57 100644 --- a/examples/modular/environment/modules/wild_west_railroad_construction_labor.py +++ b/examples/modular/environment/modules/wild_west_railroad_construction_labor.py @@ -1145,7 +1145,7 @@ def sample_parameters( seed: int | None = None, ): """Sample parameters of the setting and the backstory for each player.""" - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) rng = random.Random(seed) nearby_town = rng.choice(TOWN_NAMES) poor_work_conditions = tuple( diff --git a/examples/modular/environment/utils/helper_functions.py b/examples/modular/environment/utils/helper_functions.py index c8df52aa..2fde5a84 100644 --- a/examples/modular/environment/utils/helper_functions.py +++ b/examples/modular/environment/utils/helper_functions.py @@ -46,7 +46,7 @@ def load_time_and_place_module( like the names of individual characters, which must be resampled for each run of the simulation. """ - seed = seed or random.getrandbits(63) + seed = seed if seed is not None else random.getrandbits(63) rng = random.Random(seed) if time_and_place_module is None: time_and_place_module = rng.choice(default_time_and_place_modules)