Skip to content
Snippets Groups Projects
Commit 080bf359 authored by Florian Schröder's avatar Florian Schröder
Browse files

Remove level specific config and item info files

This commit removes the level specific configuration and item information files for 'level1' and 'level2' under the cooperative_cuisine project. Changes have been made to consolidate the configurations into a single file, which improves the maintainability and organization of the application.
parent 0ddb9e04
No related branches found
No related tags found
1 merge request!78Resolve "Adapt/Overwrite env config attr in Study config"
Pipeline #48293 passed
......@@ -7,7 +7,7 @@ plates:
game:
time_limit_seconds: 300
undo_dispenser_pickup: true
validate_recipes: false
validate_recipes: true
layout_chars:
......@@ -84,7 +84,7 @@ orders:
player_config:
radius: 0.4
speed_units_per_seconds: 10
speed_units_per_seconds: 6
interaction_range: 1.6
restricted_view: False
view_angle: 70
......
plates:
clean_plates: 2
dirty_plates: 0
plate_delay: [ 5, 10 ]
# range of seconds until the dirty plate arrives.
return_dirty: true
game:
time_limit_seconds: 300
undo_dispenser_pickup: true
validate_recipes: false
layout_chars:
_: Free
hash: Counter # #
A: Agent
pipe: Extinguisher
P: PlateDispenser
C: CuttingBoard
X: Trashcan
$: ServingWindow
S: Sink
+: SinkAddon
at: Plate # @ just a clean plate on a counter
U: Pot # with Stove
Q: Pan # with Stove
O: Peel # with Oven
F: Basket # with DeepFryer
T: Tomato
N: Onion # oNioN
L: Lettuce
K: Potato # Kartoffel
I: Fish # fIIIsh
D: Dough
E: Cheese # chEEEse
G: Sausage # sausaGe
B: Bun
M: Meat
question: Counter # ? mushroom
: Counter
^: Counter
right: Counter
left: Counter
wave: Free # ~ Water
minus: Free # - Ice
dquote: Counter # " wall/truck
p: Counter # second plate return ??
orders:
meals:
all: false
# if all: false -> only orders for these meals are generated
# TODO: what if this list is empty?
list:
- TomatoSoup
- Salad
order_gen_class: !!python/name:cooperative_cuisine.orders.RandomOrderGeneration ''
# the class to that receives the kwargs. Should be a child class of OrderGeneration in orders.py
order_gen_kwargs:
order_duration_random_func:
# how long should the orders be alive
# 'random' library call with getattr, kwargs are passed to the function
func: uniform
kwargs:
a: 40
b: 60
max_orders: 6
# maximum number of active orders at the same time
num_start_meals: 2
# number of orders generated at the start of the environment
sample_on_dur_random_func:
# 'random' library call with getattr, kwargs are passed to the function
func: uniform
kwargs:
a: 10
b: 20
sample_on_serving: false
# Sample the delay for the next order only after a meal was served.
serving_not_ordered_meals: true
# can meals that are not ordered be served / dropped on the serving window
player_config:
radius: 0.4
speed_units_per_seconds: 6
interaction_range: 1.6
restricted_view: False
view_angle: 70
view_range: 4 # in grid units, can be "null"
effect_manager:
FireManager:
class: !!python/name:cooperative_cuisine.effects.FireEffectManager ''
kwargs:
spreading_duration: [ 5, 10 ]
fire_burns_ingredients_and_meals: true
extra_setup_functions:
# # --------------- Scoring ---------------
orders:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ completed_order ]
callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks ''
callback_class_kwargs:
static_score: 20
score_on_specific_kwarg: meal_name
score_map:
Burger: 15
OnionSoup: 10
Salad: 5
TomatoSoup: 10
not_ordered_meals:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ serve_not_ordered_meal ]
callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks ''
callback_class_kwargs:
static_score: 2
trashcan_usages:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ trashcan_usage ]
callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks ''
callback_class_kwargs:
static_score: -5
expired_orders:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ order_expired ]
callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks ''
callback_class_kwargs:
static_score: -10
# # --------------- Recording ---------------
# json_states:
# func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
# kwargs:
# hooks: [ json_state ]
# callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
# callback_class_kwargs:
# log_path: USER_LOG_DIR/ENV_NAME/json_states.jsonl
# Game event recording
game_events:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks:
- post_counter_pick_up
- post_counter_drop_off
- post_dispenser_pick_up
- cutting_board_100
- player_start_interaction
- player_end_interact
- post_serving
- no_serving
- dirty_plate_arrives
- trashcan_usage
- plate_cleaned
- added_plate_to_sink
- drop_on_sink_addon
- pick_up_from_sink_addon
- serve_not_ordered_meal
- serve_without_plate
- completed_order
- new_orders
- order_expired
- action_on_not_reachable_counter
- new_fire
- fire_spreading
- drop_off_on_cooking_equipment
- players_collide
- post_plate_dispenser_pick_up
- post_plate_dispenser_drop_off
- on_item_transition
- progress_started
- progress_finished
- content_ready
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs:
log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
add_hook_ref: true
actions:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ pre_perform_action ]
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs:
log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
random_env_events:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ order_duration_sample, plate_out_of_kitchen_time ]
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs:
log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
add_hook_ref: true
env_configs:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ env_initialized, item_info_config ]
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs:
log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
add_hook_ref: true
# info_msg:
# func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
# kwargs:
# hooks: [ cutting_board_100 ]
# log_class: !!python/name:cooperative_cuisine.info_msg.InfoMsgManager ''
# log_class_kwargs:
# msg: Glückwunsch du hast was geschnitten!
# fire_msg:
# func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
# kwargs:
# hooks: [ new_fire ]
# log_class: !!python/name:cooperative_cuisine.info_msg.InfoMsgManager ''
# log_class_kwargs:
# msg: Feuer, Feuer, Feuer
# level: Warning
CuttingBoard:
type: Equipment
Sink:
type: Equipment
Stove:
type: Equipment
DeepFryer:
type: Equipment
Oven:
type: Equipment
Pot:
type: Equipment
equipment: Stove
Pan:
type: Equipment
equipment: Stove
Basket:
type: Equipment
equipment: DeepFryer
Peel:
type: Equipment
equipment: Oven
DirtyPlate:
type: Equipment
Plate:
type: Equipment
needs: [ DirtyPlate ]
seconds: 2.0
equipment: Sink
# --------------------------------------------------------------------------------
Tomato:
type: Ingredient
Lettuce:
type: Ingredient
Onion:
type: Ingredient
Meat:
type: Ingredient
Bun:
type: Ingredient
Potato:
type: Ingredient
Fish:
type: Ingredient
Dough:
type: Ingredient
Cheese:
type: Ingredient
Sausage:
type: Ingredient
ChoppedTomato:
type: Ingredient
needs: [ Tomato ]
seconds: 4.0
equipment: CuttingBoard
ChoppedLettuce:
type: Ingredient
needs: [ Lettuce ]
seconds: 3.0
equipment: CuttingBoard
ChoppedOnion:
type: Ingredient
needs: [ Onion ]
seconds: 5.0
equipment: CuttingBoard
RawPatty:
type: Ingredient
needs: [ Meat ]
seconds: 4.0
equipment: CuttingBoard
RawChips:
type: Ingredient
needs: [ Potato ]
seconds: 4.0
equipment: CuttingBoard
ChoppedFish:
type: Ingredient
needs: [ Fish ]
seconds: 4.0
equipment: CuttingBoard
PizzaBase:
type: Ingredient
needs: [ Dough ]
seconds: 4.0
equipment: CuttingBoard
GratedCheese:
type: Ingredient
needs: [ Cheese ]
seconds: 4.0
equipment: CuttingBoard
ChoppedSausage:
type: Ingredient
needs: [ Sausage ]
seconds: 4.0
equipment: CuttingBoard
CookedPatty:
type: Ingredient
seconds: 5.0
needs: [ RawPatty ]
equipment: Pan
# --------------------------------------------------------------------------------
Chips:
type: Meal
seconds: 5.0
needs: [ RawChips ]
equipment: Basket
FriedFish:
type: Meal
seconds: 5.0
needs: [ ChoppedFish ]
equipment: Basket
Burger:
type: Meal
needs: [ Bun, ChoppedLettuce, ChoppedTomato, CookedPatty ]
equipment: ~
Salad:
type: Meal
needs: [ ChoppedLettuce, ChoppedTomato ]
equipment: ~
TomatoSoup:
type: Meal
needs: [ ChoppedTomato, ChoppedTomato, ChoppedTomato ]
seconds: 6.0
equipment: Pot
OnionSoup:
type: Meal
needs: [ ChoppedOnion, ChoppedOnion, ChoppedOnion ]
seconds: 6.0
equipment: Pot
FishAndChips:
type: Meal
needs: [ FriedFish, Chips ]
equipment: ~
Pizza:
type: Meal
needs: [ PizzaBase, ChoppedTomato, GratedCheese, ChoppedSausage ]
seconds: 7.0
equipment: Peel
# --------------------------------------------------------------------------------
BurntCookedPatty:
type: Waste
seconds: 5.0
needs: [ CookedPatty ]
equipment: Pan
BurntChips:
type: Waste
seconds: 5.0
needs: [ Chips ]
equipment: Basket
BurntFriedFish:
type: Waste
seconds: 5.0
needs: [ FriedFish ]
equipment: Basket
BurntTomatoSoup:
type: Waste
needs: [ TomatoSoup ]
seconds: 6.0
equipment: Pot
BurntOnionSoup:
type: Waste
needs: [ OnionSoup ]
seconds: 6.0
equipment: Pot
BurntPizza:
type: Waste
needs: [ Pizza ]
seconds: 7.0
equipment: Peel
# --------------------------------------------------------------------------------
Fire:
type: Effect
seconds: 5.0
needs: [ BurntCookedPatty, BurntChips, BurntFriedFish, BurntTomatoSoup, BurntOnionSoup, BurntPizza ]
manager: FireManager
effect_type: Unusable
# --------------------------------------------------------------------------------
Extinguisher:
type: Tool
seconds: 1.0
needs: [ Fire ]
plates:
clean_plates: 2
dirty_plates: 0
plate_delay: [ 5, 10 ]
# range of seconds until the dirty plate arrives.
game:
time_limit_seconds: 300
undo_dispenser_pickup: true
validate_recipes: false
layout_chars:
_: Free
hash: Counter # #
A: Agent
pipe: Extinguisher
P: PlateDispenser
C: CuttingBoard
X: Trashcan
$: ServingWindow
S: Sink
+: SinkAddon
at: Plate # @ just a clean plate on a counter
U: Pot # with Stove
Q: Pan # with Stove
O: Peel # with Oven
F: Basket # with DeepFryer
T: Tomato
N: Onion # oNioN
L: Lettuce
K: Potato # Kartoffel
I: Fish # fIIIsh
D: Dough
E: Cheese # chEEEse
G: Sausage # sausaGe
B: Bun
M: Meat
question: Counter # ? mushroom
: Counter
^: Counter
right: Counter
left: Counter
wave: Free # ~ Water
minus: Free # - Ice
dquote: Counter # " wall/truck
p: Counter # second plate return ??
orders:
meals:
all: false
# if all: false -> only orders for these meals are generated
# TODO: what if this list is empty?
list:
- Pizza
order_gen_class: !!python/name:cooperative_cuisine.orders.RandomOrderGeneration ''
# the class to that receives the kwargs. Should be a child class of OrderGeneration in orders.py
order_gen_kwargs:
order_duration_random_func:
# how long should the orders be alive
# 'random' library call with getattr, kwargs are passed to the function
func: uniform
kwargs:
a: 40
b: 60
max_orders: 6
# maximum number of active orders at the same time
num_start_meals: 2
# number of orders generated at the start of the environment
sample_on_dur_random_func:
# 'random' library call with getattr, kwargs are passed to the function
func: uniform
kwargs:
a: 10
b: 20
sample_on_serving: false
# Sample the delay for the next order only after a meal was served.
serving_not_ordered_meals: true
# can meals that are not ordered be served / dropped on the serving window
player_config:
radius: 0.4
speed_units_per_seconds: 6
interaction_range: 1.6
restricted_view: True
view_angle: 100
view_range: 3.2 # in grid units, can be "null"
effect_manager:
FireManager:
class: !!python/name:cooperative_cuisine.effects.FireEffectManager ''
kwargs:
spreading_duration: [ 5, 10 ]
fire_burns_ingredients_and_meals: true
extra_setup_functions:
# # --------------- Scoring ---------------
orders:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ completed_order ]
callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks ''
callback_class_kwargs:
static_score: 20
score_on_specific_kwarg: meal_name
score_map:
Burger: 15
OnionSoup: 10
Salad: 5
TomatoSoup: 10
not_ordered_meals:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ serve_not_ordered_meal ]
callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks ''
callback_class_kwargs:
static_score: 2
trashcan_usages:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ trashcan_usage ]
callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks ''
callback_class_kwargs:
static_score: -5
expired_orders:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ order_expired ]
callback_class: !!python/name:cooperative_cuisine.scores.ScoreViaHooks ''
callback_class_kwargs:
static_score: -10
# # --------------- Recording ---------------
# json_states:
# func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
# kwargs:
# hooks: [ json_state ]
# callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
# callback_class_kwargs:
# log_path: USER_LOG_DIR/ENV_NAME/json_states.jsonl
actions:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ pre_perform_action ]
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs:
log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
random_env_events:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ order_duration_sample, plate_out_of_kitchen_time ]
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs:
log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
add_hook_ref: true
env_configs:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks: [ env_initialized, item_info_config ]
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs:
log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
add_hook_ref: true
# Game event recording
game_events:
func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
kwargs:
hooks:
- post_counter_pick_up
- post_counter_drop_off
- post_dispenser_pick_up
- cutting_board_100
- player_start_interaction
- player_end_interact
- post_serving
- no_serving
- dirty_plate_arrives
- trashcan_usage
- plate_cleaned
- added_plate_to_sink
- drop_on_sink_addon
- pick_up_from_sink_addon
- serve_not_ordered_meal
- serve_without_plate
- completed_order
- new_orders
- order_expired
- action_on_not_reachable_counter
- new_fire
- fire_spreading
- drop_off_on_cooking_equipment
- players_collide
- post_plate_dispenser_pick_up
- post_plate_dispenser_drop_off
- on_item_transition
- progress_started
- progress_finished
- content_ready
callback_class: !!python/name:cooperative_cuisine.recording.FileRecorder ''
callback_class_kwargs:
log_path: USER_LOG_DIR/ENV_NAME/LOG_RECORD_NAME.jsonl
add_hook_ref: true
# info_msg:
# func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
# kwargs:
# hooks: [ cutting_board_100 ]
# log_class: !!python/name:cooperative_cuisine.info_msg.InfoMsgManager ''
# log_class_kwargs:
# msg: Glückwunsch du hast was geschnitten!
# fire_msg:
# func: !!python/name:cooperative_cuisine.hooks.hooks_via_callback_class ''
# kwargs:
# hooks: [ new_fire ]
# log_class: !!python/name:cooperative_cuisine.info_msg.InfoMsgManager ''
# log_class_kwargs:
# msg: Feuer, Feuer, Feuer
# level: Warning
CuttingBoard:
type: Equipment
Sink:
type: Equipment
Stove:
type: Equipment
DeepFryer:
type: Equipment
Oven:
type: Equipment
Pot:
type: Equipment
equipment: Stove
Pan:
type: Equipment
equipment: Stove
Basket:
type: Equipment
equipment: DeepFryer
Peel:
type: Equipment
equipment: Oven
DirtyPlate:
type: Equipment
Plate:
type: Equipment
needs: [ DirtyPlate ]
seconds: 2.0
equipment: Sink
# --------------------------------------------------------------------------------
Tomato:
type: Ingredient
Lettuce:
type: Ingredient
Onion:
type: Ingredient
Meat:
type: Ingredient
Bun:
type: Ingredient
Potato:
type: Ingredient
Fish:
type: Ingredient
Dough:
type: Ingredient
Cheese:
type: Ingredient
Sausage:
type: Ingredient
ChoppedTomato:
type: Ingredient
needs: [ Tomato ]
seconds: 3.0
equipment: CuttingBoard
ChoppedLettuce:
type: Ingredient
needs: [ Lettuce ]
seconds: 3.0
equipment: CuttingBoard
ChoppedOnion:
type: Ingredient
needs: [ Onion ]
seconds: 5.0
equipment: CuttingBoard
RawPatty:
type: Ingredient
needs: [ Meat ]
seconds: 4.0
equipment: CuttingBoard
RawChips:
type: Ingredient
needs: [ Potato ]
seconds: 4.0
equipment: CuttingBoard
ChoppedFish:
type: Ingredient
needs: [ Fish ]
seconds: 4.0
equipment: CuttingBoard
PizzaBase:
type: Ingredient
needs: [ Dough ]
seconds: 4.0
equipment: CuttingBoard
GratedCheese:
type: Ingredient
needs: [ Cheese ]
seconds: 4.0
equipment: CuttingBoard
ChoppedSausage:
type: Ingredient
needs: [ Sausage ]
seconds: 4.0
equipment: CuttingBoard
CookedPatty:
type: Ingredient
seconds: 5.0
needs: [ RawPatty ]
equipment: Pan
# --------------------------------------------------------------------------------
Chips:
type: Meal
seconds: 5.0
needs: [ RawChips ]
equipment: Basket
FriedFish:
type: Meal
seconds: 5.0
needs: [ ChoppedFish ]
equipment: Basket
Burger:
type: Meal
needs: [ Bun, ChoppedLettuce, ChoppedTomato, CookedPatty ]
equipment: ~
Salad:
type: Meal
needs: [ ChoppedLettuce, ChoppedTomato ]
equipment: ~
TomatoSoup:
type: Meal
needs: [ ChoppedTomato, ChoppedTomato, ChoppedTomato ]
seconds: 6.0
equipment: Pot
OnionSoup:
type: Meal
needs: [ ChoppedOnion, ChoppedOnion, ChoppedOnion ]
seconds: 6.0
equipment: Pot
FishAndChips:
type: Meal
needs: [ FriedFish, Chips ]
equipment: ~
Pizza:
type: Meal
needs: [ PizzaBase, ChoppedTomato, GratedCheese, ChoppedSausage ]
seconds: 7.0
equipment: Peel
# --------------------------------------------------------------------------------
BurntCookedPatty:
type: Waste
seconds: 5.0
needs: [ CookedPatty ]
equipment: Pan
BurntChips:
type: Waste
seconds: 5.0
needs: [ Chips ]
equipment: Basket
BurntFriedFish:
type: Waste
seconds: 5.0
needs: [ FriedFish ]
equipment: Basket
BurntTomatoSoup:
type: Waste
needs: [ TomatoSoup ]
seconds: 6.0
equipment: Pot
BurntOnionSoup:
type: Waste
needs: [ OnionSoup ]
seconds: 6.0
equipment: Pot
BurntPizza:
type: Waste
needs: [ Pizza ]
seconds: 7.0
equipment: Peel
# --------------------------------------------------------------------------------
Fire:
type: Effect
seconds: 5.0
needs: [ BurntCookedPatty, BurntChips, BurntFriedFish, BurntTomatoSoup, BurntOnionSoup, BurntPizza ]
manager: FireManager
effect_type: Unusable
# --------------------------------------------------------------------------------
Extinguisher:
type: Tool
seconds: 1.0
needs: [ Fire ]
levels:
- config_path: STUDY_DIR/level1/level1_config.yaml
- config_path: CONFIGS_DIR/environment_config.yaml
layout_path: LAYOUTS_DIR/overcooked-1/1-1-far-apart.layout
item_info_path: STUDY_DIR/level1/level1_item_info.yaml
item_info_path: CONFIGS_DIR/item_info.yaml
name: "Level 1-1: Far Apart"
config_overwrite:
game:
time_limit_seconds: 300
plates:
clean_plates: 0
dirty_plates: 0
# - config_path: CONFIGS_DIR/environment_config.yaml
# layout_path: LAYOUTS_DIR/basic.layout
# item_info_path: CONFIGS_DIR/item_info.yaml
# name: "Basic"
- config_path: CONFIGS_DIR/environment_config.yaml
layout_path: LAYOUTS_DIR/basic.layout
item_info_path: CONFIGS_DIR/item_info.yaml
name: "Basic"
config_overwrite:
game:
time_limit_seconds: 300
- config_path: STUDY_DIR/level2/level2_config.yaml
- config_path: CONFIGS_DIR/environment_config.yaml
layout_path: LAYOUTS_DIR/overcooked-1/1-4-bottleneck.layout
item_info_path: STUDY_DIR/level2/level2_item_info.yaml
item_info_path: CONFIGS_DIR/item_info.yaml
name: "Level 1-4: Bottleneck"
config_overwrite:
player_config:
restricted_view: true
plates:
clean_plates: 0
dirty_plates: 0
num_players: 1
......
......@@ -19,8 +19,9 @@ import random
import signal
import subprocess
from pathlib import Path
from pprint import pprint
from subprocess import Popen
from typing import Tuple
from typing import Tuple, Any
import requests
import uvicorn
......@@ -37,6 +38,7 @@ from cooperative_cuisine.utils import (
add_list_of_manager_ids_arguments,
expand_path,
add_study_arguments,
deep_update,
)
log = logging.getLogger(__name__)
......@@ -65,6 +67,8 @@ class LevelConfig(BaseModel):
"""Path to the layout file."""
item_info_path: str
"""Path to the item info file."""
config_overwrite: dict[str, Any] | None = None
"""Overwrite parts of the `environment_config`"""
class LevelInfo(BaseModel):
......@@ -102,10 +106,10 @@ class Study:
env_config_f = file.read()
self.study_config: StudyConfig = yaml.load(
str(env_config_f), Loader=yaml.SafeLoader
str(env_config_f), Loader=yaml.Loader
)
"""Configuration for the study which layouts, env_configs and item infos are used for the study levels."""
self.levels: list[LevelConfig] = self.study_config["levels"]
self.levels: list[dict] = self.study_config["levels"]
"""List of level configs for each of the levels which the study runs through."""
self.current_level_idx: int = 0
"""Counter of which level is currently run in the config."""
......@@ -159,12 +163,12 @@ class Study:
)
return filled and not self.is_full
def create_env(self, level: LevelConfig) -> EnvironmentData:
def create_env(self, level: dict) -> EnvironmentData:
"""Creates/starts an environment on the game server,
given the configuration file paths specified in the level.
Args:
level: LevelConfig which contains the paths to the env config, layout and item info files.
level: dict with LevelConfig content which contains the paths to the env config, layout and item info files.
Returns:
EnvironmentData which contains information about the newly created environment.
......@@ -172,10 +176,10 @@ class Study:
Raises:
ValueError if the gameserver returned a conflict, HTTPError with 500 if the game server crashes.
"""
item_info_path = expand_path(level["item_info_path"])
layout_path = expand_path(level["layout_path"])
config_path = expand_path(level["config_path"])
level = LevelConfig(**level)
item_info_path = expand_path(level.item_info_path)
layout_path = expand_path(level.layout_path)
config_path = expand_path(level.config_path)
with open(item_info_path, "r") as file:
item_info = file.read()
......@@ -183,9 +187,17 @@ class Study:
layout = file.read()
with open(config_path, "r") as file:
environment_config = file.read()
self.current_config: EnvironmentConfig = yaml.load(
environment_config, Loader=yaml.Loader
)
self.current_config: EnvironmentConfig = yaml.load(
environment_config, Loader=yaml.Loader
)
if level.config_overwrite is not None:
pprint(self.current_config)
pprint(level.config_overwrite)
deep_update(self.current_config, level.config_overwrite)
pprint(self.current_config)
environment_config = yaml.dump(self.current_config)
seed = int(random.random() * 1000000)
creation_json = CreateEnvironmentConfig(
manager_id=study_manager.server_manager_id,
......
......@@ -3,6 +3,7 @@ Some utility functions.
"""
from __future__ import annotations
import collections.abc
import dataclasses
import json
import logging
......@@ -460,3 +461,12 @@ def create_layout_with_counters(w, h) -> str:
string += "\n"
print(string)
return string
def deep_update(d, u):
for k, v in u.items():
if isinstance(v, collections.abc.Mapping):
d[k] = deep_update(d.get(k, {}), v)
else:
d[k] = v
return d
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment