Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

1️⃣ OneAgent

Stop importing a dozen different agent classes. OneAgent is the single, all-encompassing interface for Reinforcement Learning.

Whether you are fine-tuning a tabular solution for a GridWorld or training a Deep Reinforcement Learning model for a robot, your code structure should not change. OneAgent encapsulates the entire RL landscape—Tabular, Linear, and Deep—into a single, configuration-driven entity.

⚡ The Promise

In other libraries, changing an algorithm requires rewriting your initialization code.

  • Old Way: from stable_baselines3 import PPO $\to$ from my_lib import QTable
  • The OneAgent Way: from oneagent import Agent. Just change the config.

📦 Installation

git clone https://github.com/Mat-thias/OneAgent.git
cd OneAgent
pip install -e .

🚀 Usage: The "All-in-One" Workflow

The Agent class is a shapeshifter. It adapts its internal architecture based on the config dictionary you pass to it.

Scenario A: The Student (Tabular Q-Learning)

You are learning RL. You want to see the Q-Table.

import gymnasium as gym
from oneagent import Agent

env = gym.make("Taxi-v3")

# The Agent becomes a Tabular Q-Learner
agent = Agent(
    env=env,
    config={
        "mode": "tabular",
        "algorithm": "q_learning",
        "policy": "epsilon_greedy",
        "memory": "none" # Tabular doesn't need a buffer
    }
)

agent.train(episodes=1000)

Scenario B: The Researcher (Deep Q-Network)

You graduate to a visual environment. You need a Neural Network. You do not change the Agent class.

import gymnasium as gym
from oneagent import Agent

env = gym.make("CartPole-v1")

# The SAME Agent class morphs into a DQN
agent = Agent(
    env=env,
    config={
        "mode": "deep",             # <--- Switches backend to PyTorch
        "algorithm": "q_learning",  # <--- Logic remains Off-Policy TD
        "policy": "epsilon_greedy",
        "memory": "prioritized_replay", # <--- Adds PER Buffer
        "network": {
            "hidden_sizes": [128, 128],
            "activation": "relu"
        }
    }
)

agent.train(episodes=500)

Scenario C: The Architect (Model-Based / Planning)

You want to simulate experience using a learned model (Dyna-Q).

# The Agent activates its internal Model simulator
agent = Agent(
    env=env,
    config={
        "mode": "tabular",
        "algorithm": "dyna_q",  # <--- Activates Planning Loop
        "planning_steps": 10    # <--- 10 Hallucinated steps per real step
    }
)

🧩 The Core Capabilities

OneAgent doesn't just list algorithms; it combines Components to create agents.

Capability Options Supported
Brain (Backend) Table (Dict), Linear (TileCoding), Neural (MLP/CNN)
Logic (Update) MonteCarlo, TD_0, TD_N, ExpectedSARSA, DoubleLearning
Memory None (Online), UniformReplay, PrioritizedReplay, Hindsight
Exploration EpsilonGreedy, Softmax, UCB, OU_Noise (Continuous)

🏗️ Architecture

How does one class do everything? Composition.

OneAgent is a wrapper that routes your config to the correct sub-modules.

OneAgent/
├── __init__.py
├── core_agent.py          # The single entry point
│
├── brains/                # Stores the Value Function
│   ├── tabular_brain.py
│   └── neural_brain.py
│
├── algorithms/            # Calculates the Loss/Error
│   ├── bellman_equation.py
│   └── policy_gradient.py
│
└── memories/              # Stores the Experience
    └── replay_buffer.py

🗺️ Roadmap

  • v1.0 (The Foundation): Tabular & Linear support for all Sutton & Barto algorithms.
  • v2.0 (The Expansion): Deep RL support (DQN, Dueling DQN).
  • v3.0 (The Continuous): Actor-Critic methods for robotics (PPO, SAC).

🤝 Contributing

We want OneAgent to be the Swiss Army Knife of RL. If you have a new exploration strategy or a better replay buffer, open a PR!

About

Your all in one agent

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages