Skip to content

Commit

Permalink
Copybara import of the project:
Browse files Browse the repository at this point in the history
--
d010a62 by Pragma <[email protected]>:

Modified setting of random seed for modules

COPYBARA_INTEGRATE_REVIEW=#101 from pragmaticTNT:main 8507f1a
PiperOrigin-RevId: 688535463
Change-Id: Id25cf807f48955dcccb394712a4dda7d1853af8e
  • Loading branch information
pragmaticTNT authored and copybara-github committed Oct 22, 2024
1 parent 1e98ce3 commit 5ede0bd
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion concordia/environment/game_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion concordia/environment/scenes/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion examples/modular/environment/modules/pre_state_villages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion examples/modular/environment/modules/vegbrooke_haggling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion examples/modular/environment/utils/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5ede0bd

Please sign in to comment.