-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update pub coordination and haggling scenarios.
also: - move most of substrate configuration into the sample_time_and_place - fix minor bugs PiperOrigin-RevId: 693430728 Change-Id: I7a53fae340f68fde6a372a4c297267ec20d84ddc
- Loading branch information
1 parent
f7b3c3f
commit b04c8a7
Showing
10 changed files
with
315 additions
and
149 deletions.
There are no files selected for viewing
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.
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
137 changes: 137 additions & 0 deletions
137
examples/modular/environment/modules/fruitville_haggling_gullible.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,137 @@ | ||
# 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. | ||
|
||
"""World configuration for the Fruitville haggling scenario.""" | ||
|
||
import random | ||
from examples.modular.environment import haggling | ||
|
||
YEAR = 1895 | ||
MONTH = 9 | ||
DAY = 12 | ||
|
||
FEMALE_NAMES = [ | ||
"Anya Blossomwood", | ||
"Brynn Orchardheart", | ||
"Clara Applebrook", | ||
"Della Plumstone", | ||
"Elara Berryvine", | ||
"Faye Honeydew", | ||
"Gaia Willowbrook", | ||
"Hazel Nutgrove", | ||
"Ivy Pearblossom", | ||
"Juniper Quincewood", | ||
"Kira Citronbloom", | ||
"Lila Figleaf", | ||
"Maeve Mulberry", | ||
"Nova Peachwood", | ||
"Opal Apricot", | ||
"Sasha Grapevine", | ||
"Quinn Cherryblossom", | ||
"Rowan Cranberry", | ||
"Sage Honeycomb", | ||
"Willow Blackberry", | ||
] | ||
|
||
MALE_NAMES = [ | ||
"Aiden Riversong", | ||
"Blaise Windwillow", | ||
"Cedric Meadowbrook", | ||
"Dorian Sunstone", | ||
"Elias Berryfield", | ||
"Flynn Honeycomb", | ||
"Garen Willowshade", | ||
"Hunter Nutwood", | ||
"Ivor Pearbrook", | ||
"Jasper Quincehill", | ||
"Kieran Citronbrook", | ||
"Lennon Figtree", | ||
"Magnus Mulberrylane", | ||
"Nolan Peachgrove", | ||
"Orion Apricotwood", | ||
"Peregrine Grapehill", | ||
"Quentin Cherrybrook", | ||
"Rowan Cranberryfield", | ||
"Silas Honeybrook", | ||
"Tristan Blackberrylane", | ||
] | ||
|
||
SCENARIO_PREMISE = ( | ||
"In the realm of Ouroboros, there is a quiet village of" | ||
" Fruitville, which is famous for its fruit market. Traders from" | ||
" all over the realm come to Fruitville to buy and sell produce." | ||
) | ||
|
||
VISUAL_SCENE_OPENINGS = [ | ||
( | ||
"The first rays of dawn painted the sky above Fruitville in hues of" | ||
" orange and gold, casting a warm glow over the bustling market. Stalls" | ||
" overflowed with vibrant fruits, their aromas mingling in the crisp" | ||
" morning air." | ||
), | ||
( | ||
"As the sun peeked over the horizon, the market of Fruitville stirred" | ||
" to life. Merchants, their voices a cheerful symphony, arranged their" | ||
" wares: glistening berries, plump melons, and exotic fruits from" | ||
" distant lands." | ||
), | ||
( | ||
"Dewdrops clung to the colorful fruits displayed in the market of" | ||
" Fruitville, reflecting the soft morning light. The air buzzed with" | ||
" anticipation as traders and customers alike gathered for the day's" | ||
" trade." | ||
), | ||
( | ||
"The cobblestone streets of Fruitville echoed with the clatter of" | ||
" hooves and the rumble of carts as the market awoke. Underneath" | ||
" colorful awnings, merchants proudly presented their bountiful" | ||
" harvests, their voices a chorus of greetings and bartering." | ||
), | ||
( | ||
"In the heart of Fruitville, the market square transformed into a" | ||
" kaleidoscope of colors as the sun rose. Fruits of every imaginable" | ||
" shape and size adorned the stalls, a feast for the eyes and a promise" | ||
" of delightful flavors." | ||
), | ||
] | ||
|
||
|
||
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) | ||
|
||
config = haggling.WorldConfig( | ||
year=YEAR, | ||
location="Fruitville", | ||
premise=SCENARIO_PREMISE, | ||
scene_visuals=VISUAL_SCENE_OPENINGS, | ||
random_seed=seed, | ||
num_supporting_players=1, | ||
num_main_players=1, | ||
num_games=3, | ||
buyer_base_reward_min=6, | ||
seller_base_reward_max=1, | ||
only_match_with_support=True, | ||
) | ||
all_names = list(MALE_NAMES) + list(FEMALE_NAMES) | ||
rng = random.Random(config.random_seed) | ||
rng.shuffle(all_names) | ||
config.people = all_names | ||
|
||
for _, name in enumerate(MALE_NAMES): | ||
config.person_data[name] = {"gender": "male"} | ||
for _, name in enumerate(FEMALE_NAMES): | ||
config.person_data[name] = {"gender": "female"} | ||
|
||
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
67 changes: 67 additions & 0 deletions
67
examples/modular/environment/modules/pub_coordination_london_follow.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,67 @@ | ||
# 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, | ||
num_main_players=2, | ||
num_supporting_players=4, | ||
num_games=5, | ||
) | ||
|
||
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"} | ||
|
||
return config |
Oops, something went wrong.