feat: implement DCOS source tree, tests, and build configuration
Complete implementation of the DCOS package including: - 40+ Python source files across agents, communication, core, learning, memory, protocols, utils - pyproject.toml build configuration - 102 unit tests across all subsystems - Fixed flake.nix (Python 3.12, proper dependencies, pyproject build) - Fixed .woodpecker.yml (correct paths, removed silent-fail flags) - Added .gitignore - Cleared stale pytest cache
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
Tests for LearningEngine.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from dcos.learning.engine import LearningEngine, Experience
|
||||
|
||||
|
||||
class TestLearningEngine:
|
||||
def test_record_experience(self):
|
||||
engine = LearningEngine()
|
||||
engine.record_experience(Experience(state={}, action="move", reward=1.0))
|
||||
assert engine.experience_count() == 1
|
||||
|
||||
def test_best_action(self):
|
||||
engine = LearningEngine()
|
||||
engine.record_experience(Experience(state={}, action="a", reward=10))
|
||||
engine.record_experience(Experience(state={}, action="b", reward=5))
|
||||
best = engine.best_action(["a", "b"])
|
||||
assert best == "a"
|
||||
|
||||
def test_get_action_score(self):
|
||||
engine = LearningEngine()
|
||||
engine.record_experience(Experience(state={}, action="explore", reward=0.5))
|
||||
assert engine.get_action_score("explore") == 0.05 # 0.5 * 0.1
|
||||
Reference in New Issue
Block a user