Training a PPO Agent in UE5: 72,000 Nights of Guarding the Campfire

A developer trained a PPO agent in UE5 to guard a campfire over 72,000 nights and is seeking community feedback.
A developer shared on Reddit a project training a PPO reinforcement learning agent in Unreal Engine 5 (UE5) to guard a campfire, with about 72,000 nights of training. The article analyzes the core challenges: UE5's high-fidelity environment brings high computational overhead and a complex observation space, and the task is essentially resource management and risk decision-making in dynamic confrontation. The tech stack involves interfaces between UE5 and Python-side RL frameworks, requiring handling of observation space design, reward function shaping, and training efficiency (parallel/distributed training). Long-cycle training lessons include environment randomization, reward function simplification, and visualized logs. The author publicly shares the setup and seeks community feedback, reflecting how RL projects depend on cross-validation and iteration.
A developer shared his hardcore project on Reddit: training a PPO reinforcement learning agent in Unreal Engine 5 (UE5) to fend off monsters and guard a campfire. The project went through roughly 72,000 nights of training, and the author posted to seek community feedback.

Project Background and Core Challenges
Training reinforcement learning agents in game environments has always been a touchstone for testing algorithm robustness. UE5 provides high-fidelity physics and rendering environments, but it also means higher computational overhead and a more complex observation space. The author chose the "guard the campfire" task, which is essentially about letting the agent learn resource management and risk decision-making in dynamic confrontation — monsters keep coming, the campfire must be maintained, and the agent must learn to weigh trade-offs.
You may not have noticed that the scale of 72,000 nights of training implies the task is far from easy. Each "night" may represent a complete training episode, and the agent needs to gradually learn a policy from repeated failures. This kind of long-cycle training places high demands on algorithm stability and sample efficiency, which also explains why the author chose PPO — a policy gradient method that performs well in both continuous control and discrete action spaces.
PPO (Proximal Policy Optimization) is a policy gradient algorithm proposed by OpenAI in 2017. Its core idea is to ensure training stability by limiting the magnitude of policy updates. Specifically, PPO introduces a clipping mechanism for the importance sampling ratio in the objective function, preventing the new policy from deviating too far from the old policy and thus avoiding training collapse. Compared with earlier methods such as TRPO, PPO is simpler to implement, more computationally efficient, and does not require second-order derivatives. It performs well in both continuous control (such as robot control) and discrete action spaces (such as game operations), making it one of the most commonly used baseline algorithms in game AI training. Typical PPO hyperparameters include the clipping coefficient ε (usually 0.1-0.2), the GAE discount factor λ, the learning rate, and the number of sampling steps per round.
"Episodes" and "nights" in reinforcement learning: In RL training, an episode refers to the complete process in which the agent starts from the initial state of the environment, goes through a series of actions and state transitions, and continues until a termination condition is reached (such as a monster being defeated, the campfire going out, or time running out). The "72,000 nights" in the original post means about 72,000 training episodes. After each episode ends, the agent updates its policy based on the cumulative reward. More episodes is not always better — too many may indicate slow convergence or improper hyperparameters, while too few may lead to underfitting. In a complex 3D game environment, 72,000 episodes is a medium-to-high scale, and it usually requires running multiple environment instances in parallel (such as 8-16) to accelerate data collection.
Tech Stack and Training Setup
Although the original post did not expand on all the details, it can be inferred that the project combined UE5's Blueprint or C++ environment interface with a Python-side reinforcement learning framework (such as PyTorch or TensorFlow). PPO (Proximal Policy Optimization) has become a common choice in game AI training because it is simple to implement and relatively friendly for hyperparameter tuning.
Building an RL environment in UE5 usually requires handling several key issues:
- Observation space design: The agent needs to perceive the campfire state, monster positions, its own resources, and so on. Observations with too high dimensionality will slow down training, while those with too low dimensionality may lose key information.
- Reward function shaping: The campfire-guarding task requires a combination of sparse and dense rewards. For example, keeping the campfire alive gives a positive reward, while being attacked by monsters gives a penalty, but the penalty strength must be carefully tuned to avoid the agent learning a strategy of "avoidance" rather than "confrontation."
- Training efficiency: UE5 environments run far slower than lightweight simulators. The training duration of 72,000 nights means the author may have used parallel environments or distributed training to accelerate it.
The communication bridge between UE5 and Python: Building an RL environment in Unreal Engine 5 usually requires passing the engine's internal state data (such as character position, monster coordinates, and campfire health) to the Python training process in real time, and sending action commands back. Common solutions include: using UE5's Python plugin (such as UnrealEnginePython) to embed scripts directly; inter-process communication via TCP/UDP sockets or gRPC; or using UE5's Remote Control API. A more mature approach is to adopt UnrealCV or an ML-Agents-style interface, wrapping the environment as step/reset interfaces that conform to the Gymnasium (formerly OpenAI Gym) specification. Because UE5 rendering is expensive, it is usually necessary to disable unnecessary rendering passes (such as shadows and post-processing) or reduce resolution to increase the environment step frequency; otherwise, the agent can only collect a few dozen steps of data per second, making training efficiency extremely low.
Parallel environments and distributed training: In heavy environments like UE5, single-instance training speed is far lower than that of lightweight simulators. Common acceleration methods include: launching multiple UE5 instances on a single machine (each instance running one copy of the environment), with the Python side collecting experience and updating the policy in a unified way; or adopting a distributed architecture (such as Ray RLlib), deploying environments across multiple machines and synchronizing gradients through a parameter server. Parallel environments can also naturally enable environment randomization — different instances can be configured with different monster spawn parameters, thereby improving the generalization ability of the policy.
Learning from Failure: The Meaning of Long-Cycle Training
A training volume of 72,000 nights is a medium-to-long cycle in reinforcement learning projects. This reflects a reality: in complex game environments, agents often need a large amount of trial and error to converge. The author did not disclose the final win rate or specific performance, but willingness to publicly share the setup and seek feedback shows that the project is still in the iteration stage.
For developers who want to reproduce or borrow from it, there are several lessons worth referencing. First, environment randomization is important — if the spawn positions, frequency, and types of monsters are too fixed, the agent will overfit to specific patterns. Second, the reward function should not be too complex, otherwise it is easy to introduce unintended behavior. Third, visualization of training logs is indispensable; otherwise, it is hard to tell whether the agent is improving or spinning its wheels.
Reward shaping is a key difficulty in applying reinforcement learning to game AI. In the "guard the campfire" task, the reward is usually composed of sparse terms (such as whether the campfire ultimately survives) and dense terms (such as changes in campfire health per frame and the number of times monsters are knocked back). Sparse reward signals are few and hard to learn from, while dense rewards may introduce bias — for example, if a positive reward is given for "staying away from monsters," the agent may learn to evade rather than confront. In practice, potential-based reward shaping is often used to ensure that the optimal policy remains unchanged: the reward is defined as the difference of a state potential function, such as F(s,s')=γΦ(s')-Φ(s), where Φ(s) can be designed as a combination of campfire health and monster distance. In addition, curriculum learning is also an effective strategy for long-cycle training: first let the agent learn basic defense in low-difficulty scenarios (such as few monsters and slow movement), then gradually increase difficulty, which can significantly shorten the number of episodes required for convergence.
The Value of Community Feedback
In the original post, the author explicitly stated that he "hopes to get feedback on the setup," which is exactly what reinforcement learning projects need most. Game AI training is often full of mystery, and the hyperparameter tuning process relies on experience and intuition. Through community cross-validation, developers can discover blind spots they have overlooked, such as whether the observation space misses key variables, or whether PPO's hyperparameters need to be adjusted for UE5's high-latency environment.
If you are also tinkering with reinforcement learning in UE5, you might as well start with this small task: first let the agent learn to survive in a simple scenario, then gradually increase the number of monsters and the campfire consumption rate. 72,000 nights sounds like a lot, but every failure is fuel for policy optimization.
One-line Summary
A developer trained a PPO agent in UE5 to guard a campfire, going through 72,000 nights and seeking community feedback.
Paragraph Summary
A developer shared on Reddit his project of training a PPO reinforcement learning agent in Unreal Engine 5 (UE5) to guard a campfire, with about 72,000 nights of training. The article analyzes the project's core challenges: UE5's high-fidelity environment brings high computational overhead and a complex observation space, and the task is essentially resource management and risk decision-making in dynamic confrontation. The tech stack involves interfaces between UE5 and Python-side RL frameworks and requires handling observation space design, reward function shaping, and training efficiency (parallel/distributed training). Lessons from long-cycle training include environment randomization, reward function simplification, and visualized logs. The author publicly shares the setup and seeks community feedback, reflecting the fact that reinforcement learning projects rely on cross-validation and iteration.
Related articles

Altman Says Local Deployment Can't Beat Data Centers: The Open-Source AI Debate Reignites
Altman says local deployment of open-source models can't match centralized data-center computing. Bilibili creator Guashu Diluola breaks down the technical roadmap debate and China-US AI industry differences behind the remark, asking whether local deployment should really be abandoned.

MiniMax H3 Open-Source Workflow: Breathing-Skin Results Even on Low VRAM
This article introduces a MiniMax H3 dual-sampling workflow shared by a Bilibili creator, using fused models, a line-breaking LoRA, and low-VRAM nodes to fix greasy AI character faces and run on 12GB VRAM devices. Includes model pairing, dual-sampling logic, and parameter details.

On-Device LLM + ESP32: Build a DIY Calorie Reminder
A Bilibili creator open-sourced a calorie intake reminder: a phone app uses the open-source miniCPM model to locally recognize food photos and estimate calories, while an ESP32 mini screen syncs data and shows intake status with green/yellow/red rings — magnetically attachable to the fridge door for constant reminders.