MoonTrajectory 是一个面向强化学习场景的 MoonBit 基础库,提供 Transition、Episode、ReplayBuffer 和 PrioritizedReplayBuffer 等核心数据结构,适合作为 DQN、PPO、离线强化学习等算法的底层组件。项目强调轻量、可扩展、易维护,后续可以继续扩展 n-step return、序列采样、持久化与更高效的优先级采样结构。
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
MoonTrajectory
MoonTrajectory is a small MoonBit library for reinforcement-learning trajectories. It focuses on a practical core that is useful on its own and easy to extend:
Transitionfor single-step environment dataEpisodefor ordered rollout storage and discounted returnsReplayBufferfor uniform experience replayPrioritizedReplayBufferfor proportional prioritized replayThe current implementation is intentionally compact, but the shape of the API is designed for later DQN, PPO, and offline-RL extensions.
Project Links
Competition Fit
This project is built to match the OSC2026 MoonBit track requirements:
Submission Checklist
masterwhen pushed to the empty remoteWhy this topic
This project sits in a mature and reusable area:
Layout
trajectory.mbt: coreTransitionandEpisodetypesreplay_buffer.mbt: circular replay buffer and uniform samplingprioritized_replay.mbt: basic proportional prioritized replayrng.mbt: tiny deterministic sampler used by tests and examplescmd/main/main.mbt: smoke demoQuick start
Public API
TransitionRepresents one step of interaction with an environment.
EpisodeStores an ordered list of transitions and keeps track of:
It also exposes
discounted_returns(gamma)for return computation.ReplayBufferA circular buffer with:
PrioritizedReplayBufferA basic prioritized replay implementation with:
alpha,beta, andepsilonThe first version uses a simple scan-based sampler instead of a tree structure so the code stays easy to read and audit.
Competition notes
This repository is set up to match the MoonBit open-source competition expectations:
Before submission, update these metadata fields for the final publishing account:
moon.modnamemoon.modrepositorycmd/main/moon.pkgimport path if the module name changesLicense
Apache-2.0
Status
This is the first public implementation pass. The next natural extensions are: