mirror of
https://github.com/NousResearch/atropos.git
synced 2026-05-01 17:45:16 +00:00
Add DynastAI game environment with FastAPI backend and web frontend
- Introduced `dynastai_local_server.py` for local development and testing. - Implemented `dynastai_server.py` as the main server entry point. - Created FastAPI endpoints for game state management, card generation, and player choices. - Developed a web interface with HTML, CSS, and JavaScript for user interaction. - Added game logic for managing metrics and decision effects. - Included configuration management and utility functions. - Established a testing framework for API and environment functionality. - Updated README.md with project overview and setup instructions.
This commit is contained in:
parent
c189fc3351
commit
e0dabe1225
18 changed files with 3143 additions and 0 deletions
80
environments/dynastai/src/config.py
Normal file
80
environments/dynastai/src/config.py
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
"""
|
||||
Configuration for DynastAI
|
||||
|
||||
This module holds configuration parameters for the DynastAI game environment.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import Dict, List, Any, Optional
|
||||
from pydantic import BaseModel, Field
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
class DynastAIConfig(BaseModel):
|
||||
"""
|
||||
Configuration class for DynastAI game
|
||||
"""
|
||||
# API configuration
|
||||
api_host: str = Field(default="localhost", description="API server host")
|
||||
api_port: int = Field(default=9001, description="API server port")
|
||||
|
||||
# Web UI configuration
|
||||
web_enabled: bool = Field(default=True, description="Enable web UI")
|
||||
web_port: int = Field(default=3000, description="Web UI port")
|
||||
|
||||
# Game configuration
|
||||
initial_metrics: Dict[str, int] = Field(
|
||||
default={
|
||||
"power": 50,
|
||||
"stability": 50,
|
||||
"piety": 50,
|
||||
"wealth": 50,
|
||||
"reign_year": 1
|
||||
},
|
||||
description="Initial game metrics"
|
||||
)
|
||||
|
||||
initial_category_weights: Dict[str, float] = Field(
|
||||
default={
|
||||
"power": 50.0,
|
||||
"stability": 50.0,
|
||||
"piety": 50.0,
|
||||
"wealth": 50.0
|
||||
},
|
||||
description="Initial category weights for card selection"
|
||||
)
|
||||
|
||||
# OpenRouter configuration
|
||||
openrouter_api_key: str = Field(
|
||||
default=os.getenv("OPENROUTER_API_KEY", ""),
|
||||
description="OpenRouter API key"
|
||||
)
|
||||
|
||||
openrouter_model: str = Field(
|
||||
default="qwen/Qwen1.5-7B",
|
||||
description="OpenRouter model to use"
|
||||
)
|
||||
|
||||
# Data storage configuration
|
||||
data_dir: str = Field(
|
||||
default="data",
|
||||
description="Directory for storing game data"
|
||||
)
|
||||
|
||||
# Game difficulty settings
|
||||
min_effect_value: int = Field(default=-20, description="Minimum effect value")
|
||||
max_effect_value: int = Field(default=20, description="Maximum effect value")
|
||||
normal_effect_range: tuple = Field(default=(-10, 10), description="Normal range for effects")
|
||||
|
||||
# Adaptive weighting parameters
|
||||
weight_alpha: float = Field(default=0.9, description="Alpha parameter for EMA weight update")
|
||||
weight_beta: float = Field(default=0.1, description="Beta parameter for EMA weight update")
|
||||
|
||||
|
||||
def get_config() -> DynastAIConfig:
|
||||
"""
|
||||
Returns the configuration object with values from environment variables
|
||||
"""
|
||||
return DynastAIConfig()
|
||||
Loading…
Add table
Add a link
Reference in a new issue