Real Agents is a planning framework that combines traditional artificial intelligence methods with Large Language Models (LLM) and is suitable for generative AI agents. It includes a Unity plug-in and demonstration project.
The reason for the development of this project is to complete my undergraduate thesis (design) and my personal interest in game AI.
Large language models can perform reasoning, decision-making, and planning problems. We already have many mature Agent frameworks to help users operate some tools, such as searching for documents and creating web pages.
But I think there are several problems when implementing it in the game:
Difficult to debug: If behavior execution relies on LLM, it will bring about difficult-to-estimate token usage and how to handle Agent exceptions;
Slow response: For example if the state in the game changes, we may need to reconstruct the prompt word and context. If you let NPC generate plans like in Generative AI, it will take a lot of time to wait for LLM to be generated, which cannot be applied to real-time games.
Therefore, I tried to make LLM based on the traditional AI method, allowing the agent to plan by understanding the relationship between state quantities and behaviors, while behavior execution and status monitoring are completed by the program, and the agent will only trigger planning actions when the status changes. .
- Combined with Goal Oriented Action Planning (GOAP)
- The agent plans directly based on the set of behaviors defined in the game
- The agent learns and makes plans based on Goap planner
{
"dependencies": {
"com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask",
"com.huggingface.sharp-transformers": "https://github.com/AkiKurisu/sharp-transformers.git",
"com.kurisu.akiai": "https://github.com/AkiKurisu/AkiAI.git",
"com.kurisu.akibt": "https://github.com/AkiKurisu/AkiBT.git",
"com.kurisu.akiframework": "https://github.com/AkiKurisu/AkiFramework.git",
"com.kurisu.akigoap": "https://github.com/AkiKurisu/AkiGOAP.git",
"com.kurisu.unichat": "https://github.com/AkiKurisu/UniChat.git"
}
}
Download the Windows Build version from the Release page
-
First use LLM to label Action and Goal based on GOAP data.
-
Let Agent and Planner generate and search Plans based on world states (WorldStates) during runtime.
-
Compare the Plan, LLM reflects and iterates on the Memory.
-
You can then close the Planner and let the Agent generate the Plan.
First, the developer defines an executable action set (ActionSet
) and a goal set (GoalSet
).
Each behavior is based on GOAP rules and has a precondition Precondition
and an effect Effect
.
public class Eat : DescriptiveTask
{
protected sealed override void SetupDerived()
{
Preconditions[States.HasFood] = true;
Preconditions[States.IsHungry] = true;
}
protected sealed override void SetupEffects()
{
Effects[States.IsHungry] = false;
}
}
Secondly, input Action
to the large language model, summarize it into natural language as the agent's initial impression of the behavior (InitialImpression
) and long-term memory (Summary
), and leave the short-term memory (Comments
) blank.
"Name": "Cook",
"InitialImpression": "To Cook, you need to have energy and ingredients, and as a result, you will have food.",
"Summary": "Latest summary",
"Comments": [
"",
"",
"",
"",
""
]
Input Goal
to the large language model and let LLM generate natural language as an explanation (Explanation
) for using the Goal. And combine them to obtain the interpretation of the set G.
In Real Agents, you can directly click Self Description
in the editor of RealAgentSet
to generate the above data.
Adjust the agent mode (AgentMode
) and set it to Training
.
The Plan
running at this time is searched by Planner, and the Agent generates a Plan
at the same time. If there is a difference in behavior, LLM reflects on the reason and generates a Comment
as a short-term memory.
When the short-term memory reaches the threshold, the agent summarizes it based on the initial impression, comments and current long-term memory, overwrites the long-term memory, and iterates.
Based on the goals input from the outside, the agent reasons in real time in the virtual space.
LLM finds a suitable Plan
based on its own memory of each behavior. Since there is no Planner comparison, it only determines whether the Plan
is feasible. If not, LLM generates (Comment
) and injects it into the memory.
The experiment uses OpenAI's ChatGPT3.5 as the inference model. You need to fill in your own API Key in the game settings interface.
MIT
For VRM models please see the individual author's license statements.
Polygon Fantasy Kingdom is a paid asset.
Example scene is optimized by Scene Optimizer created by Procedural Worlds.
Lowpoly Environment can be downloaded in assetstore for free.
Heat - Complete Modern UI is paid asset.
https://assetstore.unity.com/packages/2d/gui/heat-complete-modern-ui-264857
GUI-CasualFantasy is paid asset.
https://assetstore.unity.com/packages/2d/gui/gui-casual-fantasy-265651
Unity Chan animation is owned by Unity Technology Japan and under UC2 license.
Medieval Animations Mega Pack is paid asset.
https://assetstore.unity.com/packages/3d/animations/medieval-animations-mega-pack-12141
Unity Starter Asset is under the Unity Companion License and can be downloaded in assetstore for free.
UniVRM is under MIT license.
AkiFramework is under MIT license.
Other animation, music, UI, and font resources used in the demo are network resources and should not be used for commercial purposes.
@misc{realagents,
author = {YiFei Feng},
title = {Real Agents: An planning framework for generative artificial intelligence agents},
year = {2024},
publisher = {GitHub},
journal = {https://github.com/AkiKurisu/Real-Agents},
school = {East China University of Political Science and Law},
location = {Shanghai, China}
}
-
Steve Rabin, Game AI Pro 3: Collected Wisdom of Game AI Professionals,International Standard Book.
-
[Orkin 06] Orkin, J. 2006. 3 states and a plan: The AI of F.E.A.R., Game Developers Conference, San Francisco, CA.
-
Joon Sung Park, Joseph C. O’Brien, Carrie J. Cai, Meredith Ringel Morris,Percy Liang, and Michael S. Bernstein. 2023. Generative Agents: Interactive Simulacra of Human Behavior.
-
Wang, Zihao et al. “Describe, Explain, Plan and Select: Interactive Planning with Large Language Models Enables Open-World Multi-Task Agents.” ArXiv abs/2302.01560 (2023): n. pag.
-
Lin J, Zhao H, Zhang A, et al. Agentsims: An open-source sandbox for large language model evaluation[J]. arXiv preprint arXiv:2308.04026, 2023.
-
Xi, Z., Chen, W., Guo, X., He, W., Ding, Y., Hong, B., Zhang, M., Wang, J., Jin, S., Zhou, E., Zheng, R., Fan, X., Wang, X., Xiong, L., Liu, Q., Zhou, Y., Wang, W., Jiang, C., Zou, Y., Liu, X., Yin, Z., Dou, S., Weng, R., Cheng, W., Zhang, Q., Qin, W., Zheng, Y., Qiu, X., Huan, X., & Gui, T. (2023). The Rise and Potential of Large Language Model Based Agents: A Survey. ArXiv, abs/2309.07864.