Abstract
The RoboCup 2D Soccer Simulation (SS2D) is a premier benchmark for multi-agent systems, requiring autonomous agents to manage real-time decision-making and coordination in noisy environments. Historically, the high barrier to entry has been defined by complex C++ base codes, which are difficult for beginners to navigate and challenging to integrate with modern AI tools. This paper presents Pyrus, the first complete, open-source Python framework for SS2D. Pyrus replaces dense C++ implementations with a readable, Object-Oriented Python architecture, enabling seamless integration with machine learning libraries like PyTorch and NumPy while maintaining functional parity with traditional simulation standards.
Introduction: The C++ Bottleneck
For decades, high-performing teams in the RoboCup 2D Soccer Simulation league have relied on base codes such as HELIOS or Cyrus2D. While these C++ frameworks offer the execution speed necessary for real-time simulation, their complexity—involving manual memory management and dense syntax—presents a significant bottleneck for rapid prototyping. Furthermore, as the majority of modern Artificial Intelligence and Reinforcement Learning (RL) research has shifted to Python, the lack of a native Python framework has forced researchers to use inefficient wrappers or complex inter-process communication (IPC) middleware.
The Pyrus Framework Architecture
Pyrus is a ground-up implementation of an SS2D agent in Python 3.9, designed to be lean and modular. The framework is divided into two primary components:
- PyrusGeom Library: A standalone library for 2D geometric calculations tailored for soccer, handling intercepts, field regions, and player trajectories using objects like
Vector2DandConvexHull. - Pyrus Base Code: A complete agent architecture that manages communication with the RoboCup Soccer Simulation Server (RCSSServer).
By stripping out deprecated features, the authors reduced the codebase from approximately 150,000 lines in traditional C++ bases to roughly 30,000 lines in Pyrus. The framework utilizes an Object-Oriented Programming (OOP) structure that mirrors the logic of established bases while prioritizing readability.
Agent Lifecycle and Decision Logic
The Pyrus framework handles the full agent lifecycle, from parsing server messages to executing complex behaviors. The agent maintains a "World Model"—an internal representation of the field state—and follows a structured decision-making loop. This loop ensures that the agent can respond to server cycles within the required millisecond windows.
As shown in the flowcharts, the agent first updates its world model based on incoming server messages. During "decision time," it enters the action impl phase, which prioritizes critical behaviors such as goalie decisions and set plays before falling back to standard kick or move decisions.
Key Advantages for AI Research
- Native ML Integration: Unlike previous wrappers, Pyrus allows researchers to import
scikit-learn,TensorFlow, orPyTorchdirectly into the agent's decision loop. This eliminates the need for middleware and simplifies the implementation of neural-network-based strategies. - Experience Replay Readiness: Pyrus is built with Python’s multiprocessing and shared memory packages, specifically designed to facilitate the collection of "experiences" across multiple player instances for training RL agents.
- Human-in-the-Loop Efficiency: The reduction in codebase size and the use of Python's readable syntax allow researchers to focus on high-level strategy and coordination rather than low-level memory management.
Performance and Future Directions
The primary trade-off for Pyrus is the inherent execution speed of Python compared to C++. While Pyrus is fully functional and compatible with RCSSServer v18, the authors plan to utilize Cython to optimize computationally expensive geometric calculations.
Future development goals include the release of an OpenAI Gymnasium wrapper to standardize SS2D as a reinforcement learning environment, as well as the creation of Python-based monitoring and log analysis tools to modernize the league's infrastructure. Pyrus is currently available under the MIT License, providing an accessible entry point for the next generation of multi-agent systems researchers.
Summary updated