-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move pub closure probability and friendship matrix to time and place …
…module into the time and place module. PiperOrigin-RevId: 696472872 Change-Id: Ia4e940afe7a906350592abf80bb05341f9df2e6c
- Loading branch information
1 parent
bfde374
commit ad79494
Showing
6 changed files
with
93 additions
and
152 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
examples/modular/environment/modules/pub_coordination_london_closures.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2024 DeepMind Technologies Limited. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""A set of pub names and reasons to like them.""" | ||
|
||
import random | ||
from examples.modular.environment import pub_coordination | ||
from examples.modular.environment.modules import pub_coordination_london | ||
|
||
YEAR = pub_coordination_london.YEAR | ||
MONTH = pub_coordination_london.MONTH | ||
DAY = pub_coordination_london.DAY | ||
|
||
NUM_PUBS = pub_coordination_london.NUM_PUBS | ||
|
||
|
||
def sample_parameters(seed: int | None = None): | ||
"""Samples a set of parameters for the world configuration.""" | ||
seed = seed if seed is not None else random.getrandbits(63) | ||
rng = random.Random(seed) | ||
|
||
pubs = rng.sample( | ||
list(pub_coordination_london.PUB_PREFERENCES.keys()), | ||
pub_coordination_london.NUM_PUBS, | ||
) | ||
pub_preferences = { | ||
k: pub_coordination_london.PUB_PREFERENCES[k] for k in pubs | ||
} | ||
|
||
config = pub_coordination.WorldConfig( | ||
year=pub_coordination_london.YEAR, | ||
location="London", | ||
event="European football cup", | ||
game_countries=pub_coordination_london.EURO_CUP_COUNTRIES, | ||
venues=pubs, | ||
venue_preferences=pub_preferences, | ||
social_context=pub_coordination_london.SOCIAL_CONTEXT, | ||
random_seed=seed, | ||
pub_closed_probability=0.7 | ||
) | ||
|
||
all_names = list(pub_coordination_london.MALE_NAMES) + list( | ||
pub_coordination_london.FEMALE_NAMES | ||
) | ||
|
||
rng.shuffle(all_names) | ||
config.people = all_names | ||
|
||
for _, name in enumerate(pub_coordination_london.MALE_NAMES): | ||
config.person_data[name] = {"gender": "male"} | ||
for _, name in enumerate(pub_coordination_london.FEMALE_NAMES): | ||
config.person_data[name] = {"gender": "female"} | ||
config.player_who_knows_closed_pub = all_names[0] | ||
|
||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
examples/modular/environment/pub_coordination_closures_friendships.py
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
examples/modular/environment/pub_coordination_friendships.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters