Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ LoD Agent SDK

Build AI agents that play League of Degens

Developer Portal โ€ข Quickstart โ€ข Examples โ€ข Twitter


What is this?

The LoD Agent SDK is an open-source Python toolkit that lets you build AI agents that play League of Degens matches autonomously. Your agent receives structured game state (positions, HP, cooldowns, minion waves) and sends back actions (move, attack, cast spells) โ€” all through a simple Python API.

Built on top of the pylol reinforcement learning environment (MIT License), repackaged and extended for the League of Degens ecosystem.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Game Server  โ”‚โ—„โ”€โ”€โ”€โ–บโ”‚  LoD Agent SDK   โ”‚โ—„โ”€โ”€โ”€โ–บโ”‚  Your Agent  โ”‚
โ”‚  (C# / .NET)  โ”‚     โ”‚  (Python / Redis) โ”‚     โ”‚  (Python)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     Game State โ”€โ”€โ”€โ”€โ”€โ”€โ–บ observations (JSON) โ”€โ”€โ”€โ”€โ”€โ”€โ–บ decisions
     โ—„โ”€โ”€โ”€โ”€โ”€โ”€ commands โ—„โ”€โ”€โ”€โ”€โ”€โ”€ actions (move/attack/spell)

Features

  • Full game state โ€” champion positions, health, mana, cooldowns, minion data
  • Action space โ€” move, attack, cast spells (Q/W/E/R), summoner spells
  • OpenAI Gym compatible โ€” works with stable-baselines3, RLlib, CleanRL
  • Multiple agent types โ€” scripted, random, RL-trained, or LLM-powered
  • Replay recording โ€” capture and replay agent matches
  • Headless mode โ€” train without rendering (fast), or watch with the LoL client

Quickstart

Prerequisites

  • Python 3.8+ (tested with 3.14)
  • .NET SDK 8.0
  • Redis server (Windows: Redis 3.0.504)
  • Windows 10/11

5v5 tested: 10 agents, 1000 steps, 2.8 fps, all agents receiving valid rewards.

1. Clone the repository

git clone https://github.com/Jul1usCrypto/lod-agents.git
cd lod-agents

2. Install the SDK

pip install -e .

3. Build the Game Server

# Windows
.\setup_server.bat

# Linux / macOS
chmod +x setup_server.sh && ./setup_server.sh

4. Run your first agent

python examples/my_first_agent.py

You should see two Ezreal champions spawning on Summoner's Rift โ€” one controlled by your agent, one scripted. Your agent will attempt to attack the enemy.

Examples

Example Description
examples/my_first_agent.py Minimal 1v1 agent โ€” attack the nearest enemy
examples/simulation.py 5v5 team fight โ€” 10 AI agents brawling mid-lane
examples/scripted_agent.py Rule-based agent with ability usage
examples/random_agent.py Random actions from the action space
examples/train_ppo.py Train a PPO agent using stable-baselines3
examples/llm_agent.py Template for connecting an LLM (GPT/Claude)

Agent API

Observations

Every game tick, your agent receives an observation dict:

{
    "me_unit": {
        "position_x": 1500.0,
        "position_y": 2000.0,
        "current_hp": 580.0,
        "max_hp": 580.0,
        "current_mp": 280.0,
        "user_id": 1,
        "level": 1,
        "alive": 1.0
    },
    "enemy_unit": {
        "position_x": 3000.0,
        "position_y": 4000.0,
        "current_hp": 480.0,
        ...
    },
    "champ_units": [...],  # All champions
    "minion_units": [...]  # All minions
}

Actions

Your agent returns a FunctionCall:

from pylol.lib import actions

# No operation (do nothing)
return actions.FunctionCall(0, [[0]])

# Move in direction [dx, dy] โ€” grid 0-7, center=4
# e.g. [6, 4] = move right, [4, 6] = move down
return actions.FunctionCall(1, [[dx, dy]])

# Cast spell at position [x, y]
# spell_slot: 0=Q, 1=W, 2=E, 3=R
return actions.FunctionCall(2, [[spell_slot], [x, y]])

Writing a Custom Agent

from pylol.agents import base_agent
from pylol.lib import actions

class MyAgent(base_agent.BaseAgent):
    def step(self, obs):
        super().step(obs)

        me = obs.observation["me_unit"]
        enemy = obs.observation["enemy_unit"]

        # Calculate distance to enemy
        dx = enemy["position_x"] - me["position_x"]
        dy = enemy["position_y"] - me["position_y"]
        dist = (dx**2 + dy**2) ** 0.5

        if dist < 500:
            # Close enough โ€” cast Q at enemy
            return actions.FunctionCall(2, [[0], [enemy["position_x"], enemy["position_y"]]])
        else:
            # Move toward enemy (dx/dy grid: 0-7, center=4)
            move_x = int(4 + (dx / dist) * 3)
            move_y = int(4 + (dy / dist) * 3)
            return actions.FunctionCall(1, [[max(0, min(7, move_x)), max(0, min(7, move_y))]])

Configuration

Create a config_dirs.txt pointing to your game server build:

[dirs]
gameserver = C:\path\to\lod-agents\GameServer\publish-x86\
lolclient =

Leave lolclient empty for headless mode (no visual rendering, faster training).

Architecture

lod-agents/
โ”œโ”€โ”€ pylol/                  # Core SDK (Python RL environment)
โ”‚   โ”œโ”€โ”€ agents/             # Base agent classes
โ”‚   โ”œโ”€โ”€ bin/                # CLI tools
โ”‚   โ”œโ”€โ”€ env/                # Environment wrappers (Gym-compatible)
โ”‚   โ”œโ”€โ”€ lib/                # Actions, features, protocol, Redis controller
โ”‚   โ”œโ”€โ”€ maps/               # Map definitions
โ”‚   โ””โ”€โ”€ run_configs/        # Platform-specific configs
โ”œโ”€โ”€ examples/               # Example agents and training scripts
โ”œโ”€โ”€ docs/                   # Documentation
โ”œโ”€โ”€ GameServer/             # C# game server (git submodule)
โ”œโ”€โ”€ setup.py                # Package installer
โ”œโ”€โ”€ setup_server.bat        # Windows server build script
โ””โ”€โ”€ config_dirs.txt         # Server path configuration

For Developers & Bot Builders

We're building the first open AI playground on a real MOBA. Here's why you should build on LoD:

  • Open source โ€” fork it, mod it, ship it
  • Real game physics โ€” not a simplified toy environment
  • Community tournaments โ€” AI vs AI, AI vs Human, streamed live
  • $LoD token rewards โ€” top agent developers earn from the ecosystem
  • LLM integration ready โ€” connect GPT, Claude, Gemini to play live matches

Join the community

Credits

  • pylol by MiscellaneousStuff โ€” MIT License
  • LeagueSandbox community โ€” the original open-source LoL server project
  • League of Degens team โ€” rebranding, extensions, and ecosystem integration

License

MIT License โ€” see LICENSE for details.

About

League of Degens SDK for agents

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages