Skip to content
Snippets Groups Projects
Commit 500d043e authored by Fabian Heinrich's avatar Fabian Heinrich
Browse files

Seed in study config

parent 05af345c
No related branches found
No related tags found
No related merge requests found
Pipeline #49684 passed
...@@ -4,6 +4,7 @@ levels: ...@@ -4,6 +4,7 @@ levels:
layout_path: LAYOUTS_DIR/overcooked-1/1-1-far-apart.layout layout_path: LAYOUTS_DIR/overcooked-1/1-1-far-apart.layout
item_info_path: CONFIGS_DIR/item_info.yaml item_info_path: CONFIGS_DIR/item_info.yaml
name: "Level 1" name: "Level 1"
seed: 12345
config_overwrite: config_overwrite:
game: game:
time_limit_seconds: 300 time_limit_seconds: 300
...@@ -21,6 +22,7 @@ levels: ...@@ -21,6 +22,7 @@ levels:
layout_path: LAYOUTS_DIR/overcooked-1/1-4-bottleneck.layout layout_path: LAYOUTS_DIR/overcooked-1/1-4-bottleneck.layout
item_info_path: CONFIGS_DIR/item_info.yaml item_info_path: CONFIGS_DIR/item_info.yaml
name: "Level 2" name: "Level 2"
seed: 12345
config_overwrite: config_overwrite:
game: game:
time_limit_seconds: 300 time_limit_seconds: 300
...@@ -29,6 +31,7 @@ levels: ...@@ -29,6 +31,7 @@ levels:
layout_path: LAYOUTS_DIR/overcooked-1/1-5-circle.layout layout_path: LAYOUTS_DIR/overcooked-1/1-5-circle.layout
item_info_path: CONFIGS_DIR/item_info.yaml item_info_path: CONFIGS_DIR/item_info.yaml
name: "Level 3" name: "Level 3"
seed: 12345
config_overwrite: config_overwrite:
game: game:
time_limit_seconds: 300 time_limit_seconds: 300
...@@ -41,6 +44,7 @@ levels: ...@@ -41,6 +44,7 @@ levels:
layout_path: LAYOUTS_DIR/overcooked-1/4-1-moving-counters.layout layout_path: LAYOUTS_DIR/overcooked-1/4-1-moving-counters.layout
item_info_path: CONFIGS_DIR/item_info.yaml item_info_path: CONFIGS_DIR/item_info.yaml
name: "Level 4" name: "Level 4"
seed: 12345
config_overwrite: config_overwrite:
game: game:
time_limit_seconds: 300 time_limit_seconds: 300
......
...@@ -15,7 +15,6 @@ import argparse ...@@ -15,7 +15,6 @@ import argparse
import asyncio import asyncio
import logging import logging
import os import os
import random
import signal import signal
import subprocess import subprocess
import uuid import uuid
...@@ -70,6 +69,8 @@ class LevelConfig(BaseModel): ...@@ -70,6 +69,8 @@ class LevelConfig(BaseModel):
"""Path to the item info file.""" """Path to the item info file."""
config_overwrite: dict[str, Any] | None = None config_overwrite: dict[str, Any] | None = None
"""Overwrite parts of the `environment_config`""" """Overwrite parts of the `environment_config`"""
seed: int
"""Seed for the level."""
class LevelInfo(BaseModel): class LevelInfo(BaseModel):
...@@ -108,13 +109,13 @@ class Study: ...@@ -108,13 +109,13 @@ class Study:
game_port: The port number of the game server. game_port: The port number of the game server.
""" """
with open(study_config_path, "r") as file: with open(study_config_path, "r") as file:
env_config_f = file.read() study_config_f = file.read()
self.study_id = uuid.uuid4().hex[:UUID_CUTOFF] self.study_id = uuid.uuid4().hex[:UUID_CUTOFF]
"""Unique ID of the study.""" """Unique ID of the study."""
self.study_config: StudyConfig = yaml.load( self.study_config: StudyConfig = yaml.load(
str(env_config_f), Loader=yaml.Loader str(study_config_f), Loader=yaml.Loader
) )
"""Configuration for the study which layouts, env_configs and item infos are used for the study levels.""" """Configuration for the study which layouts, env_configs and item infos are used for the study levels."""
self.levels: list[dict] = self.study_config["levels"] self.levels: list[dict] = self.study_config["levels"]
...@@ -203,7 +204,7 @@ class Study: ...@@ -203,7 +204,7 @@ class Study:
deep_update(self.current_config, level.config_overwrite) deep_update(self.current_config, level.config_overwrite)
environment_config = yaml.dump(self.current_config) environment_config = yaml.dump(self.current_config)
seed = int(random.random() * 1000000) seed = level.seed
creation_json = CreateEnvironmentConfig( creation_json = CreateEnvironmentConfig(
manager_id=study_manager.server_manager_id, manager_id=study_manager.server_manager_id,
number_players=self.study_config["num_players"] number_players=self.study_config["num_players"]
......
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