LLM-PySC2 项目概述

생성일: 2025년 1월 8일

답변에 사용된 모델 O1 by Chat01

질문

<p align="center"> <img src="docs/figures/llm_smac_demo1.gif" width="225"> <img src="docs/figures/llm_smac_demo3.gif" width="225"> <img src="docs/figures/llm_smac_demo2.gif" width="225"><br/> <img src="docs/figures/llm_pysc2_demo1.gif" width="225"> <img src="docs/figures/llm_pysc2_demo2.gif" width="225"> <img src="docs/figures/llm_pysc2_demo3.gif" width="225"><br/> <img src="docs/figures/llm_pysc2_demo4.gif" width="225"> <img src="docs/figures/llm_pysc2_demo5.gif" width="225"><br/> <i>Demos of LLM-Pysc2 with SMAC tasks</i> </p>

LLM-PySC2 - LLM StarCraft II Learning Environment

LLM-PySC2 is
NKU Robot Autonomy and Human-AI Collaboration Group and
NUDT Laboratory for Big Data and Decision's Python component of the StarCraft II LLM Decision Environment.
It wraps Deepmind's PySC2 Learning Environment API
in to a LLM energized Multi-Agent Decision Environment.
This is a collaboration between NKU and NUDT to develop StarCraft II into a rich environment for LLM research.
LLM-PySC2 provides an interface for LLM agents to interact with StarCraft 2,
getting textual/multimodal observations and dealing with textual actions.

We also make it possible for LLMs to make decisions in SMAC tasks, which make it possible to compare LLM with RL method.

Features

  1. Support for more than 5 series of mainstream LLMs;
  2. Macro decision-making and Micro operation available;
  3. Multi-Agent(even heterogeneous agent) collaboration, point-to-point communication, domain communication;
  4. Rich experimental tasks, consist of 24 llm_pysc2 experiments with 9 llm_smac tasks (more to be added);
  5. Support for parallel experiments, multi-agent multi-thread concurrently query;
  6. Diversified observational information, text observation, feature maps and StarCraft2 wiki data;
  7. Complete StarCraft2 action space, with support for nearly all kinds of unit skills/abilities;
  8. Automatic economic management in complete game;
  9. High quality logger and data recorder.

About

If you use the LLM-PySC2 environment or LLM-SMAC tasks in your research,
please cite our github pager or
LLM StarCraft II Pre-Print Paper after preprint paper published.
You can also contact us by e-mail [email protected] or [email protected].

Arxiv paper: https://arxiv.org/abs/2411.05348 (Citation: https://ui.adsabs.harvard.edu/abs/2024arXiv241105348L/exportcitation)

Quick Start Guide

Get StarCraft II

LLM-PySC2 depends on the full StarCraft II game and only works with versions that
include the API, which is 3.16.1 and above.

Linux

Follow Blizzard's documentation to
get the linux version. By default, LLM-PySC2 expects the game to live in
~/StarCraftII/. You can override this path by setting the SC2PATH
environment variable or creating your own run_config.

Windows/MacOS

Install of the game as normal from Battle.net. Even the
Starter Edition will work.
If you used the default install location LLM-PySC2 should find the latest binary.
If you changed the install location, you might need to set the SC2PATH
environment variable with the correct location.

LLM-PySC2 should work on MacOS and Windows systems running Python 3.8+,
but has only been thoroughly tested on Linux. We welcome suggestions and patches
for better compatibility with other systems.

Get LLM-PySC2

download the LLM-PySC2 code from our github page LLM-PySC2.

use pip install to initialize the environment:

shell
$ conda create --name YOUR_ENV_NAME python==3.9 $ conda activate YOUR_ENV_NAME $ pip install -e .

you can use mirrors like pip install -e . -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple to speed up downloading.

Get the maps

We have placed the required maps in the project folder:

text
llm_pysc2/maps/llm_pysc2 llm_pysc2/maps/llm_smac

You need to copy and paste these 2 folders into the Maps folder of the StarCraft2 program. Generally, the folder path is:

C:\Program Files (x86)\StarCraft II\Maps

and finally looks like:

text
C:\Program Files (x86)\StarCraft II\Maps\llm_pysc2 C:\Program Files (x86)\StarCraft II\Maps\llm_smac

If you used a custom path in installation, you may need to find the Map folder to finish the step.

Get llm api key

If you do not know how to get api_key, you can contact us to obtain a temporary gpt-3.5-turbo api_key with 2M tokens for free.

You need to write your api_key in ./llm_pysc2/agents/configs/config.ProtossAgentConfig before test the llm:

text
class ProtossAgentConfig(AgentConfig): def __init__(self): super(ProtossAgentConfig, self).__init__() self.race = 'protoss' self.model_name = 'gpt-3.5-turbo' self.api_base = 'YOUR_API_BASE' self.api_key = 'YOUR_API_KEY' ...

or set api_key like what we do in ./llm_pysc2/bin/experiment_llm_pysc2.py:

config.reset_llm(model_name, api_base, api_key)

if you do not have api_key but still want to test the environment,
you can set config.LLM_SIMULATION_TIME = 5 to simulate a 5-second response large model
and continue the tutorial below.

Test the environment

After specify your LLM api_key, api_base and model_name, you can run our experiments to test LLM and
both the llm_pysc2 tasks and llm-smac tasks:

shell
$ python -m llm_pysc2.bin.experiment_llm_pysc2 $ python -m llm_pysc2.bin.experiment_llm_smac

These two script will load gpt-3.5 energized agents and use pure text observation to make decisions.
If you want to use multimodal LLMs like gpt-4v, you can set config.ENABLE_IMAGE_RGB = True to
activate image observations.

Also, you can use --parallel parameter (or edit files in ./llm_pysc2/bin) to run several games at the same time:

shell
$ python -m pysc2.bin.agent --map pvz_task4_level1 --agent_race protoss --parallel 2 --agent llm_pysc2.bin.experiment_llm_pysc2.MainAgentLLMPysc2 $ python -m pysc2.bin.agent --map pvz_task4_level1 --agent_race protoss --parallel 4 --agent llm_pysc2.bin.experiment_llm_pysc2.MainAgentLLMPysc2

which may significantly improve experimental efficiency.

Experiments

We provided two series of experiment tasks:

text
(1) llm_pysc2 experiments: a series of pvz combat, with 8 different settings and 3 levels of difficult for each. (2) llm_smac experiments: same as original SMAC tasks, units control by LLM agent instead of RL agent.

You can run these experiments in ./llm_pysc2/bin/llm_pysc2 and ./llm_pysc2/bin/llm_smac.

llm_smac experiments

llm_smac experiments are original smac tasks, use the same map and setting of smac tasks. Consider that
the control of the Zerg and Terran is still ongoing, we will add more smac tasks in the future
(executable files in ./llm_pysc2/bin/llm_smac):

text
2s3z 3s5z 1c3s5z 3s_vs_3z 3s_vs_4z 3s_vs_5z 2c_vs_64zg 2s_vs_1sc 3s5z_vs_3s6z (more to be added in future version)

llm_pysc2 experiments

llm_pysc2 experiments contains 6 pvz combat with 3 level of difficulties, concentrate more attention to larger
scenarios and the use of unit skills, provide higher complexity and operability:

TaskDescriptionText-InputImage-InputMulti-AgentCommunication
task12 Adept harass zerg base✔ (can be disabled)
task23 Phoenix harass zerg base✔ (can be disabled)
task36 Stalker intercept airdrops✔ (can be disabled)
task412 Stalkers vs many zerg units✔ (can be disabled)
task52c3d4s12s vs many zerg units✔ (can be disabled)✔ (Isomorphic)✖ (can be enabled)
task61a6h4s12s vs many zerg units✔ (can be disabled)✔ (Isomorphic)✖ (can be enabled)
task71m3c3t6v12s vs many zerg units✔ (can be disabled)✔ (Heterogeneous)✔ (can be disabled)
task82wp8bg12s multiline attack✔ (can be disabled)✔ (Heterogeneous)✔ (can be disabled)

Each of them has three different difficulties. Simply, level-1 can be used for demo and method debug;
level-2 is a standard difficulty, can be used for policy training, and level-3 can be used as an experimental field
for trained method evaluating, which is quite difficult, and can be served as a good OOD evaluating environment.

More details can be seen in ./docs/llm_pysc2/experiments.md.

Customize your Agent/Tasks

Customize LLM Interaction Process

If you want to redefine a SubAgent's interaction process with the large model, you can redefine the query function of
a SubAgent. View relevant code of class Customized_LLMAgent(LLMAgent) in ./llm_pysc2/agents/llm_pysc2_agent.py:

text
class Customized_LLMAgent(LLMAgent) def query(self, obs) -> None:

Customize MainAgent

Main agent is used to interact with pysc2 and does not directly make decisions, so it is not recommended to modify it.
You can affect the main agent by modifying the config just like what we do in.

text
llm_pysc2/bin/experiment_llm_pysc2.py llm_pysc2/bin/experiment_llm_smac.py

Customize SubAgents

MainAgent is only an objects used for scheduling cameras, managing internal data and interacting with the env.
While SubAgents(of the MainAgent) query llm to obtain text actions, plays the role of decision maker.

SubAgent is configured in configurations(llm_pysc2/agents/configs).
For example, ./llm_pysc2/agents/configs/llm_smac/config_2s3z.py defines a MainAgent with only one sub agent named
CombatGroupSmac:

text
class ConfigSmac_2s3z(ProtossAgentConfig): def __init__(self): super(ConfigSmac_2s3z, self).__init__() ... self.AGENTS = { 'CombatGroupSmac': { 'describe': "Protoss military commander, controls units to fight against enemy. ", 'llm': {...}, 'team': [ {'name': 'Zealot-1', 'unit_type': [units.Protoss.Zealot], 'game_group': 1, 'select_type': 'group'}, {'name': 'Zealot-2', 'unit_type': [units.Protoss.Zealot], 'game_group': 2, 'select_type': 'group'}, {'name': 'Stalker-1', 'unit_type': [units.Protoss.Stalker], 'game_group': 4, 'select_type': 'group'}, ], 'action': { units.Protoss.Zealot: PROTOSS_BASIC_ACTION_SMAC, units.Protoss.Stalker: PROTOSS_BASIC_ACTION_SMAC, }, }, } ...

you can add more sub agent in your configuration if needed.

Customize SubAgent's UnitTeams

You can design agent's unit team in config.
In the example above, we showed a sub agent with 3 teams called 'Zealot-1', 'Zealot-2' and 'Stalker-1'.
You can redefine your agent teams if needed.

A team should consist of:

text
'name': any str 'unit_type': list, of pysc2 unit enum 'game_group': int, -1 to 9, -1 refers to do not add units to any game_group 'select_type': str, 'group' for group recall, 'select' for single select(mouse left click), 'select_all_type' for select screen units of same types(mouse double click)

More examples can be viewed in ./llm_pysc2/agents/configs.

Customize UnitTeam's action space

You can design team's action space in config.
In the example(ConfigSmac_2s3z) above, we showed a action space of CombatGroupSmac.
Where PROTOSS_BASIC_ACTION_SMAC shape as:

[{'name': 'Attack_Unit', 'arg': ['tag'], 'func': [(12, F.Attack_screen, ('queued', 'screen_tag'))]},]

and PROTOSS_BASIC_ACTION_SMAC2 shape as:

text
[{'name': 'Attack_Unit', 'arg': ['tag'], 'func': [(12, F.Attack_screen, ('queued', 'screen_tag'))]}, {'name': 'Move_Screen', 'arg': ['screen'], 'func': [(331, F.Move_screen, ('queued', 'screen'))]},]

Each action should consist of three parts:

text
'name': any str 'arg': list, either of [] / ['tag'] / ['screen'] / ['minimap'] / ['tag', 'screen'] / ['tag', 'minimap'] 'func': a list of triplet (pysc2_func_id, pysc2_func, args_type)

More examples can be viewed in ./llm_pysc2/agents/configs and ./llm_pysc2/lib/llm_actions.

Customize Observation Wrapper

You can design your own Observation Wrapper by redefining o_translator in ./llm_pysc2/lib/llm_observations.py.

Customize Action Recognizer

You can design your own Text Action Recognizer by redefining a_translator in ./llm_pysc2/lib/llm_actions.py.

Customize LLM Client

You can design your own LLM Client in llm_pysc2/lib/llm_client if needed.

Future Work

We have planed to try our best to add the following features before 2025/2/1:

text
(1) Support of Zerg control (2) Support of Terran control (3) Compatibility of classic RL algorithms

And more features before 2025/5/1:

text
(1) Full game experiments series1: in map Simple64, Simple96, Simple128 (2) Full game experiments series2: in map Ancient Cistern LE, Babylon LE, Gresvan LE

Note that this LLM-PySC2 is a preview version, and official version with far more features and better stability
will be open-sourced before 2025/7/1.

Contributors

Zongyuan Li (Main Contributor, Nankai University):
Framework design. Multi-Agent structure. Text observation generation. Text action recognition.
Communication. Experiments design. Prompt. Logger. Documents. Organize.

Runnan Qi, Yanan Ni, Lumin Jiang (National University of Defense Technology):
LLM Client. Multimodal LLM Client. Image observation generation. Documents.

Chang Lu, Xiaojie Xu, Pengfei Li, Yunzheng Guo, Zhe Ma (Nankai University):
Data recorder. Experiments evaluation. Game knowledge.

Kuihua Huang (National University of Defense Technology), Xian Guo, Xuebo Zhang(Nankai University):
Organize.

Thanks

LLM-PYSC2: STARCRAFT II LEARNING ENVIRONMENT FOR
LARGE LANGUAGE MODELS ∗†
Zongyuan Li1
, Yanan Ni2
, Runnan Qi2
, Lumin Jiang2
, Chang Lu1
, Xiaojie Xu1
,
Xiangbei Liu1
, Pengfei Li1
, Yunzheng Guo1
, Zhe Ma1
,
Xian Guo1,∗
, Kuihua Huang2,∗
, Xuebo Zhang1,∗
1 College of Artificial Intelligence, Nankai University
2 Laboratory for Big Data and Decision, National University of Defense Technology
ABSTRACT
This paper introduces a new environment LLM-PySC2 (the Large Language Model StarCraft II
Learning Environment), a platform derived from DeepMind’s StarCraft II Learning Environment
that serves to develop Large Language Models (LLMs) based decision-making methodologies. This
environment is the first to offer the complete StarCraft II action space, multi-modal observation
interfaces, and a structured game knowledge database, which are seamlessly connected with various
LLMs to facilitate the research of LLMs-based decision-making. To further support multi-agent
research, we developed an LLM collaborative framework that supports multi-agent concurrent queries
and multi-agent communication. In our experiments, the LLM-PySC2 environment is adapted to
be compatible with the StarCraft Multi-Agent Challenge (SMAC) task group and provided eight
new scenarios focused on macro-decision abilities. We evaluated nine mainstream LLMs in the
experiments, and results show that sufficient parameters are necessary for LLMs to make decisions,
but improving reasoning ability does not directly lead to better decision-making outcomes. Our
findings further indicate the importance of enabling large models to learn autonomously in the
deployment environment through parameter training or train-free learning techniques. Ultimately,
we expect that the LLM-PySC2 environment can promote research on learning methods for LLMs,
helping LLM-based methods better adapt to task scenarios.
1 Introduction
In 2017, the StarCraft II Learning Environment (SC2LE)[1] was developed by DeepMind and Blizzard Entertainment.
It is the first environment that enables various reinforcement learning (RL) agents to compete with each other in the
StarCraft II game, and promoted the emergence of decision-making methods such as QMix[2], Weighted QMIX[3],
MAPPO[4], and the household name AlphaStar[5]. However, RL-trained agents typically require a substantial amount
of data and prolonged interactions, but still lack generalization capabilities in most scenarios due to the task-relevant
reward function. Consequently, it is urgent to develop new decision-making methods at the present.
Additionally, impressive research efforts such as Stanford Town[6], LLM plays MineCraft[7] and the game of
Diplomacy[8] have demonstrated great potential in LLM-based decision-making in recent years. Considering that
large models exhibit greater interactivity, interpretability, and reasoning capabilities, it is quite natural to apply large
models in complex decision-making environments. However, there is no sufficiently comprehensive platform to support
research on LLM decision-making methods in complex environments. Notably, the mainstream platform SC2LE
environment does not yet support research on decision-making with large models.
In order to leverage the advantages of large models and circumvent the disadvantages of RL, researchers developed the
SC2 module into TextStarCraft II (TSC2)[9], enabling LLMs to interact with the StarCraft II environment for the first
time. However, there are some restrictions in the environment. The LLM based agent can not use micro-operations and
∗Corresponding author.
†Code is available at https://github.com/NKAI-Decision-Team/LLM-PySC2
arXiv:2411.05348v1 [cs.AI] 8 Nov 2024
Zongyuan Li et. al.
unit skills to defeat enemy units due to the scale-cropped discrete action space. While observation only contains unit
counts and upgrade status that are not sufficient for the implementation of complex strategies. What’s more, multi-agent
collaboration is not available because TSC2 is a single-agent framework.
To address these issues, we developed LLM-PySC2, an environment derived from SC2LE, based on PySC2 module.
This environment provides agents with comprehensive observations, including global information and agent-specific
local combat information (in text form or multimodal form) and a structured game knowledge database. We also
expanded the action space to the full StarCraft II action space, enabling agents to perform fine-grained operations and
unit skills. To support multi-agent research, we built a multi-agent framework with a communication system that allows
both point-to-point and domain communication.
In experiments, eight new scenarios were proposed. Unlike the SMAC[10] tasks, these tasks emphasize not only
micro-operations but also task understanding and macro-decision abilities. We tested nine mainstream LLMs in both the
SMAC tasks and the new proposed scenarios. The results indicate that pre-trained LLMs have possess decision-making
ability but lack the ability to make consistently effective decisions. Pre-trained LLMs without task-specific training may
be unable to analyze the key elements for achieving victory. They often fail to identify the important part of the game
knowledge for the most times, making mistakes in analysis or even dealing damage to allies sometimes.
In summary, there remains much to be done to raise the ability of LLMs in the domain of multi-agent decision making.
We hope that the LLM-PySC2 environment will advance research on LLM learning techniques, helping LLM-based
methods better adapt to task scenarios.
2 Related Works
2.1 Starcraft II
Starcraft II is a classic platform for evaluating algorithms. Specially, as a real-time strategy game, StarCraft II features a
high-dimensional partially observable state space and a huge continuous action space. With three species and more than
120 types of units, it is widely regarded as one of the most complex and challenging environments and is commonly
used for evaluating advanced decision-making methods.
To support the research of learning methods, DeepMind and Blizzard Entertainment developed SC2LE, a comprehensive
environment for RL research. This environment is designed to improve research in learning algorithms within complex
strategy games. It provides RL interfaces such as the observation, actions, and reward function, considered as one of the
most significant environments in the field of artificial intelligence.
Consequently, after the introduction of SC2LE, more and more StarCraft II environments have emerged. Among
those environments, SMAC[10] and PyMARL are the most famous. SMAC is a benchmark comprising 23 tasks
specifically designed for multi-agent RL, mostly focusing on distributed multi-agent decision-making. To evaluate
MARL algorithms, the SMAC team also developed PyMARL as their training platform. In the PyMARL framework,
over five algorithms are integrated, and the framework is gradually expanded into a multi-environment available RL
platform.
Overall, their work effectively advanced the research on multi-agent learning methods, made significant contributions
to the field of intelligent decision-making, and motivated us to develop an environment for LLM-based methods.
2.2 LLM Decision-Making and Text StarCraft II
In recent years, the decision-making ability of LLMs has started to attract attention. In 2023, an LLM-based agent
called the Ghost in Minecraft achieved 67.5% success in Minecraft’s diamond challenge. After that, Agent-Pro[11], an
LLM agent capable of using strategies like bluffing in Poker, was developed. Additionally, researchers deployed LLM
agents in Werewolf[12], a game with deception and counter-deception through communication, and developed LLM
agents in the game of Diplomacy, a game of collaboration and competition.
These works inspire researchers to develop LLM-based decision-making methods in games. As one of the most
famous real-time strategy games, StarCraft II was first developed into an LLM-interactable environment called TSC2.
This environment enables LLMs to make macro-decisions in StarCraft II and proves that LLMs can make decisions
and defeat build-in bots at level-4 in StarCraft-II. However, TSC2 does not support micro-operations on units and
multi-agent collaboration and faces limitations in observation and action space.
Under these circumstances, we constructed the LLM-PySC2 environment, aiming to solve these problems and provide
a new StarCraft-II environment. We also make our environment compatible with SMAC tasks, facilitating comparisons
with algorithms developed in the StarCraft environment.
2
Zongyuan Li et. al.
3 LLM-PySC2 environment
3.1 Framework
The LLM-PySC2 environment is built on the PySC2 module’s agent level. In Figure 1, the MainAgent plays the role of
controlling the camera, selecting units, collecting observations, and executing actions, while the LLM agent plays the
role of the actual decision maker that observes game situations, analyzes, and gives actions. Each LLM agent connects
to an LLM, getting a text or multimodal observations from a wrapper, querying the LLM in an independent thread, and
finally getting game analysis and actions.
LLMLLM-PySC2
MainAgent
pysc2.lib.actions.Functions.xx
obs
image
obs
agent info
relevant data
latest communication data
Starcraft2(PySC2)
obs1
obs2
obs3
obs4
analysis: xxcommu: xxactions: xx
systemprompt
example prompt
observed infoCommunication:
<MessageTo(Commander, ‘’‘xxxx’‘’)>
<MessageTo(Channel-1, ‘’‘xxxx’‘’)>
obs5
LLM-PySC2 MainAgent Opponent Agent
Build-inbot
RLAgent
AI Arenacamera
Actions:
Team Stalker-1:
<AttackUnit(0x1000a2001)>
<MoveScreen([54, 32])>
𝑡�� ��
𝑡�� ��
LLMAgent
Action Recognizer
��
�� ��
’ ��

𝑖� ��
Obs Wrapper
Game Wiki Data
Communication data
LLM Agent1
LLM Agent2
LLM Agent3
LLMLLMFigure 1: LLM-PySC2 framwork. In LLM-PySC2, the original PySC2 observation will transform into a text-form
observation. LLM-generated text action can be recognized and transformed into PySC2 action functions, enabling
LLMs to interact with the StarCraft II environment.
3.1.1 Interact with environment
An interaction step consists of two phases: auxiliary management and decision-making (and it consists of many game
steps). In the auxiliary management phase, no LLM will be involved. The MainAgent will control the PySC2 camera
and finish works like grouping newly trained units and managing idle workers to avoid excessive involvement of large
models in simple and repetitive labour.
Observations for each agent’s unit teams will be collected in the decision-making phase. After all teams’ observations
are collected, the agents use the Observation Wrapper to translate the structured observations into a text observation.
Then, all agents query remote or local LLMs concurrently, waiting until all the agents get the response.
After all agents get the response, they will use the Action Recognizer to detect valid actions and translate the text actions
into a structured form. Then, the MainAgent moves the camera to the same position when collecting observations and
executes each agent’s stored actions. After executing all the actions, the LLM-PySC2 environment will enter the next
interaction step and repeat the work mentioned above.
3.1.2 Multi-agent communication
Considering that LLMs have inherent advantages in interaction, we designed a communication system for the multiagent framework. In the communication system, agents communicate with each other using ’communication actions’, a
kind of text action similar to unit control actions shown in Figure 1.
3
Zongyuan Li et. al.
In the communication system. An LLM agent can send a message to another agent or send information to a channel.
If the message is sent to an agent, only the designated receiver can get the information. If the message is sent to a
channel, all agents that listen to the channel share the information. Through these communication actions, multi-agent
collaboration frameworks such as centralized decision-making and distributed decision-making can be easily built.
3.2 Observation
Observation is indispensable for decision making. Different types of information are necessary for agents with different
tasks. Roughly, we categorize observational information into two types: local observations for micro-level operations
and global observations for macro-level decision-making. These observations can be divided into text and image
observations according to form.
Valid Communicate Target: Agent XXX: ......
Team XXX: ...... Team XXX: ...... Query Message
System Prompt
Example Input
Example Output
Text Observation
Task Description
Game Time
Team unit info
Game Knowledge
Valid Actions
Valid Commu Target
Communication
Game Time: 00:50
Text Observation
Team XXX Info: ...... Team XXX Info: ......
Team Stalker-1 Info: Minimap Pos: ...... Controlled Units: ...... Nearby Ally Units: ...... Nearby Enemy Units: ...... Relevant Knowledge: Protoss.Stalker: ...... Zerg.Queen: ...... Zerg.Drone: ......
Valid Actions: Team Stalker-1: <Stop()>
<No_Operation()>
<Hold_Position()>
<Move_Minimap(minimap)>
<Move_Screen(screen)>
<Attack_Unit(tag)> Communication: From Agent XXX: ...... Tasks: Team Adept-1' task: Kill as much as enemy workers as possible.
Figure 2: Text observation for micro-operation LLM. Text observation is a part of the query message. It contains
many paragraphs, including team unit info, relevant game Knowledge, and valid actions. Semantic information is added
when the observation wrapper processes the original obs object.
3.2.1 Text Observation
Observation Wrapper for micro-operations This wrapper focuses on local observations. It provides detailed
information of controlled unit, nearby ally and nearby enemy unit for an agent. It extracts unit information from PySC2
obs object and the relevant game knowledge from the knowledge base. As shown in Figure 2 The text observation
generated by the wrapper includes game time, unit information, unit knowledge, valid actions, short-term memory,
communication data, and task descriptions. Agents using the wrapper are designed for micro-operations like fighting
with enemy units or constructing buildings in a specific position.
Observation Wrapper for macro-decisions This wrapper focuses on global observations. It provides deployment
information, unit counts, and upgrade status that are similar to the text observation of the TSC2 environment. For the
agent responsible for military deployment, text observation generated from the wrapper is used for supporting overall
strategy. For the agent responsible for development, the generated global observation will make the agent aware of the
current economy and technology situation, supporting the planning of future works of development.
3.2.2 Image Observation
In the complex environment of StarCraft II, relying solely on textual observations may prevent agents from fully
comprehending the battlefield dynamics. To enhance situational awareness, the LLM-PySC2 environment provides
multimodal observation. This feature enables multimodal large models to integrate visual information, leading to a
more accurate understanding of the situation. Figure 3 highlights two primary types of image observations: game image
observation and feature map observation. These visual inputs provide the agent with critical battlefield information,
facilitating tactical analysis and strategy development.
4
Zongyuan Li et. al.
Figure 3: Image observations. LLM-PySC2 directly extracts PySC2’s image observation, including the game image
and the feature map. It enhances these images by incorporating auxiliary lines, which assist LLMs in accurately
determining the coordinates of various positions. These images, interpretable by multimodal LLMs, provide decisionmakers with complex information, such as terrain layout and unit distribution on the map.
Figure 3 demonstrates the game image and feature map, which are directly extracted from the PySC2 interface. These
images are enhanced with auxiliary lines to provide coordinate information for large models. This approach enables
the agent to accurately perceive crucial battlefield elements, such as unit count and distribution, while also conveying
information that is challenging to express through text, such as terrain features and relative spatial relationships.
3.3 Action
In decision-making environments, the concept of "action" is pivotal to enable interactions between the agent and the
environment. In our framework, LLMs engage with the environment through text-based actions, which must adhere to a
specific format to be recognized and converted into PySC2 action functions. The process of processing text action into
PySC2 functions can be seen in Figure 4.
LLM Response
Analysis:
Team Adept-1 is already attacking a nearby Drone and
should continue this focus, while Team AdeptPhase-1 can
target another Drone nearby for maximum efficiency. Both
teams should remain aggressive to disrupt the enemy's
economy. Actions:
Team Adept-1:
<Attack_Unit(0x101340001)>
<Move_Screen([62, 64])>
Team AdeptPhase-1:
<Attack_Unit(0x1012c0001)>
<Move_Screen([66, 61])>
Team Adept-1:
<Attack_Unit(0x101340001)>
<Move_Screen([62, 64])>
Team AdeptPhase-1:
<Attack_Unit(0x1012c0001)>
<Move_Screen([66, 61])>
Text Action Recognize
pysc2.lib.actions.Attack_screen('now', [40, 47])
pysc2.lib.actions.Move_screen('queued', [62, 64])
pysc2.lib.actions.Attack_screen('now', [48, 51])
pysc2.lib.actions.Move_screen('queued', [66, 61])
0x101340001
0x1012c0001
unit tag unit positionGenerate Action Functions
Figure 4: Text action recognition. The default action recognizer recognizes text actions by searching the "Actions"
part in LLM’s response, extracting action names and arguments, searching for corresponding PySC2 functions, and
generating the callback form of the function.
Text Actions These actions are expressed in a syntax that is intuitive and descriptive, allowing the LLM to comprehend
the intended operation without additional context. A standard text action is encapsulated in angle brackets and several
arguments, shaped as <ActionName()>, <ActionName(arg0)>, or <ActionName(arg0, arg1)>. The arguments can
represent various elements, such as a unit tag, a screen coordinate, or a minimap position, allowing these actions to
encompass the complete continuous action space of PySC2.
5
Zongyuan Li et. al.
In the decision-making phase, LLM will be informed of currently available actions, such as <Attack_Unit(tag)>,
<Move_Screen(screen)> and <Select_Unit_Attack_Unit(tag, tag)>. The LLM can generate actions like <Attack_Unit(0x100030001)> or <Move_Screen([23, 37])> according to observed information and its purpose. If LLM
generated multiple text actions, the first action will be executed immediately, and the remaining actions will be added to
the action sequence waiting for execution.
Action Space All kinds of actions in PySC2 are available in our environment, however, each agent does not have to
face all the actions of its race. In our environment, the action space is agent-specific, allowing each agent to define a
unique set of actions. For the agent that controls units such as Stalkers, the action space consists of text actions like
<Stop()>, <No_Op()>, <Move_Screen(screen)>, <Move_Minimap(minimap)>, <Attack_Unit(tag)>, and do not consist
of actions like training units or research.
4 Experiments
4.1 Experiment Scenarios
To facilitate research in LLM-based decision-making, we have provided two sets of experiments: LLM-SMAC tasks and
LLM-PySC2 tasks. The LLM-SMAC tasks are the same as standard SMAC experiments, which serve as an excellent
bridge for comparing with RL-based methods. LLM-PySC2 tasks are new scenarios, which, compared to the SMAC
tasks designed specifically for micro-operations, place more emphasis on the large model’s ability to understand the
task scenario and make macro-level decisions.
4.1.1 LLM-SMAC tasks
LLM-SMAC tasks share the same settings as the original SMAC tasks. These tasks initialize units for both sides
and automatically raise attacks for enemy units. In these scenarios, the key to victory lies in concentrating firepower,
controlling combat distance, and, sometimes, in interaction frequency. They are good scenarios for comparing the
training data efficiency with RL-based methods but not good scenarios for utilizing the multitasking and macro
decision-making capabilities of LLMs.
4.1.2 LLM-PySC2 tasks
LLM-PySC2 tasks are the newly proposed experiment scenarios, a task group that tests agents’ situation analysis
capabilities, planning abilities, the application of knowledge, communication, and collaboration. Some of the tasks are
shown in Figure 5
(d) Task4: Mid scale combat (e) Task5: Large scale combat (type1)
(a) Task1: 2 Adept harass (b) Task2: 3 Pheonix harass (b) Task3: Intercept enemyairdrops
(f) Task6: Large scale combat (type2)
Figure 5: LLM-PySC task group. The LLM-PySC task group contains eight tasks, with three difficulties for each
task. Compared to SMAC tasks, they place more emphasis on macro decision-making, situation analysis, and skill
use. These scenarios are common in professional competitions. Winning these small tasks is beneficial for winning
complete games in the future.
6
Zongyuan Li et. al.
In these tasks, LLMs need to plan an infiltration route into the enemy base and kill enemy workers, or use unit skills to
implement specific tactics in a battle. In addition, these tasks are more suitable for researching multi-agent collaboration
methods, and implementing centralized or distributed decision-making for LLMs.
There are eight tasks in the LLM-PySC2 task group. Half of the task scenarios are single-agent decision-making
scenarios (from tasks 1 to 4), where one LLM agent controls multiple units, while the other half (from tasks 5 to 8)
tests the cooperation between agents, with multiple agents controlling multiple units with different tactical roles. In
LLM-PySC2 task group, image observation and multi-agent communication are available and can be easily disabled if
needed.
To avoid the situation where methods in SMAC can always reach the 100% winning rate of most tasks, we set three
different difficulty levels for our experiment group. From level 1 to level 3, the forces of the enemy gradually increase.
At a higher level, more units or upgrades will be added to the enemy side, ensuring these tasks can still be effective
even after the LLM-based decision-making methods have been well developed.
4.2 Experiment Results
To facilitate subsequent research, we tested the decision-making ability of various large models. All experiments were
conducted in StarCraft II of Version 5.0.13 (92440), LLM-PySC2 v0.1. We recorded a ratio of resources of the killed
unit over the dead unit (K/D rate) and the winning rate (WR, i.e. task completion rate). The combination of K/D rate
and WR reflects the performance of LLM in decision-making scenarios.
In the LLM-PySC2 environment, we provide series of LLMs, such as GPT-3, GPT-4, GPT-o1, GLM-4, Claude-3,
Llama-3.1. We tested some representative models among them, tested the performance of models with different
reasoning abilities in decision-making tasks (GPT-3.5, GPT-4o-mini, GPT-4o), and tested the performance of models
with different parameters based on the same architecture (Llama3.1-8b, Llama3.1-70b, Llama3.1-405b).
All experiments use the default configuration of the open-sourced codes. As a benchmark, we do not specially design
prompts to promote decision quality or instruct the LLMs to obtain victories, and all the LLMs are not fine-tuned in the
LLM-PySC2 environment. Results show that large models can make decisions and generate text actions in the correct
form. However, when the task is complex enough or requires a lot of micro-operations, large models may not perform
well, suggesting that training or other technical methods are necessary for improving their decision quality.
4.2.1 Experiment Results in LLM-SMAC tasks
In the LLM-SMAC tasks, we conducted 20 repeated experiments for 6 LLMs in each scenario. For scenarios where
decisions were made by GPT-3.5-turbo, we raised the number to 50 due to its good concurrency support and friendly
cost. In these experiments, all large models used textual observations. This setting is completely sufficient for scenarios
other than 2c_vs_64zg, as they basically did not need to utilize terrain information. Results are shown in Table 1.
Table 1: Kill/Death Rates and Winning Rates of LLMs in LLM-SMAC Tasks.
Model Name 2s3z 3s5z 1c3s5z 3s5z_vs_3s6z 2s_vs_1sc 2c_vs_64zg 3s_vs_3z
Gpt-3.5-turbo 0.60 (22%) 0.43 (4%) 0.91 (44%) 0.29 (0%) 0.01 (2%) 0.52 (0%) 0.05 (0%)
Gpt-4o-mini 0.66 (20%) 0.39 (0%) 1.01 (50%) 0.29 (0%) 0.00 (0%) 0.54(0%) 0.09 (0%)
Gpt-4o 0.76 (20%) 0.47 (0%) 0.80 (30%) 0.35 (0%) 0.00 (0%) 0.56 (0%) 0.15 (0%)
Claude3-haiku 0.58 (5%) 0.48 (0%) 0.48 (0%) 0.32 (0%) 0.00 (0%) 0.52 (0%) 0.10 (0%)
Llama3.1-8b 0.19 (0%) 0.23 (0%) 0.18 (0%) 0.14 (0%) 0.00 (0%) 0.49 (0%) 0.00 (0%)
Glm-4-plus 0.81(25%) 0.46 (0%) 0.47 (0%) 0.33 (0%) 0.00 (0%) 0.54 (5%) 0.15 (0%)
We found that, although large models can analyze the observation information and output actions in the correct form,
they performed poorly in SMAC tasks. On the one hand, due to LLM hallucinations and the lack of task-specific
knowledge, they can not deduce the principle that concentrated fire is the key to victory. On the other hand, even if
the observation provided the knowledge that Zealots have a higher attack efficiency than Stalkers, the large models
sometimes still chose to attack the enemy Stalkers first in tasks like 2s3z and 3s5z.
7
Zongyuan Li et. al.
4.2.2 Experiment Results in LLM-PySC2 tasks
The same as the experiments in SMAC, we conducted 20 repeated experiments for each large model in each scenario
and 50 for GPT-3.5-turbo. Considering that all models cannot complete the multi-line attack in Task 8, we only listed
the data from Task 1 to Task 7. Results are shown in Table 2 and 3.
Table 2: Kill/Death Rates and Winning Rates of Gpt-3.5-turbo in LLM-PySC2 Tasks (level-1/2/3).
Task level task1 task2 task3 task4 task5 task6 task7
task-level-1 1.23 (58%) 0.13 (4%) 6.63 (38%) 0.38 (0%) 0.61 (8%) 0.28 (0%) 1.29 (72%)
task-level-2 0.56 (5%) 0.04 (0%) 3.31 (5%) 0.34 (0%) 0.52 (0%) 0.20 (0%) 0.98 (25%)
task-level-3 0.39 (0%) 0.05 (0%) 1.99 (0%) 0.31 (0%) 0.40 (0%) 0.26 (0%) 0.62 (0%)
In table 2, we tested Gpt-3.5-turbo’s performance in all the levels of each task. These data can serve as benchmark values
for future research. These three levels of difficulty not only serve as validation scenarios for developed decision-making
methods in the future but can also be applied to out-of-distribution (OOD) tasks, such as training on level 2 and
validating on level 3.
Table 3: Kill/Death Rates and Winning Rates of LLMs in LLM-PySC2 Tasks (level-1).
Model Name task1 task2 task3 task4 task5 task6 task7
Gpt-3.5-turbo 1.23 (58%) 0.13 (4%) 6.63 (38%) 0.38 (0%) 0.61 (8%) 0.28 (0%) 1.29 (72%)
Gpt-4o-mini 1.67 (70%) 0.16 (0%) 3.46 (0%) 0.39 (0%) 0.62 (20%) 0.30 (0%) 1.02 (40%)
Gpt-4o 2.27 (80%) 0.16 (10%) Inf (100%) 0.46 (0%) TBD TBD TBD
Gpt-o1-mini 1.36 (60%) 0.04 (0%) TBD TBD TBD TBD TBD
Claude3-haiku 2.19 (90%) 0.19 (10%) 5.25 (40%) 0.34 (0%) 0.75 (25%) 0.33 (0%) 0.93 (45%)
Llama3.1-8b 0.28 (5%) 0.12 (5%) 14.9 (75%) 0.18 (0%) 0.48 (5%) 0.14 (0%) 0.71 (25%)
Llama3.1-70b 0.36 (15%) 0.14 (0%) 58.9 (95%) 0.33 (0%) 0.59 (15%) 0.31 (0%) 0.71 (30%)
Llama3.1-405b 0.70 (30%) 0.10 (0%) 3.0k(100%) 0.28 (0%) 0.56 (10%) 0.32 (0%) 0.47 (15%)
Glm-4-plus 0.78 (30%) 0.21 (5%) 153 (100%) 0.38 (0%) 0.60 (10%) 0.30 (0%) 1.03 (55%)
Based on the data presented in Table 3, two conclusions can be extrapolated. First, adequate parameters for the large
model are necessary for decision-making. Llama-3.1-8b, the model with minimum parameters, performs nearly the
worst among all the models we tested, while the 70b and 405b models perform better than the 8b model. Second,
improving reasoning ability does not lead to a linear improvement in decision-making ability. Although GPT-4o
performed the best in most experiments, it still had a zero winning rate in some tasks that can easily be completed,
such as task 4. These results lead to a conclusion: pre-trained large models cannot directly undertake complex
decision-making tasks, and learning in deployment scenarios is almost inevitable.
5 Discussion
In the experiments, we found that there are several deficiencies in LLM-based decision making.
Hallucinations. Hallucination is the first problem that leads to bad decisions. Sometimes, LLMs confuse screen
coordinates with minimap coordinates (as shown in Figure 6), or use unmentioned actions in the Valid Actions part
of the observation. Sometimes, LLMs even damage teammate units. Hallucination has become an urgent problem in
LLM-based decision making.
Poor knowledge utilization. Large models generally exhibit a significant deficiency in leveraging game-related
knowledge. In task 2, game knowledge shows that Phoenix’s GravitonBeam ability will prevent the unit from moving
and attacking. However, this ability is still overused, failing to obtain victories in task 2. In task 5, even the LLM knows
the PurificationNova of Disruptor deals a lot of damage, they use the skill on injured units, causing a large amount of
spillover damage.
8
Zongyuan Li et. al.
Game Info: ...... Team HighTemplar-1 Info:
Team minimap position: [23, 31]
Controlled Team Units:
Unit: HighTemplar Tag: 0x100240001 ScreenPos: [66, 69] ...... Unit: HighTemplar Tag: 0x101dc0001 ScreenPos: [66, 64] ......
......
...... Tasks: Team HighTemplar-1' task: Go to minimap coordinate [32, 32]. Now, start generating your analysis and actions:
Analysis:
Team HighTemplar-1 consists of several High Templars, each with full health andenergy. Our task is to move to the specified minimap coordinate [32, 32]. Beforeproceeding, we should prepare to engage any nearby enemy units with a Psionic
Storm, if they are in range. However, we currently have no information about nearby
enemy units, so we'll focus on reaching the destination while maintaining our ability toengage if necessary. Actions:
Team HighTemplar-1:
<Ability_PsiStorm_Screen([32, 32])>
<Move_Minimap([32, 32])>
<No_Operation()>
screen [32, 32] minimap [32, 32]
<Ability_PsiStorm_Screen([32, 32])>
Query
LLM��
��
Figure 6: LLM hallucination in decision-making. This is an example that LLM confuse the screen coordinates and
minimap coordinates, wasting a PsiStrom skill and 75 energy. This is just an instance of the hallucination of large
models. In fact, there are many other forms of expression, such as attacking teammates and incorrectly choosing priority
targets.
Poor understanding of the world. Lack of world understanding is a kind of lack of knowledge. Pre-trained LLMs are
generally not trained in decision-making tasks. They do not know how to win in each task. In task 4, for example, the
large model should use Stalker’s Blink ability to transfer injured units to the rear. However, this ability is rarely used,
resulting in the unit’s death and a zero winning rate in task 4, even though the LLM is told that Blink is commonly used
to pursue the enemy or retreat injured units.
Low quality collaboration. In the multi-agent tasks like task 5 to 8, LLM agents should collaborate with others and
defeat the enemy together. However, we found it difficult for these agents to reasonably allocate targets, coordinate
attack timing, and coordinate retreat timing, no matter whether they collaborate with or without a leadership/commander.
How to improve the collaboration performance of LLM agents is important in building a high-level multi-agent
decision-making system.
These issues hinder the application of LLMs in decision-making scenarios. Fortunately, there are many ways to improve
the decision-making ability of large models. For example, directly providing knowledge to LLMs may directly improve
their ability. However, providing LLMs knowledge or precisely annotated datasets usually demands quite a lot of
resources. Self-supervised learning is still the most attractive way to enhance decision-making ability, either through
reward-based or reward-free methods (such as LLM reflection), and either through parameter training or training-free
techniques.
6 Conclusion
In this paper, we introduce a new environment for LLM decision-making, the first environment that accommodates
continuous PySC2 actions, and the first LLM StarCraft II environment with a multi-agent framework and communication
system. In experiments, we test mainstream LLMs’ performance in both the LLM-SMAC and LLM-PySC2 task groups,
among which the LLM-PySC2 task group is a brand-new experimental scenario that we designed for large models.
Results of baseline tests show that LLMs can make decisions, generating actions in the correct form. Still, the decision
quality is relatively low and there are several problems like hallucinations, poor utilization of game knowledge, and
lack of world understanding. Results indicate that learning in the deployment environment is necessary for LLM-based
decision-making. We hope the LLM-PySC2 environment can promote research on LLM learning methods, helping
LLM-based decision-making methods better adapt to task scenarios.
9
Zongyuan Li et. al.
References
[1] Oriol Vinyals, Tim Ewalds, Sergey Bartunov, Petko Georgiev, Alexander Sasha Vezhnevets, Michelle Yeo, and
Demis Hassabis. Starcraft ii: A new challenge for reinforcement learning. arXiv preprint arXiv:1708.04782,
2017.
[2] Tabish Rashid, Mikayel Samvelyan, Christian Schroeder de Witt, Gregory Farquhar, Jakob Foerster, and Shimon
Whiteson. QMIX: Monotonic Value Function Factorisation for Deep Multi-Agent Reinforcement Learning. arXiv
e-prints, page arXiv:1803.11485, March 2018.
[3] Tabish Rashid, Gregory Farquhar, Bei Peng, and Shimon Whiteson. Weighted QMIX: Expanding Monotonic Value
Function Factorisation for Deep Multi-Agent Reinforcement Learning. arXiv e-prints, page arXiv:2006.10800,
June 2020.
[4] Chao Yu, Akash Velu, Eugene Vinitsky, Jiaxuan Gao, Yu Wang, Alexandre Bayen, and Yi Wu. The Surprising
Effectiveness of PPO in Cooperative, Multi-Agent Games. arXiv e-prints, page arXiv:2103.01955, March 2021.
[5] Oriol Vinyals, Igor Babuschkin, Wojciech M. Czarnecki, Michaël Mathieu, Andrew Dudzik, Junyoung Chung,
David Choi, Richard Powell, Timo Ewalds, Petko Georgiev, Junhyuk Oh, Dan Horgan, Manuel Kroiss, Ivo
Danihelka, Aja Huang, L. Sifre, Trevor Cai, John P. Agapiou, Max Jaderberg, Alexander Sasha Vezhnevets,
Rémi Leblond, Tobias Pohlen, Valentin Dalibard, David Budden, Yury Sulsky, James Molloy, Tom Le Paine,
Caglar Gulcehre, Ziyun Wang, Tobias Pfaff, Yuhuai Wu, Roman Ring, Dani Yogatama, Dario Wünsch, Katrina
McKinney, Oliver Smith, Tom Schaul, Timothy P. Lillicrap, Koray Kavukcuoglu, Demis Hassabis, Chris Apps,
and David Silver. Grandmaster level in starcraft ii using multi-agent reinforcement learning. Nature, 575:350 –
354, 2019.
[6] Joon Sung Park, Joseph C. O’Brien, Carrie J. Cai, Meredith Ringel Morris, Percy Liang, and Michael S. Bernstein.
Generative Agents: Interactive Simulacra of Human Behavior. arXiv e-prints, page arXiv:2304.03442, April
2023.
[7] Xizhou Zhu, Yuntao Chen, Hao Tian, Chenxin Tao, Weijie Su, Chenyu Yang, Gao Huang, Bin Li, Lewei Lu,
Xiaogang Wang, et al. Ghost in the minecraft: Generally capable agents for open-world environments via large
language models with text-based knowledge and memory. arXiv preprint arXiv:2305.17144, 2023.
[8] Meta Fundamental AI Research Diplomacy Team (FAIR)†, Anton Bakhtin, Noam Brown, Emily Dinan, Gabriele
Farina, Colin Flaherty, Daniel Fried, Andrew Goff, Jonathan Gray, Hengyuan Hu, et al. Human-level play in the
game of diplomacy by combining language models with strategic reasoning. Science, 378(6624):1067–1074,
2022.
[9] Anonymous. Large language models play starcraft ii: Benchmarks and a chain of summarization approach. arXiv
preprint arXiv:2312.11865, 2023. Accessed: 2024-10-21.
[10] Mikayel Samvelyan, Tabish Rashid, Christian Schroeder de Witt, Gregory Farquhar, Nantas Nardelli, Tim GJ
Rudner, Chia-Man Hung, Philip HS Torr, Jakob Foerster, and Shimon Whiteson. The starcraft multi-agent
challenge. In Proceedings of the 18th International Conference on Autonomous Agents and MultiAgent Systems
(AAMAS), pages 2186–2188, 2019.
[11] Wenqi Zhang, Ke Tang, Hai Wu, Mengna Wang, Yongliang Shen, Guiyang Hou, Zeqi Tan, Peng Li, Yueting
Zhuang, and Weiming Lu. Agent-pro: Learning to evolve via policy-level reflection and optimization. arXiv
preprint arXiv:2402.17574, 2024.
[12] Yuzhuang Xu, Shuo Wang, Peng Li, Fuwen Luo, Xiaolong Wang, Weidong Liu, and Yang Liu. Exploring large
language models for communication games: An empirical study on werewolf. arXiv preprint arXiv:2309.04658,
2023.
10
现在请你结合论文内容,理解这个项目

사고

思考,持续 几秒

답변

了解 LLM-PySC2 项目

LLM-PySC2 是一个基于 Python 的 StarCraft II 学习环境,旨在将大型语言模型(LLMs)集成到 StarCraft II 的多智能体决策环境中。该项目由南开大学机器人自治与人机协作团队(NKU Robot Autonomy and Human-AI Collaboration Group)与国防科技大学大数据与决策实验室(NUDT Laboratory for Big Data and Decision)合作开发。以下是对该项目的详细理解:

项目背景

  • StarCraft II 学习环境(SC2LE):由 DeepMind 和暴雪娱乐开发,主要用于强化学习(RL)研究,支持复杂策略游戏中的算法评估。
  • LLM 的兴起:近年来,大型语言模型在交互性、可解释性和推理能力方面表现出色,激发了将其应用于复杂决策环境的兴趣。然而,现有的 SC2LE 并未充分支持 LLM 的应用。

LLM-PySC2 的目标

  • 集成 LLM:将 DeepMind 的 PySC2 API 包装成一个支持 LLM 的多智能体决策环境,使 LLM 能够通过文本或多模态观察与 StarCraft II 进行交互,并处理文本动作。
  • 扩展功能:支持 SMAC(StarCraft Multi-Agent Challenge)任务,使得 LLM 与 RL 方法之间的比较成为可能。

主要特性

  1. 多种主流 LLM 支持:支持超过五种主流的大型语言模型。
  2. 宏观决策与微观操作:同时支持宏观策略制定和微观单位操作。
  3. 多智能体协作:支持多智能体(包括异构智能体)协作、点对点通信和域通信。
  4. 丰富的实验任务:包含 24 个 llm_pysc2 实验和 9 个 llm_smac 任务,并计划持续增加。
  5. 并行实验支持:支持并行运行多个实验,提高实验效率。
  6. 多样化的观察信息:提供文本观察、特征图和 StarCraft II 维基数据等多种观察形式。
  7. 完整的动作空间:支持 StarCraft II 中几乎所有类型的单位技能和能力。
  8. 自动经济管理:在完整游戏中自动管理经济。
  9. 高质量的日志记录:提供完善的日志和数据记录功能。

实验设计与结果

  • 实验任务

    • LLM-SMAC 任务:与原始 SMAC 任务相同,适合比较 RL 方法。
    • LLM-PySC2 任务:新设计的实验任务,强调 LLM 的任务理解和宏观决策能力,包括八个不同的 PvZ(Protoss vs Zerg)战斗任务,每个任务有三个难度级别。
  • 实验结果

    • LLM-SMAC 任务:尽管 LLM 能生成正确格式的动作,但在决策质量上表现不佳,无法有效集中火力或优先攻击高效单位,导致较低的胜率。
    • LLM-PySC2 任务:较大的模型(如 GPT-4o 和 Llama3.1-405b)在某些任务中表现较好,但整体上 LLM 在复杂任务和需要大量微观操作时仍表现不足,提示需要在部署环境中进行进一步的训练或优化。

存在的问题

  1. 幻觉(Hallucinations):LLM 有时会混淆屏幕坐标和小地图坐标,或使用未提及的动作,甚至对队友单位造成伤害。
  2. 知识利用不足:LLM 在利用游戏相关知识方面存在显著不足,无法有效应用技能或策略。
  3. 世界理解欠缺:缺乏对任务场景的深刻理解,无法制定有效的策略。
  4. 协作质量低:在多智能体任务中,LLM 代理难以合理分配目标、协调攻击和撤退时机。

未来工作

  • 短期目标(截至 2025 年 2 月)

    1. 支持 Zerg 和 Terran 的控制。
    2. 兼容经典的 RL 算法。
  • 长期目标(截至 2025 年 5 月)

    1. 在简单、中等和复杂地图(如 Simple64、Ancient Cistern LE 等)上进行全面游戏实验。
  • 正式版本计划:计划在 2025 年 7 月前开源更稳定、功能更完善的正式版本。

结论

LLM-PySC2 作为一个新型的环境平台,填补了将大型语言模型应用于复杂多智能体决策环境的空白。尽管当前 LLM 在决策质量和协作能力上存在不足,但通过进一步的训练和优化,有望显著提升其在 StarCraft II 等复杂环境中的表现。项目团队希望通过开源和社区合作,推动基于 LLM 的决策方法研究,促进其在实际任务场景中的适应性和效果。

引用与联系方式

贡献者

项目由南开大学和国防科技大学的多位研究人员共同开发,涵盖框架设计、LLM 客户端开发、数据记录、实验评估等多个方面。


总结:LLM-PySC2 是一个创新的项目,旨在将大型语言模型应用于 StarCraft II 的复杂决策环境中,通过多智能体协作和丰富的实验任务,探索 LLM 在实时策略游戏中的潜力与挑战。尽管当前存在一些技术难题,但其开源和持续优化的计划为未来的研究和应用提供了广阔的空间。

질문

我在这个环境上做了Visual-CoT的工作,请你理解这个工作。
Visual-CoT: A Visual Guided Chain of Thought Framework
for Fine-grained Control in StarCraft II Actions
Yanan Nia∗
, Runnan Qia
, Zongyuan Lib
, Kuihua Huanga
, Lumin Jianga
, Xiaojie Xub
,
Guo Xianb
, and Xuebo Zhangb
aLaboratory for Big Data and Decision, National University of Defense Technology, Changsha,
China
bCollege of Artificial Intelligence, Nankai University, Tianjin, China
ABSTRACT
In recent years, large language models (LLMs) have made significant progress in the field of natural language
processing. However, fine-grained action control in complex environments remains a significant challenge. To
address this issue, we propose a framework called Visual-CoT (Visual guided Chain of Thought), which aims to
enhance the ability of LLMs to perform fine-grained action control in complex strategy games such as StarCraft
II. This framework integrates visual information with the chain of thought, allowing visual data to seamlessly
interact with the reasoning and decision-making processes of LLMs. We implement Visual-CoT on the LLM￾PySC2 environment (the Large Language Model StarCraft II Learning Environment) and validate it on a map
featuring high-ground terrain information, simulating a scenario where one Colossus faces thirty-two Zerglings.
Experimental results show that the Visual-CoT framework improves the LLM’s win rate to 45% (winning 9 out
of 20 games), significantly enhancing fine-grained control and precise action execution capabilities. The code is
open-sourced and available at https://github.com/Flycat-Tom/Visual-COT.
Keywords: large language models, Visual-CoT, fine-grained action control, StarCraft II, strategy games

  1. INTRODUCTION
    LLMs have achieved remarkable success in the fields of natural language processing and complex decision-making.
    For instance, models such as the Generative Pre-trained Transformer (GPT) series1 and Large Language Model
    Meta AI(LLaMA)2 have demonstrated outstanding performance in language generation, knowledge reasoning,
    and problem-solving. With the development of multimodal large language models (such as GPT-4),3
    these models
    have begun to integrate textual and visual information, significantly enhancing their perception and decision￾making capabilities.4–6 However, in complex strategy games, particularly in scenarios that require fine-grained
    action control, LLMs still face significant challenges.7 These games demand that agents extract critical features
    from multimodal information and formulate and adjust strategies in real time. Even for multimodal LLMs,
    the integration of visual information is not yet sufficient to meet the demands of real-time decision-making
    in dynamic environments, which limits their ability in spatial understanding and environmental perception.
    Therefore, deeply integrating visual information into the decision-making process of LLMs to enhance their
    performance in complex tasks has become an urgent problem to address.
    In the absence of visual guidance, LLMs exhibit limitations in understanding physical laws and causal relation￾ships.8 Additionally, they struggle to perform fine-grained action control tasks that require visual information
    support. For instance, even advanced multimodal models, such as GPT-4, still face difficulties in fully interpret￾ing visual features in complex scenarios, especially when real-time reasoning is required.9
    In strategic scenarios
    involving complex terrains (e.g., high ground and low ground) and enemy-allied distributions, the lack of effec￾tive visual information integration hampers the model’s ability to accurately interpret key visual elements on
    ∗Corresponding author
    Further author information: (Send correspondence to Yanan Ni)
    Emails: {niyanan, qirunnan13579, jlm_mz, khhuang}@nudt.edu.cn, {2120230524, 2120220490, guoxian, zhangx￾uebo}@mail.nankai.edu.cn
    the map, such as the relative positions of units, advantageous terrain distributions, and threat zones of enemy
    forces. This information deficit directly affects the precision and effectiveness of strategy generation. To address
    this issue, we propose the Visual-CoT framework, which integrates image inputs with Chain of Thought(CoT)
    prompting techniques. This approach seamlessly embeds visual information into the reasoning and decision￾making processes of LLMs, thereby mitigating the inadequacies in their understanding of visual information in
    complex strategic tasks.
    The main contributions of this study are summarized as follows:
    Proposed the Visual-CoT framework: Innovatively combined visual guidance with CoT reasoning to
    enhance the fine-grained action control capabilities of large language models in complex strategy games, providing
    in-depth reasoning and logical support for decision-making.
    Validated effectiveness on the LLM-PySC2 environment: Designed a complex scenario featuring a
    Colossus versus 32 Zerglings on a specialized map, demonstrating the critical role of visual information in strategy
    generation and action control, and thoroughly validated the framework through extensive experiments.
    Achieved significant performance improvements: Experimental results showed that models employing
    the Visual-CoT framework achieved substantial improvements across multiple metrics, including win rate, unit
    operation precision, and tactical planning capabilities, with the win rate increasing from 0% to 45%, highlighting
    the advantages of integrating visual guidance with CoT reasoning.
    The remainder of this paper is organized as follows: Section 2 reviews related work. Section 3 outlines the
    Visual-CoT framework. Section 4 describes the methodology. Section 5 presents the experiments and results.
    Finally, Section 6 concludes the paper with future directions.
  2. RELATED WORK
    2.1 Recent Advances in LLM Applications for Game AI
    In recent years, LLMs have made significant progress in their application to game AI. In 2023, the ”Ghost in the
    Minecraft” agent, based on LLMs, used a task decomposition approach to achieve a 67.5% success rate in the
    ”Diamond Challenge” of Minecraft.10 This research laid the foundation for subsequent efforts to apply LLMs
    in decision-making across other game scenarios. For example, in the open-world game Red Dead Redemption
    2, an agent called CRADLE,11 which integrates video input, was proposed to construct and update the game’s
    skill library. Other studies have explored using LLMs to master advanced strategies in games with incomplete
    information, such as poker and blackjack.12 LLMs have also been successfully deployed in the strategy game
    Diplomacy to drive decision-making and strategic reasoning.13
    In the realm of real-time strategy (RTS) games, TextStarCraft II14 combined the complexity of StarCraft II
    with LLMs, using a text adapter to interact with the game environment. However, this system faced limitations in
    its action space and single-agent design. To address these challenges, the LLM-PySC2 environment introduced
    RGB images and a richer action space, thereby advancing research in complex strategy decision-making and
    micro-management control.15
    2.2 Visual Guided Chain of Thought Method
    The CoT method enhances the logical reasoning capabilities of LLMs in complex tasks by guiding the model
    through step-by-step reasoning.16 However, traditional CoT methods face limitations in scenarios requiring
    visual information for reasoning. Studies have demonstrated that combining multimodal information with CoT
    can significantly improve the complex reasoning capabilities of LLMs.17
    To improve these limitations, we propose a Visual-CoT method, which embeds visual information into the
    CoT framework. By integrating visual elements into the reasoning chain, our approach empowers the model with
    stronger scene understanding and decision optimization capabilities, achieving deep integration of linguistic and
    visual information.
    2.3 Introduction to the LLM-PySC2 environment
    The LLM-PySC2 environment is a research environment based on StarCraft II, designed to investigate the per￾formance of LLMs in complex decision-making scenarios. The environment provides a diverse set of observation
    interfaces, including global information, localized combat data, and a structured game knowledge database.
    These observations can be presented in textual or multimodal formats.
    The environment supports an expanded and comprehensive action space, enabling LLMs to perform precise
    unit operations and skill executions. It also facilitates multi-agent research. By validating the Visual-CoT
    framework on the LLM-PySC2 environment, our experiments demonstrate the significant role this framework
    plays in enhancing model performance.
  3. OVERVIEW OF THE VISUAL-COT FRAMEWORK
    3.1 Framework Design Philosophy
    The core concept of the Visual-CoT framework is to integrate visual information to guide LLMs in generating
    comprehensive chains of thought, enabling fine-grained action control in complex gaming environments. In real￾time strategy games like StarCraft II, visual elements such as terrain features, unit positions, and enemy-allied
    distributions play a crucial role in strategic decision-making.
    Traditional LLMs, when handling such tasks, typically rely on textual or numerical observational data,
    which fails to fully exploit the rich visual cues available. This limitation constrains the quality of decision￾making. The Visual-CoT framework addresses this challenge by incorporating visual guidance, embedding in￾game visual data—such as screenshots and feature maps—into the model’s reasoning process, thereby enhancing
    its situational awareness and comprehension of the environment.
    In our research, we designed a specific map scenario in StarCraft II featuring the Colossus unit, where the
    model needs to interpret visual information to assist in tactical operations. The model is required to analyze
    visual cues to assess terrain characteristics, determine the spatial relationships between enemy and allied units,
    and make tactical choices. This design highlights the importance of visual information in complex decision￾making tasks and provides a robust experimental foundation to validate the effectiveness of the Visual-CoT
    framework.
    3.2 Framework Structure
    We propose the Visual-CoT framework for fine-grained action control in complex scenarios within StarCraft II.
    Visual-CoT enhances the decision-making capabilities of LLMs in multimodal environments by integrating visual
    information with CoT reasoning through optimized prompt design. The core of the framework lies in embedding
    visual descriptions and reasoning logic into prompts, guiding the model to iteratively analyze complex game
    scenarios and generate actions.
    Figure 1 outlines the three key components of the Visual-CoT framework: system prompt, example input
    prompt, and example output prompt. The system prompt consolidates task rules, map information, and strategic
    priorities while incorporating critical features extracted from visual game observations, such as terrain boundaries
    and enemy-allied distributions, to provide a decision-making context. The example input prompt highlights the
    visual cues and related descriptions necessary for reasoning within the CoT framework, demonstrating how to
    leverage visual information for environment understanding and strategy planning. The example output prompt
    showcases the model’s expected reasoning process and generated actions, including position evaluations, strategy
    selection, and detailed execution plans.
    Multimodal large language models (MMLMs) process text observations and RGB screen images as input.
    These inputs, augmented with visual prompts, guide the model in extracting critical visual information. Com￾bined with task knowledge and strategic rules embedded in the System Prompt, the model employs CoT reasoning
    to generate detailed action decisions.
    Figure 1: Visual-CoT Framework: Fine-Grained Action Control in StarCraft II. The framework combines visual
    observations (Screen RGB Image) with text inputs, utilizing supplemental visual information to assist the CoT
    in guiding the LLM’s reasoning and decision-making, ultimately generating fine-grained strategic actions.
  4. METHOD
    4.1 Map and Scenario Design
    In this study, we utilized the StarCraft II map editor to design a scenario where one Colossus faces off against
    32 Zerglings,as shown in figure 2. This scenario highlights the importance of strategic planning and fine-grained
    action control while emphasizing the critical role of visual information in model decision-making in complex
    environments. As a high-damage ranged unit, the Colossus requires precise control to avoid being surrounded
    by Zerglings and to maximize its damage output.
    The designed map includes complex terrains such as high ground, low ground, cliffs, and narrow pathways.
    The Colossus starts at the center of the high ground, benefiting from vision and terrain advantages, and can
    leverage its unique ability to traverse cliffs. The Zerglings, on the other hand, must navigate narrow pathways
    to attack the high ground, which limits their movement options and aids the Colossus in defense and offense.
    The edges of the map are marked with impassable black backgrounds, and red lines indicate the boundaries of
    the playable area.
    In this scenario, the model must rely on visual information to perceive the battlefield situation, understand
    terrain characteristics, and grasp the positional relationships between allied and enemy units. Numerical or
    textual information alone cannot fully describe these spatial relationships, making this scenario an ideal exper￾imental condition to evaluate the effectiveness of the Visual-CoT framework in enhancing decision-making in
    complex environments.
    4.2 Visual Information Extraction
    In this study, using the observation wrapper of the LLM-PySC2 environment, a screenshot is captured every
    second (equivalent to 22.4 game steps) to record the current game state. The screen coordinate system ranges
    Figure 2: Map of the 1 Colossus vs 32 Zerglings scenario, featuring high and low terrain with connecting pathway
    from 0 to 256, with the origin located at the top-left corner. To enhance the model’s understanding of map
    boundaries and terrain features, edge masks are generated by detecting the boundaries between black pixel
    regions and non-black regions, with the boundaries marked in red (black backgrounds represent unpassable
    areas). This processing clarifies map boundaries, helping the model to avoid unpassable areas while leveraging
    terrain advantages in decision-making. The specific marking results are shown in figure 3.
    Figure 3: Processed Screen RGB Image with Terrain Boundary Markings
    The processed images are directly embedded into the model’s prompts, providing a reference for the model
    when generating chains of thought. By including this visual information in the prompts, the model can better
    understand the current game state and make more informed action decisions.
    4.3 Prompt Generation
    In the Visual-CoT framework, the prompt generation process is illustrated in algorithm 1. This algorithm
    organizes system prompts, example inputs and outputs, visual information, and current observations into a
    message sequence, which serves as input for the LLMs to perform multimodal reasoning and decision-making.
    By integrating visual information with chains of thought, the model can better comprehend the game environment
    and generate more refined action instructions.The specific generated prompts are provided in Appendix B.
    4.4 Visual-Guided Chain of Thought Design
    4.4.1 Role of the Chain of Thought
    In the Visual-CoT framework, the Chain of Thought is one of the core components of model decision-making.
    By employing step-by-step reasoning and analysis, it enhances the model’s depth of reasoning and transparency
    Algorithm 1 Visual-CoT Prompt Generation
    Input: Text observation ot; User image It (Base64 encoded RGB image data); Example images Iex1 and Iex2
    (Base64 encoded); System prompt pr; Example input pi and output po; Screen RGB prompt prgb; Descriptions
    descex1 and descex2 for Iex1 and Iex2.
    Output: Formatted message sequence mt for multimodal reasoning input to the LLM.
    1: function Generate_Message_Sequence(ot)
    2: Initialize message list mt as an empty list
    3: Append(pr, role=”system”)
    4: Append(descex1 and Iex1, role=”user”)
    5: Append(descex2 and Iex2, role=”user”)
    6: Append(pi
    , role=”user”)
    7: Append(po, role=”assistant”)
    8: Append(prgb and It, role=”user”)
    9: Append(ot, role=”user”)
    10: return mt
    11: end function
    in decision-making. Through iterative analysis, the model organically integrates visual and textual information,
    enabling a more accurate understanding of the current game state (e.g., unit positions, terrain features, and
    enemy dynamics). This facilitates the formulation of precise and effective strategies while avoiding errors caused
    by incomplete information comprehension. Furthermore, the CoT provides the model with a clear reasoning
    logic, not only improving its grasp of complex game states but also offering a solid foundation for optimizing
    and refining the framework.
    4.4.2 Methods for Integrating Visual Information
    To effectively integrate visual information into the Chain of Thought, we embed preprocessed game screenshots
    (Base64 encoded) into the prompts, accompanied by textual descriptions of terrain, unit positions, and map
    coordinates. This guides the model to fully utilize visual information during reasoning. Additionally, by providing
    examples of inputs and outputs that include visual information, the model learns to synthesize visual cues and
    textual information for reasoning within the Chain of Thought.
    4.4.3 Chain of Thought Generation Process
    In the Visual-CoT framework, the CoT facilitates complex decision-making through a step-by-step reasoning
    process, consisting of five logical stages. The first stage is position evaluation, where the model analyzes the
    battlefield situation using both visual and textual information, such as determining whether the Colossus is
    on high ground and if Zerglings are approaching. Based on the results of the position evaluation, the process
    proceeds to action priority assessment, where factors like weapon cooldowns and enemy positions are considered
    to identify the most critical action. The next stage involves strategic recommendation, where global strategies
    are formulated according to the priorities, such as retreating to leverage terrain advantages or prioritizing specific
    targets for attack. Subsequently, during the movement and attack analysis phase, the strategy is broken down
    into concrete operations, with the model evaluating the optimal path, target selection, and attack timing to
    ensure effective and safe execution. Finally, in the action output stage, the model generates specific operational
    commands, such as moving to a designated location or attacking a particular unit. This stepwise reasoning
    structure enhances the accuracy of the model’s decision-making while ensuring interpretability throughout the
    process.
    4.5 Fine-grained Action Control Strategy
    4.5.1 State Assessment for Decision-making
    To achieve precise control of the Colossus, a detailed decision-making process and condition evaluation rules
    are established. Before generating action commands, the model evaluates the current game state and identifies
    key variables, including the positions of the Colossus and Zerglings, weapon cooldown status, and the health
    of the Colossus. By assessing these conditions, the model gains a comprehensive understanding of the current
    battlefield situation, providing a basis for subsequent action decisions.
    For instance, the model uses visual information (such as terrain and unit positions in the image) and textual in￾formation (such as unit attributes and statuses) to determine whether the Colossus is on high ground (IS_COLO￾SSUS_HIGH_GROUND), whether Zerglings are near the Colossus (IS_ZERGLING_NEAR_COLOSSUS), and
    whether the Colossus’s weapon is on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN), among other con￾ditions.
    4.5.2 Action Decision Priorities
    As illustrated in the figure 4, the action decision rules and priorities define the optimal strategies for the model
    under specific circumstances and special conditions. The following rules are outlined to guide the model in
    making reasonable action decisions in complex battle environments.
    For example, when the Colossus has low health, its weapon is on cooldown, and enemies are approaching,
    the model prioritizes moving to retreat to a safe location, leveraging terrain advantages to delay enemy pursuit.
    Figure 4: Action Decision Rules and Priority Judgments for Colossus Combat Scenarios
  5. EXPERIMENTS AND RESULTS
    5.1 EXPERIMENTS
    5.1.1 Experimental Setup
    To validate the effectiveness of the proposed Visual-CoT framework in the complex strategy game StarCraft II,
    we performed a series of controlled experiments. The experiments aimed to evaluate the model’s performance in
    fine-grained action control, strategy planning, and decision-making capabilities. We focused on comparing the
    performance of models utilizing the Visual-CoT framework against the baseline method, LLM-PySC2.
    The experiments were conducted on the LLM-PySC2 environment, using GPT-4 and GPT-4O as the mul￾timodal large language models, which served as the primary test models for this study. The experiments were
    executed on version 5.0.13 of StarCraft II, with the selected map featuring a complex battle scenario specifically
    designed for Colossus versus Zerglings.
    Each experimental configuration involved running 20 matches to ensure the statistical significance and relia￾bility of the results.
    5.1.2 Evaluation Metrics
    To evaluate the model’s performance, several metrics were employed to comprehensively assess its performance
    in the competition. The Overall Win Rate (W) quantifies the ratio of the number of victories Nwin to the total
    number of games Ntotal and is defined as:
    W =
    Nwin
    Ntotal
    × 100%, (1)
    Additionally, the Average Enemy Kills (Eavg) is the average number of enemies killed per game, computed
    as the mean of the number of enemies killed in each match, as shown by the formula:
    Eavg =
    ∑Ntotal
    i=1 Ei
    Ntotal
    (2)
    For victorious games, the Average Victory Time (Twin) and Average Health Ratio (Hwin) represent the
    average duration of the winning games and the average remaining health ratio in those games, respectively, and
    are calculated as follows:
    Twin =
    ∑Nwin
    i=1 Ti
    Nwin
    , Hwin =
    ∑Nwin
    i=1 Hi
    Nwin
    For losing games, the Average Loss Time (Tlose) and Average Enemy Kills in Losses (Elose) represent the
    average duration of the losing games and the average number of enemies killed in those games, respectively.
    These are calculated as:
    Tlose =
    ∑Nlose
    i=1 Ti
    Nlose
    , Elose =
    ∑Nlose
    i=1 Ei
    Nlose
    (4)
    Finally, the Kill-to-Loss Ratio (KLR) measures the ratio of total enemy kills to the number of Colossus units
    lost in all games, and is computed using the formula:
    KLR =
    ∑Ntotal
    i=1 Ei
    Ncolossus_lost
    (5)
    These evaluation metrics provide a comprehensive overview of the model’s performance across various di￾mensions, including win rate, kill efficiency, game duration, performance in losses, and survival capability.
    5.2 Experimental Results
    5.2.1 Performance Comparison between Visual-CoT Framework and Baseline Prompt Model
    To evaluate the performance improvements introduced by the Visual-CoT framework in complex strategy game
    scenarios, we conducted comparative experiments on the LLM-PySC2 environment. Each experimental setup,
    including the baseline, was tested in 20 matches to ensure statistical significance and reliability.
    The following setups were compared: (1) LLM-PySC2, utilizing the LLM-PySC2 prompt framework (with
    textual and visual prompts) and GPT-4O as the multimodal model, but without the Visual-CoT framework; (2)
    Visual-CoT Framework, incorporating visual guidance and CoT reasoning techniques, using GPT-4O and GPT-4
    as multimodal models. The comparison metrics included Win Rate (W), Average Enemies Eliminated (Eavg),
    Average Victory Time (Twin), Average Defeat Time (Tlose), Average Enemies Eliminated in Defeats (Elose),
    Average Health Ratio in Victories (Hwin), and Kill-to-Loss Ratio (KLR).
    As shown in Table 1, the Visual-CoT framework significantly outperformed the baseline model across all
    key metrics when using the GPT-4O model. The Win Rate (W) improved from 0.00% to 45.00%, Average
    Enemies Eliminated (Eavg) increased from 14.5 to 24.00, and the Kill-to-Loss Ratio (KLR) rose from 14.5 to
    43.63. These results demonstrate that the deep integration of visual guidance and CoT reasoning is crucial for
    improving decision-making accuracy and battle performance.
    The Visual-CoT model using GPT-4 showed lower performance compared to GPT-4O but still significantly
    outperformed the baseline model. This indicates that the multimodal data handling capability of GPT-4O
    provides an advantage. However, the Visual-CoT framework effectively enhances combat control and strategic
    planning by combining visual information with reasoning capabilities.
    Table 1: Performance Comparison of Visual-CoT Framework
    Metric W (%) Eavg Twin (s) Tlose (s) Elose Hwin (%) KLR
    LLM-PySC2 (GPT-4O) 0.00 14.5 N/A 10.95 14.5 N/A 14.5
    Visual-CoT (GPT-4O) 45.00 24.00 57.44 26.18 17.45 35.08 43.63
    Visual-CoT (GPT-4) 25.00 20.45 72.60 38.40 16.60 24.00 27.27
    5.2.2 Ablation Study
    To evaluate the impact of visual guidance and CoT reasoning on model performance, we conducted two ablation
    experiments, with each setup running 20 matches:
  6. ScreenRGB Removed: The model used only textual information and was guided by CoT reasoning but
    received no visual input.
  7. COT Removed: The model received real-time game images as input but did not use Chain of Thought
    examples for input-output reasoning. It directly generated action commands without deep reasoning guidance.
    The experimental results are shown in Table 2.
    Table 2: Results of Ablation Study
    Metric W (%) Eavg Twin (s) Tlose (s) Elose Hwin (%) KLR
    Visual-CoT (GPT-4O) 45.00 24.00 57.44 26.18 17.45 35.08 43.63
    ScreenRGB Removed (GPT-4O) 5.00 12.75 55.00 25.36 11.73 35.71 13.42
    COT Removed (GPT-4O) 0.00 14.00 N/A 13.90 14.00 N/A 14.00
    When ScreenRGB Removed, the absence of visual guidance caused the Win Rate (W) to drop significantly
    to 5.00%, and the Average Enemies Eliminated (Eavg) decreased to 12.75. This indicates that visual guidance is
    critical for understanding the game environment and making strategic decisions.
    When CoT Removed, the Win Rate dropped to 0%, and the Kill-to-Loss Ratio (KLR) reduced to 14.00,
    highlighting the essential role of Chain of Thought reasoning in enhancing reasoning ability and decision quality.
    The results demonstrate the unique contributions of both visual guidance and Chain of Thought reasoning
    in improving model performance. Their combination enables the Visual-CoT framework to achieve significant
    performance gains in complex strategic scenarios.
    5.2.3 Conditional Judgment Accuracy Analysis
    To evaluate the effectiveness of the Visual-CoT framework, we analyzed the model’s accuracy in conditional
    judgments, focusing on key conditions. In the best match (where the Colossus had the highest remaining
    health), at 41 seconds of game time, each output from GPT-4O was analyzed alongside visual inputs. The
    results are shown in Table 3.
    As presented in Table 3, the model achieved 85.36% accuracy in determining whether the Colossus was on
    high ground (IS_COLOSSUS_HIGH_GROUND) and 87.80% in recognizing whether Zerglings were near the
    Colossus (IS_ZERGLING_NEAR_COLOSSUS). These results indicate that the model effectively integrates
    Table 3: Accuracy Analysis of Conditional Judgments in the Best Match
    Metric Accuracy (%)
    IS_COLOSSUS_HIGH_GROUND 85.36
    IS_ZERGLING_HIGH_GROUND 87.80
    IS_ZERGLING_NEAR_COLOSSUS 87.80
    IS_COLOSSUS_AT_CLIFF 82.96
    visual inputs with reasoning capabilities to perceive battlefield conditions accurately. The model also achieved
    87.80% accuracy in judging whether Zerglings were on high ground (IS_ZERGLING_HIGH_GROUND) and
    82.96% in determining whether the Colossus was at the edge of a cliff (IS_COLOSSUS_AT_CLIFF). This
    demonstrates the Visual-CoT framework’s ability to understand complex geographical conditions and provide a
    reliable foundation for subsequent decision-making.
    5.3 Result Analysis
    The experimental results demonstrate that the Visual-CoT framework, by integrating visual guidance and Chain
    of Thought reasoning, effectively improves the model’s decision-making accuracy and efficiency in complex combat
    scenarios in StarCraft II. The model is able to accurately understand the battlefield terrain, unit positions, and
    the enemy-friendly situation, formulate reasonable strategies, and achieve tactical objectives through precise
    action control.
    Visual guidance provides the model with critical environmental perception information, enabling the model to
    accurately assess the battlefield situation using visual inputs. The addition of visual information and the Chain
    of Thought reasoning enhance the model’s inference and decision-making capabilities, improving the depth and
    accuracy of strategy planning through step-by-step reasoning. To provide a more intuitive understanding of the
    Visual-CoT framework’s refined control and decision-making capabilities, Appendix A presents a series of visual
    demonstrations. These include annotated screenshots that illustrate the Colossus’s tactical movements, strategic
    positioning, and effective use of terrain to counter enemies.
  8. CONCLUSION AND FUTURE WORK
    This paper proposes the Visual-CoT framework, which enhances the action fine-grained control ability of large
    language models in complex strategy games, such as StarCraft II by combining visual guidance with Chain of
    Thought reasoning. Experimental results demonstrate that this framework significantly improves the model’s
    win rate and decision-making quality. In each of the 20 experimental runs, the model’s performance showed
    notable improvements, validating the effectiveness of the framework.
    While this research has made progress in the area of Visual-CoT, there are still limitations. Future research
    directions include: 1) validating the model’s generalization ability in more complex maps and diverse battle
    scenarios; 2) extending to multi-agent decision-making, exploring communication and collaboration mechanisms
    to enhance strategic effectiveness; 3) incorporating advanced computer vision techniques and integrating them
    deeply with large language models to improve visual information processing capabilities; 4) applying the Visual￾CoT framework to other domains to expand its applicability.
    APPENDIX A. VISUAL-COT REFINED CONTROL DEMONSTRATION
    This appendix presents a visual demonstration of the refined control enabled by the Visual-CoT framework.
    Key decision-making processes and corresponding actions are illustrated through annotated screenshots from the
    experimental scenarios.
    (a) When the Colossus is surrounded on the high
    ground, LLM issues a command to move across the
    cliff to the low ground.
    <Move_Screen([135, 200])> moves the Colossus to
    the green marker on the low ground.
    (b) Upon reaching the low ground, the Colossus attacks
    the LLM-locked enemy while enemy Zerglings are mov￾ing toward the low ground.
    <Attack_Unit(0x100440001)> directs the Colossus to
    target the specified enemy tag.
    (c) When the Colossus is approached on the low
    ground, LLM issues a command to move across the
    cliff to the high ground.
    <Move_Screen([135, 64])> moves the Colossus to the
    green marker on the high ground.
    (d) With multiple precise and refined operations, the
    Colossus combines its own abilities and terrain infor￾mation to eliminate an overwhelming number of ene￾mies.
    APPENDIX B. MAIN PROMPTS
    This appendix provides a detailed description of the prompts used in the Visual-CoT framework, including
    system prompt, example input prompt, and example output prompt. Certain content has been summarized and
    streamlined for clarity.
    System Prompt
  9. Role Description
    Describes the character’s identity, mission objectives, and primary responsibilities.
  10. Map Information
    Provides information about the map’s coordinate system, terrain features, and obstacles.
    • Coordinate System: The 2D grid coordinate system ranges from [0, 256] × [0, 256], with each
    grid cell being 32×32 pixels.
    • Terrain: Includes high ground, low ground, pathways, cliffs, and impassable areas. The Colossus
    can traverse the cliffs between high and low ground, while Zerglings must use the pathway.
  11. Key Victory Points
    Strategies to leverage the Colossus’s advantages for victory.
    • Maintain Maximum Attack Range: Stay within the maximum attack range to avoid close
    combat.
    • Focus Fire on Dense Enemy Clusters: Prioritize attacking the densest enemy groups to max￾imize damage.
    • Use Cliff Barrier to Delay Enemy: Use the terrain’s cliff to force enemies to take detours,
    buying time to reposition or counterattack.
  12. Decision Process
    Assess the battlefield based on conditions and determine action priorities.
    • Condition Assessment: Evaluate the status and positioning of the Colossus and Zerglings to
    assess the current situation.
    • Action Priority Determination: Based on the assessment, decide whether movement or attack
    should take priority.
  13. Integrated Strategy and Decision Framework
    Combine strategic elements to formulate an overall strategy and specific action plan.
    • Strategy Suggestions: Provide strategic advice based on the battle situation, such as utilizing
    terrain advantages or avoiding encirclement.
    • Action Decisions: Based on the current situation, decide on the movement and attack priorities,
    as well as the best timing and routes for actions.
  14. Analysis
    In your response, please follow the format outlined in the example output, including section titles, num￾bering, and the terminology used. Ensure that you use the same variable names and terms specified in
    the decision process and chain of thought
    • Condition Assessment: Assess the status and positioning of the Colossus and Zerglings.
    • Action Priority Determination: Based on the situation, decide whether to prioritize movement
    or attack.
    • Strategy Suggestions: Offer timely strategic adjustments based on the battlefield conditions.
    • Movement Analysis: Determine the best movement paths and timing for the Colossus to ensure
    safety.
    • Attack Analysis: Evaluate the best attack timing and targets to maximize damage.
    • Action Output: Based on the analysis, generate specific operational steps and instructions.
  15. Action Output:
    Team Colossus-1:
    • Action steps
    Example Input Prompt
    Game Info
    Time: 0:05
    Team Colossus-1 Info:
    Team minimap position: [31, 27]
    Controlled Team Units:
    • Unit: Colossus, Tag: 0x100000001, ScreenPos: [150, 123], Health: 350 (100
    Nearby Enemy Units:
    • Unit: Zergling, Tag: 0x1002c0001, ScreenPos: [52, 164], Distance: 10, Health: 6 (17%)
    • Unit: Zergling, Tag: 0x100180001, ScreenPos: [79, 159], Distance: 7, Health: 35 (100%)
    • Unit: Zergling, Tag: 0x100440001, ScreenPos: [112, 140], Distance: 4, Health: 35 (100%)
    • ...
    Relevant Knowledge:
    • Protoss.Colossus: A massive unit with splash laser attacks, ideal for defeating swarms of weak
    units. It can traverse terrain height due to long legs.
    Weapon info: Attack Range 7, target: [’ground’], DPS 13, anti-light DPS 20.
    • Zerg.Zergling: A fast, weak melee unit suited for swarm attacks.
    Weapon info: Attack Range 1, target: [’ground’], DPS 10.
    • ...
    Valid Actions:
    • Team Colossus-1 Valid Actions:
    – <Attack_Unit(tag)>
    – <Move_Screen(screen)>
    Action Args:
  16. tag: A hexadecimal number representing a unit, e.g., 0x000000000.
  17. screen: A coordinate in the screen range [0, 256].
    Last Step Actions:
    • Team Colossus-1:
    – <Move_Screen([160, 130])>
    – <Attack_Unit(0x1007c0001)>
    – <Attack_Unit(0x100740001)>
    You need to confirm whether the previous action finished executing, and based on this, determine whether
    to continue the old strategy or immediately take other actions.
    Give each team no more than 3 actions, among which activity release should usually be before move and
    attack.
    Now, start generating your analysis and actions:
    Example Output Prompt
    Analysis:
  18. Decision Process
    1.1 Condition Assessment
    • IS_COLOSSUS_HIGH_GROUND = True: The Colossus is currently on the high ground.
    • IS_ZERGLING_HIGH_GROUND = True: Zerglings are also concentrated on the high
    ground.
    • IS_ZERGLING_NEAR_COLOSSUS = True: Multiple Zerglings are approaching the
    Colossus, posing an immediate threat.
    • IS_COLOSSUS_AT_CLIFF = False: The Colossus is not near the cliff.
    • IS_COLOSSUS_WEAPON_COOLDOWN = True: The weapon is currently on cooldown
    and cannot attack immediately.
    • IS_COLOSSUS_HEALTH_LOW = False: The Colossus has full health, no low-health
    threat.
    1.2 Action Decision Rules
    • Decision Basis:
    – Special Rules: Prioritize movement over attack when the weapon is on cooldown.
    – Current Scenario: Zerglings are approaching the Colossus, and the weapon is on cooldown.
    – Terrain Condition: The Colossus is near the red boundary of the map, limiting maneuver￾ability.
    • Decision Result:
    – Prioritize movement: Retreat to low ground to avoid encirclement and give time for weapon
    cooldown.
  19. Integrated Strategy and Decision Framework
    2.1 Strategy Suggestions
    • Current Strategy: Emergency retreat to the low ground, using the cliff to delay Zerglings’ pursuit.
    • The retreat will provide time for weapon cooldown and create safe distance to regain battlefield
    control.
    2.2 Movement Decision Analysis
    • Enemy Approach Path Prediction: Zerglings are advancing from the left pathway on the high
    ground, attempting to encircle the Colossus.
    • Movement Target Suggestions: Retreat directly to screen coordinates [160, 200], a safe area
    near the cliff on the low ground.
    • Reason: Retreating to the low ground avoids encirclement and uses the cliff to delay enemy pursuit,
    ensuring the Colossus’s safety.
    2.3 Attack Decision Analysis
    • Attack Target Priority: Once the weapon cooldown ends, prioritize attacking the nearest Zer￾glings.
    • Target Selection: Choose the closest Zerglings (e.g., Zergling, Tag: 0x1004c0001 and
    0x100740001) as primary targets.
  20. Actions:
    • Team Colossus-1:
    – <Move_Screen([160, 200])> # Retreat directly from high ground to low ground, avoiding
    Zergling encirclement and using the cliff to delay pursuit.
    – <Attack_Unit(0x1004c0001)> # After weapon cooldown, prioritize attacking the nearest Zer￾gling to reduce threat.
    – <Attack_Unit(0x100740001)> # Continue attacking other nearby Zerglings to weaken the
    enemy forces using splash damage.
    REFERENCES
    [1] Team, O. C., “Chatgpt.” Online (2022). Accessed: 26-Nov-2024.
    [2] Touvron, H., Lavril, T., Izacard, G., and et al., X. M., “Llama: Open and efficient foundation language
    models,” (2023).
    [3] Achiam, J., Adler, S., Agarwal, S., and et al., “Gpt-4 technical report,” arXiv preprint arXiv:2303.08774
    (2023).
    [4] et al., R. G., “A survey on advancements in image–text multimodal models: From general techniques to
    biomedical implementations,” Computers in Biology and Medicine 178, 108709 (2024).
    [5] Huang, W., Wu, A., Yang, Y., Luo, X., Yang, Y., Hu, L., Dai, Q., Dai, X., Chen, D., Luo, C., et al.,
    “Llm2clip: Powerful language model unlock richer visual representation,” arXiv preprint arXiv:2411.04997
    (2024).
    [6] Kuckreja, K., Danish, M. S., Naseer, M., Das, A., Khan, S., and Khan, F. S., “Geochat: Grounded large
    vision-language model for remote sensing,” in [Proceedings of the IEEE/CVF Conference on Computer
    Vision and Pattern Recognition], 27831–27840 (2024).
    [7] Xu, X., Wang, Y., and Xu, C. e. a., “A survey on game playing agents and large models: Methods,
    applications, and challenges,” (2024).
    [8] Buschoff, L. M. S., Akata, E., Bethge, M., and Schulz, E., “Visual cognition in multimodal large language
    models,” (2024).
    [9] Yan, H., Hu, X., and Wan, X. e. a., “Inherent limitations of llms regarding spatial information,” (2023).
    [10] Zhu X., Chen Y., T. H. e. a., “Ghost in the minecraft: Hierarchical agents for minecraft via large language
    models with text-based knowledge and memory,” (2024).
    [11] Tan, W., Zhang, W., Xu, X., Xia, H., and Ding, G. e. a., “Cradle: Empowering foundation agents towards
    general computer control,” in [NeurIPS 2024 Workshop on Open-World Agents], (2024).
    [12] Zhang, W., Tang, K., Wu, H., and Wang, M. e. a., “Agent-pro: Learning to evolve via policy-level reflection
    and optimization,” arXiv preprint arXiv:2402.17574 (2024).
    [13] Meta FAIR Diplomacy Team, Bakhtin, A. B. N. D. E. e. a., “Human-level play in the game of diplomacy
    by combining language models with strategic reasoning,” Science 378(6624), 1067–1074 (2022).
    [14] Ma, W., Mi, Q., Zeng, Y., and Yan, X. e. a., “Large language models play starcraft II:benchmarks and a chain
    of summarization approach,” in [The Thirty-eighth Annual Conference on Neural Information Processing
    Systems], (2024).
    [15] Li, Z., Ni, Y., Qi, R., and Jiang, L. e. a., “Llm-pysc2: Starcraft ii learning environment for large language
    models,” (2024).
    [16] Wei, J., Wang, X., Schuurmans, D., and Bosma, M. e. a., “Chain-of-thought prompting elicits reasoning in
    large language models,” Advances in Neural Information Processing Systems 35, 24824–24837 (2022).
    [17] Zhang, Z., Zhang, A., Li, M., and Zhao, H. e. a., “Multimodal chain-of-thought reasoning in language
    models,” (2024).

사고

分析技术内容

我正在深入研究Visual-CoT框架的技术细节,确保理解其在LLM-PySC2项目中的作用,以及是否需要进一步探讨或总结。

思考,持续 几秒

답변

理解 Visual-CoT 项目

Visual-CoT: A Visual Guided Chain of Thought Framework for Fine-grained Control in StarCraft II Actions 是一个旨在提升大型语言模型(LLMs)在复杂策略游戏(如《星际争霸 II》)中进行精细化动作控制能力的框架。该项目在 LLM-PySC2 环境上实现,结合视觉信息与思维链(Chain of Thought, CoT)方法,显著增强了 LLM 在实时决策和策略执行中的表现。

项目背景

  • LLM-PySC2 环境:这是一个基于 Python 的《星际争霸 II》学习环境,旨在将大型语言模型集成到 StarCraft II 的多智能体决策环境中。该环境支持多种主流 LLM,提供丰富的观察接口和完整的动作空间,并支持多智能体协作。
  • LLMs 的局限性:尽管 LLM 在自然语言处理和复杂决策方面表现出色,但在需要精细化动作控制的复杂环境中,仍面临显著挑战,特别是在整合视觉信息以支持实时决策方面。

Visual-CoT 框架的目标

  • 整合视觉信息与思维链:通过将视觉数据无缝嵌入到 LLM 的推理和决策过程中,增强模型对战场环境的理解和精确动作执行能力。
  • 提升决策质量:在复杂的策略游戏场景中,尤其是在需要实时调整策略和精细控制的情况下,提供更高质量的决策支持。

主要贡献

  1. 提出 Visual-CoT 框架

    • 创新性地结合视觉引导与思维链推理,增强 LLM 在复杂策略游戏中的精细化动作控制能力。
    • 通过优化提示设计,将视觉描述和推理逻辑嵌入到提示中,引导模型进行多模态推理和决策。
  2. 在 LLM-PySC2 环境上的验证

    • 设计了一个复杂的战斗场景:一个 Colossus 对战三十二个 Zerglings,地图包含高地和低地等复杂地形。
    • 实验结果显示,Visual-CoT 框架显著提高了模型的胜率(从 0% 提升到 45%),增强了精细化控制和精确动作执行能力。
  3. 显著的性能提升

    • 实验表明,采用 Visual-CoT 框架的模型在胜率、敌方击杀数、战斗时间和击杀比率等多个指标上均有显著提升。
    • 通过视觉引导和思维链推理的深度整合,模型在复杂战略场景中的决策准确性和效率得到了显著改善。

框架设计

  • 系统提示(System Prompt)

    • 描述角色身份、任务目标和主要职责。
    • 提供地图信息,包括坐标系统、地形特征和障碍物。
    • 关键胜利点策略,如保持最大攻击范围、集中火力攻击密集敌群等。
    • 决策过程,包括条件评估和动作优先级确定。
  • 示例输入和输出提示

    • 示例输入提示:包括游戏信息、团队单位信息、敌方单位信息、相关知识和有效动作列表。
    • 示例输出提示:包括详细的分析和行动计划,分为条件评估、动作优先级判断、策略建议、移动决策分析、攻击决策分析和具体行动输出。
  • 视觉信息提取

    • 使用观察包装器每秒截取一次屏幕截图(Base64 编码),记录当前游戏状态。
    • 通过检测黑色像素区域与非黑色像素区域的边界,生成边界标记,帮助模型准确理解地图边界和地形特征。

方法论

  1. 地图与场景设计

    • 设计了一个 Colossus 对战 32 个 Zerglings 的场景,强调地形优势和精细化动作控制的重要性。
    • 地图包含高地、低地、悬崖和狭窄通道,模拟复杂战场环境。
  2. 视觉信息提取

    • 每秒截取一次游戏屏幕,处理图像以标记地图边界和地形特征。
    • 将处理后的图像嵌入到提示中,辅助模型进行战场情况的理解和决策。
  3. 提示生成

    • 通过算法组织系统提示、示例输入输出、视觉信息和当前观察,形成多模态推理输入。
    • 在提示中结合视觉信息与思维链,指导模型进行综合分析和决策。
  4. 思维链生成过程

    • 条件评估:分析 Colossus 和 Zerglings 的位置、健康状态和武器冷却状态。
    • 动作优先级判断:根据评估结果决定优先执行的动作,如撤退或攻击。
    • 策略建议:根据战场情况提出战略调整建议,如利用地形优势或避免被包围。
    • 移动和攻击决策分析:细化具体的移动路径和攻击目标,确保动作的有效性和安全性。
    • 动作输出:生成具体的操作指令,如移动到指定位置或攻击特定单位。
  5. 精细化动作控制策略

    • 通过详细的决策过程和条件评估,确保模型能够根据实时战场情况做出精准的动作选择。
    • 建立动作决策规则和优先级判断,指导模型在特定条件下采取最优策略。

实验与结果

  • 实验设置

    • 在 LLM-PySC2 环境中,设计了 Colossus 对战 32 个 Zerglings 的复杂战斗场景。
    • 使用 GPT-4 和 GPT-4O 作为多模态大型语言模型进行测试,每种配置运行 20 场比赛以确保结果的统计显著性。
  • 评估指标

    • 胜率(Win Rate, W):胜利场次与总场次的比率。
    • 平均击杀数(Average Enemy Kills, Eavg):每场比赛平均击杀的敌方单位数。
    • 平均胜利时间(Average Victory Time, Twin):胜利比赛的平均持续时间。
    • 平均失败时间(Average Loss Time, Tlose):失败比赛的平均持续时间。
    • 失败时的平均击杀数(Average Enemy Kills in Losses, Elose):失败比赛中平均击杀的敌方单位数。
    • 胜利时的平均健康比率(Average Health Ratio in Victories, Hwin):胜利比赛中剩余健康的平均比率。
    • 击杀比率(Kill-to-Loss Ratio, KLR):总击杀数与 Colossus 死亡数的比率。
  • 实验结果

    • Visual-CoT 框架
      • 使用 GPT-4O 时,胜率显著提升至 45%,击杀比率从 14.5 提升至 43.63。
      • 使用 GPT-4 时,胜率为 25%,击杀比率为 27.27,仍显著优于基线模型。
    • 消融实验
      • 移除视觉输入(ScreenRGB Removed)后,胜率降至 5%,击杀比率降至 13.42。
      • 移除思维链(CoT Removed)后,胜率降至 0%,击杀比率降至 14.00。
      • 结果表明,视觉引导和思维链推理在提升模型性能中各自发挥了关键作用。
  • 条件判断准确性分析

    • 模型在判断 Colossus 是否在高地、Zerglings 是否接近 Colossus 等关键条件上,准确率均在 80%以上,证明了 Visual-CoT 框架在战场情况感知上的有效性。

讨论

  • 视觉引导的重要性:实验结果表明,视觉信息在理解战场环境和制定战略决策中起到了至关重要的作用。缺乏视觉引导时,模型的决策能力显著下降。
  • 思维链推理的作用:思维链推理通过逐步分析和决策,提高了模型的推理深度和决策质量,确保了策略的连贯性和有效性。
  • 综合优势:视觉引导与思维链推理的结合,显著提升了模型在复杂战斗场景中的表现,使其能够更准确地理解环境、制定策略并执行动作。

结论与未来工作

  • 结论

    • Visual-CoT 框架 成功地将视觉信息与思维链推理相结合,显著提升了 LLM 在《星际争霸 II》复杂战斗场景中的动作控制能力和决策
  • 未来工作

    1. 验证模型的泛化能力
      • 在更多复杂地图和多样化战斗场景中测试 Visual-CoT 框架,以确保其在不同环境下的有效性和鲁棒性。
    2. 扩展至多智能体决策
      • 探索视觉引导与思维链在多智能体协作和沟通机制中的应用,提升整体战略效果。
    3. 集成先进的计算机视觉技术
      • 深入结合先进的计算机视觉方法,进一步提高视觉信息处理能力,增强模型的环境感知和理解能力。
    4. 跨领域应用
      • 将 Visual-CoT 框架应用于其他需要多模态信息整合和精细化控制的领域,如机器人控制、自动驾驶和虚拟助手等,扩展其应用范围。

项目资源

  • 代码开源:Visual-CoT 框架的代码已在 GitHub 上开源,供研究人员和开发者参考和使用。

总结

Visual-CoT 框架通过将视觉信息与思维链推理相结合,显著提升了大型语言模型在《星际争霸 II》等复杂策略游戏中的动作控制和决策能力。通过在 LLM-PySC2 环境中的验证,证明了其在战场环境理解和精细化动作执行中的有效性。尽管当前已经取得了显著的成果,但未来仍需进一步验证其泛化能力、扩展至多智能体决策、集成更先进的视觉技术以及探索跨领域应用,以推动基于 LLM 的复杂决策方法的发展。

질문

我给出你这个思维链具体的内容:# Copyright 2024, LLM-PySC2 Contributors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS-IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

class BasePrompt:

text
def __init__(self): self.sp = '' self.eip = '' self.eop = '' self.screen_img_rgb_prompt = '' self.screen_img_fea_prompt = '' self.minimap_img_rgb_prompt = '' self.minimap_img_fea_prompt = ''

class CombatGroupPrompt(BasePrompt):

text
def __init__(self, name, log_id, config): super(CombatGroupPrompt, self).__init__() self.name = name self.config = config self.log_id = log_id # Part 1 self.sp = f""" 1. Role Description You are a {self.config.AGENTS[self.name]['describe']}. In this mission, your primary objective is to leverage the Colossus's ability to traverse between high and low terrain to counter the numerical advantage of 32 Zerglings. Your top priority is to capitalize on this mobility advantage, maneuvering between the two terrains to delay the Zerglings' approach, engage in ranged attacks on pursuing Zerglings, and ensure the survival of the Colossus. 2.Map Information 2.1 Coordinate System: - The screen coordinate system is a 2D grid with a range of [0, 256] &times; [0, 256]. - Each grid cell measures 32 &times; 32 pixels, resulting in a total of 8 &times; 8 = 64 grid cells. - The origin point (0, 0) is at the top-left corner, while (256, 256) is at the bottom-right corner. 2.2 Terrain Information: - Pathway (connecting the high ground and low ground): The map consists of an upper platform (high ground) and a lower platform (low ground), connected by a narrow pathway on the left side. - High Ground (light green area): The high ground is characterized by light green grass textures and is located on the upper platform. - Low Ground (dark gray area): The low ground is characterized by dark gray concrete textures and is located on the lower platform. - Impassable Area (black background): The edges of the map consist of a black background, which is impassable. The Colossus must avoid entering these areas. - Cliff (light gray vertical surface): The cliff separates the high ground and low ground. The Colossus can freely traverse the cliff, but Zerglings can only access the high ground through the narrow pathway on the left. Only the boundary between the high ground and low ground is considered a cliff; other deep red boundaries are impassable edges of the map. - Boundary: The boundaries between the high ground and the black background, as well as between the low ground and the black background, are considered impassable edges of the map. The boundaries are represented by deep red lines on the map. 3. Key Victory Points: 3.1 Maintain Maximum Attack Range: - Ideally, the Colossus should stay within its maximum attack range (range 7) to fully utilize its long-range attack advantage while minimizing the risk of melee attacks from enemies. 3.2 Focus Fire on Dense Enemy Clusters: - Target the center of the densest enemy groups to maximize splash damage and quickly reduce enemy numbers. 3.3 Cliff Barrier Delay Effect: The Cliff Barrier Delay Effect refers to leveraging the terrain characteristics of cliffs, where enemy units cannot directly cross the cliff, while allied units can freely traverse it. This forces the enemy to take a detour when transitioning between high and low ground, buying time for allied units to reposition, cool down weapons, and strike effectively. - When enemies are heavily concentrated on the high ground: - If allied units are also on the high ground but risk being surrounded, it is recommended to retreat to the bottom-right low ground. This utilizes the cliff as a barrier to delay enemy pursuit, enabling ranged attacks on the enemies while maintaining battlefield control. - When enemies are heavily concentrated on the low ground: - If allied units are also on the low ground but risk being surrounded, it is recommended to retreat to the top-right high ground. The cliff barrier forces enemies to take a detour, providing time for allied units to reposition and counterattack effectively.

4. Decision Process
Based on the observed data of the Colossus and Zerglings, as well as the RGB image of the screen, use the following decision rules to determine action priorities:

text
4.1 Condition Assessment Rules: - IS_HIGH_GROUND: - Criteria: If the Colossus is on the green high ground (above the cliff, with a clear boundary from the low ground), set to True; otherwise, set to False. - Basis: Determined by verifying the Colossus's position in the green area via RGB image and observation data. - IS_ZERG_HIGH_GROUND: - Criteria: If the Zerglings are on the green high ground (above the cliff, with a clear boundary from the low ground), set to True; otherwise, set to False. - Basis: Determined by analyzing the Zerglings' positions via RGB image. - IS_ZERG_NEAR: - Criteria: If at least 5 Zerglings are within the attack range (&le;7) or attempting to surround the Colossus, set to True; otherwise, set to False. - Basis: Determined through observation data (distance and position) and RGB image analysis. - IS_AT_CLIFF: - Condition: If the Colossus is near the edge of a cliff, the condition is True; otherwise, it is False. It is important to distinguish between a cliff and a boundary. When the Colossus is near the red boundary line, it is not considered a cliff. A cliff is the transitional area between the highland and the lowland. - Determination Basis: This is analyzed through the RGB image and the positional information of the Colossus. - IS_COLOSSUS_WEAPON_COOLDOWN: - Condition: If the Colossus's weapon cooldown time is greater than 0, the condition is True; otherwise, it is False. - Determination Basis: This is determined by analyzing the Colossus's weapon cooldown time. - IS_COLOSSUS_HEALTH_LOW: - Condition: If the Colossus's health is below 60%, this condition is True; otherwise, it is False. - Determination Basis: Determined by observing the Colossus's health. 4.2 Action Decision Rules - Special Scenarios: rule1 :As long as the weapon is in cooldown, the priority of movement actions is higher than attack actions. Movement > Attack. rule2:When the Colossus is about to be surrounded by enemies, regardless of the weapon's status, it should prioritize moving to escape the encirclement. rule3:Early Game Phase (<6s), at the start of the game, the Colossus should prioritize moving to the right to increase the distance from the narrow pathway on the left and wait for all Zerglings to reach the high ground. During this phase, movement takes priority over attacking. - Situation 1: The Colossus and Zerglings are in different areas - Weapon not on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = False): - Priority: Attack. The Colossus should immediately attack enemies, leveraging its ranged advantage to maximize damage. - Weapon on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = True): - Priority: Move. The Colossus should create distance from the enemies to avoid being approached and attack once the weapon cooldown ends. - Situation 2: The Colossus and Zerglings are in the same area - Enemies are near and about to attack (IS_ZERG_NEAR = True, Zerglings approaching): - Priority: Move. Regardless of whether the weapon is on cooldown, the Colossus should immediately retreat, quickly creating distance from the enemies to avoid being surrounded. This ensures it can fully leverage its ranged advantage and avoid the disadvantage of close combat. Once out of danger, it can then look for opportunities to counterattack. - Enemies are not near (IS_ZERG_NEAR = False): - Weapon not on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = False): - Priority: Attack. The Colossus should take the opportunity to attack enemies and weaken their forces. - Weapon on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = True): - Priority: Move. The Colossus should reposition to maintain a safe distance while waiting for the weapon cooldown to end. - Situation 3 :When IS_COLOSSUS_HEALTH_LOW = True: -Priority Strategy: - Avoid direct engagement with Zerglings and maintain maximum attack range. - Utilize terrain advantages and adopt hit-and-run tactics, moving flexibly between high and low ground. - Priority: Movement > Attack

5 Integrated Strategy and Decision Framework
1. Strategy Suggestions

text
1.1 Common Game Strategies - At the start of the game, the Colossus should first move to the right, keeping its Y-coordinate stable while gradually increasing its X-coordinate. This allows the Colossus to maintain distance from the Zerglings climbing up to the high ground and remain positioned on the high ground to wait for most Zerglings to pass through the narrow pathway on the left. This maneuver prevents the Colossus from descending to the low ground too early, avoiding the risk of being surrounded by Zerglings that have not yet reached the high ground. - Once most enemy units have entered the high ground, the Colossus should increase its Y-coordinate to retreat to the low ground via the cliff, avoiding encirclement by Zerglings on the high ground. 1.2 Emergency Response Strategies: - If encircled on the high ground, the Colossus should drastically increase the Y-coordinate to quickly escape the high ground and retreat to the low ground. - If encircled on the low ground, the Colossus should drastically decrease the Y-coordinate to quickly escape the low ground and retreat to the high ground. 2. Movement and Attack Decision 2.1 When Movement Is Required: - Phase Judgment: - Determine the current phase based on game time and the positions of both allied and enemy units. - Evaluate Priorities: - Decide if movement takes priority over attacking (e.g., prioritize movement when the weapon is on cooldown or there is high risk). - Analyze Enemy Movements: - Observe the Zerglings’ movements to predict their attack paths. - Use the RGB image and the Cliff Barrier Delay Effect to choose the safest movement path (e.g., move down-right or up-right). - Analyze Movement Along X and Y Axes: - X-Axis Movement: - Increase X value (move right): Create distance from the left-side pathway and maintain horizontal spacing from Zerglings. - Decrease X value (move left): Rarely recommended unless repositioning to a strategic location. - Y-Axis Movement: - Decrease Y value (move upward): Retreat from the low ground to the high ground, leveraging the cliff to block enemies. - Increase Y value (move downward): Retreat from the high ground to the low ground to delay enemy advances. 2.2 When Attacking Is Required: - Target Selection: - Prioritize the densest groups of enemies to maximize splash damage. - Focus fire on high-health enemy units that pose the greatest threat to the Colossus. - Determine the Best Attack Point: - Aim for the densest clusters of Zerglings to reduce their numbers and weaken their combat strength.

6.Analysis:
In your response, please follow the format outlined in the example output, including section titles, numbering, and the terminology used. Ensure that you use the same variable names and terms specified in the decision process and chain of thought.

text
The output should include: 1. Decision Process 1.1 Condition Assessment: - `IS_COLOSSUS_HIGH_GROUND = True/False` - `IS_ZERGLING_HIGH_GROUND = True/False` - `IS_ZERGLING_NEAR_COLOSSUS = True/False` - `IS_COLOSSUS_AT_CLIFF = True/False` - `IS_COLOSSUS_WEAPON_COOLDOWN = True/False` - `IS_COLOSSUS_HEALTH_LOW = True/False' 1.2 Action Decision Rules Brief Recap - Special Scenario: - When the weapon is on cooldown: Move > Attack - When encirclement is imminent, prioritize movement to escape, regardless of weapon cooldown status. - Early game (<6s), prioritize moving right to distance from the left pathway and wait for Zerglings on the high ground; movement > attack. - Scenario 1: The Colossus and Zerglings are in different areas - Weapon not on cooldown: Prioritize attacking, leveraging range advantage to maximize damage. - Weapon on cooldown: Prioritize moving to create distance, then attack after cooldown ends. - Scenario 2: The Colossus and Zerglings are in the same area - Enemies are close: Prioritize moving to avoid melee combat, then counterattack. - Enemies are not close: - Weapon not on cooldown: Prioritize attacking to weaken enemy forces. - Weapon on cooldown: Prioritize moving to maintain a safe distance. - Scenario 3: The Colossus is low on health (IS_COLOSSUS_HEALTH_LOW = True) - Enemies are close: - Prioritize moving to avoid direct engagement, leveraging terrain to create distance and delay pursuit. - Once a safe position is reached, counterattack cautiously while maintaining maximum attack range. - Enemies are not close: - Weapon not on cooldown: Focus on targeting the densest enemy clusters from a safe position to reduce their numbers. - Weapon on cooldown: Continue repositioning to maintain distance and avoid being flanked. 1.3 Judgment Based on 4.2 Action Decision Rules: -Provide movement and attack priorities, e.g., attack > move or move > attack. -Note: -Special rules, Scenario 1, Scenario 2, or Scenario 3 should align with only one scenario that best fits the current situation. -Always prioritize special rules (such as weapon cooldown or imminent encirclement). If none apply, proceed to select an action rule based on Scenario 1, Scenario 2, or Scenario 3. 2 Integrated Strategy and Decision Framework 2.1 Strategy Suggestions - Current Phase Determination: Dynamically determine the strategy based on time, the Colossus’s position, and Zergling distribution. Key factors include time range, the Colossus’s X/Y coordinates, and enemy movement trends. - Consider Common Action Recommendations:: - Early Game Observation Phase: Initially, keep the X-coordinate steady while gradually increasing the Y-coordinate to monitor enemy movements. Utilize the Colossus’s range advantage to weaken enemy forces. - Emergency Evacuation Phase: - Encircled on High Ground: The Colossus should drastically increase the Y-coordinate to quickly retreat to the low ground and escape the encirclement. - Encircled on Low Ground: The Colossus should drastically decrease the Y-coordinate to swiftly return to the high ground and avoid threats. - Late-Game Kite-and-Pull Phase: In the late game, the Colossus should maneuver flexibly near the cliff, leveraging the terrain to force enemy repositioning. Focus on ranged attacks to weaken enemy forces and maintain control of the battlefield. 2.2 Movement Decision Analysis - Enemy Approach Path Prediction: Analyze the primary approach paths of enemy units and identify potential threats. - Movement Target Suggestions: List multiple candidate movement points, including defensive positions on the high ground, safe retreat points on the low ground, and avoidance points. Specify the most suitable movement target (e.g., a safe spot on the high ground or near the cliff on the low ground). Explain the reasoning behind the selection (e.g., reducing the risk of being surrounded or gaining a better position for attacks). 2.3 Attack Decision Analysis - Target Prioritization: Prioritize attacking dense enemy clusters to maximize splash damage. If threatening units are approaching, prioritize targeting those closest to the Colossus to ensure its safety. - Attack Target Selection: Identify multiple candidate attack points (e.g., the center of a dense enemy group or the closest group to the Colossus). Specify the optimal attack point and provide reasoning (e.g., to maximize damage or avoid being overwhelmed). 7.Action Output: Team Colossus-1: Action steps. """ self.eip = \ """ Game Info Time: 0:05 Team Colossus-1 Info: Team minimap position: [31, 27] Controlled Team Units: Unit: Colossus, Tag: 0x100000001, ScreenPos: [150, 123], Health: 350 (100%), Weapon Cooldown Time: 0.91s Nearby Enemy Units: Unit: Zergling, Tag: 0x1002c0001, ScreenPos: [52, 164], Distance: 10, Health: 6 (17%) Unit: Zergling, Tag: 0x100180001, ScreenPos: [79, 159], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100440001, ScreenPos: [112, 140], Distance: 4, Health: 35 (100%) Unit: Zergling, Tag: 0x100640001, ScreenPos: [38, 176], Distance: 12, Health: 21 (60%) Unit: Zergling, Tag: 0x100700001, ScreenPos: [52, 178], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x100780001, ScreenPos: [42, 169], Distance: 11, Health: 6 (17%) Unit: Zergling, Tag: 0x100540001, ScreenPos: [49, 171], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x100500001, ScreenPos: [91, 146], Distance: 6, Health: 35 (100%) Unit: Zergling, Tag: 0x100800001, ScreenPos: [83, 147], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100280001, ScreenPos: [96, 151], Distance: 6, Health: 21 (60%) Unit: Zergling, Tag: 0x1000c0001, ScreenPos: [59, 162], Distance: 9, Health: 35 (100%) Unit: Zergling, Tag: 0x100040001, ScreenPos: [93, 157], Distance: 6, Health: 35 (100%) Unit: Zergling, Tag: 0x100340001, ScreenPos: [67, 172], Distance: 9, Health: 35 (100%) Unit: Zergling, Tag: 0x1001c0001, ScreenPos: [72, 161], Distance: 8, Health: 6 (17%) Unit: Zergling, Tag: 0x100600001, ScreenPos: [76, 152], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100140001, ScreenPos: [86, 162], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x1004c0001, ScreenPos: [117, 145], Distance: 3, Health: 35 (100%) Unit: Zergling, Tag: 0x100400001, ScreenPos: [66, 164], Distance: 9, Health: 21 (60%) Unit: Zergling, Tag: 0x100200001, ScreenPos: [78, 166], Distance: 8, Health: 35 (100%) Unit: Zergling, Tag: 0x100240001, ScreenPos: [104, 144], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100100001, ScreenPos: [59, 172], Distance: 10, Health: 35 (100%) Unit: Zergling, Tag: 0x1003c0001, ScreenPos: [86, 154], Distance: 7, Health: 6 (17%) Unit: Zergling, Tag: 0x100480001, ScreenPos: [46, 159], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x1006c0001, ScreenPos: [69, 155], Distance: 8, Health: 35 (100%) Unit: Zergling, Tag: 0x100580001, ScreenPos: [59, 154], Distance: 9, Health: 6 (17%) Unit: Zergling, Tag: 0x100740001, ScreenPos: [130, 134], Distance: 2, Health: 35 (100%) Unit: Zergling, Tag: 0x1005c0001, ScreenPos: [97, 142], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100380001, ScreenPos: [39, 183], Distance: 12, Health: 35 (100%) Unit: Zergling, Tag: 0x100080001, ScreenPos: [106, 151], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100300001, ScreenPos: [124, 137], Distance: 2, Health: 35 (100%) Relevant Knowledge: Protoss.Colossus The large quad-legged vehicle fires lasers in a splash pattern well-suited to destroying swarms of weaker units. This unit can also traverse differences in terrain height due to its long legs, and will appear to step over ledges and other obstacles due to the inverse kinematics system. Unit properties: ['ground', 'air', 'armored', 'massive', 'mechanical'] Weapon info: Attack Range 7, target: ['ground'], anti: ['light'], DPS(damage per second) 13, DPS-anti 20 Unit abilities: Zerg.Zergling Fast but weak melee attacker ideal for swarming attacks in large numbers. Unit properties: ['ground', 'light', 'biological'] Weapon info: Attack Range 1, target: ['ground'], DPS(damage per second) 10 Valid Actions: Team Colossus-1 Valid Actions: <Attack_Unit(tag)> <Move_Screen(screen)> Action Args: (1) tag: tag refers to a hexadecimal number, shape as 0x000000000. (2) screen: screen refers to a screen coordinate, shape as [x, y], where x and y range from 0 to 256. (3) minimap: minimap refers to a minimap coordinate, shape as [x, y], where x and y range from 0 to 64. For example, when you want to use an action like <Action_Name(tag, screen)>, you should output like <Action_Name(0x100580001, [37, 55])>; when you want to use an action like <Action_Name(screen)>, you should output like <Action_Name([66, 78])>. Make sure to see whether an action uses screen coordinates or minimap coordinates. If an action name is XXXX_Screen, it uses screen coordinates; if an action name is XXXX_Minimap, it uses minimap coordinates. Last Step Actions: Team Colossus-1: <Move_Screen([160, 130])> <Attack_Unit(0x1007c0001)> <Attack_Unit(0x100740001)> You need to confirm whether the previous action finished executing, and based on this, determine whether to continue the old strategy or immediately take other actions. Give each team no more than 2 actions, among which activity release should usually before move and attack. Now, start generating your analysis and actions: """ self.eop = \ """

Analysis:

  1. Decision Process

    1.1 Condition Assessment

    text
    - IS_COLOSSUS_HIGH_GROUND = True The Colossus is currently on the high ground, confirmed via the image and coordinates. - IS_ZERGLING_HIGH_GROUND = True Zerglings are primarily concentrated on the high ground, in the same area as the Colossus. - IS_ZERGLING_NEAR_COLOSSUS = True Multiple Zerglings are close to the Colossus and within its attack range (&le;7), posing an immediate threat. - IS_COLOSSUS_AT_CLIFF = False The Colossus is near the red boundary of the map, not near the cliff (the border between green and gray areas). - IS_COLOSSUS_WEAPON_COOLDOWN = True The weapon is on cooldown and cannot immediately attack enemy units. - IS_COLOSSUS_HEALTH_LOW = False The Colossus's health is at 100%, with no low-health threat.

    1.2 Action Decision Rules

    Decision basis:
    1. Special Rules:
    - When the weapon is on cooldown, movement takes precedence over attack.
    - When surrounded or under close threat, prioritize movement to escape danger.

    text
    2. Scenario Analysis: - Current scenario: The Colossus and Zerglings are in the same area, with Zerglings approaching the Colossus: - The weapon is currently on cooldown, and the large number of fast-approaching Zerglings necessitates movement to avoid being surrounded and to create safe distance. - Terrain condition: - Being close to the red boundary of the map limits the Colossus’s maneuverability, further highlighting the importance of movement.

    1.3 Judgment Based on Action Decision Rules

    • Prioritize matching the special rule: Weapon cooldown (Move > Attack). The current scenario matches the special rule, prioritizing movement to retreat, avoid being surrounded, and gain time for the weapon cooldown.
    • Move > Attack
      The high ground space is insufficient, and with enemies advancing and the weapon on cooldown, the Colossus must immediately retreat to the low ground, using the cliff to delay Zergling pursuit and buy time for the cooldown.
  2. Integrated Strategy and Decision Framework

    2.1 Strategy Suggestions

    text
    Current Strategy: Emergency Retreat to Low Ground - The Colossus and Zerglings are both on the high ground. Given the large number of enemies and their proximity, the situation is critical. - The Colossus must quickly retreat to the low ground (gray area), using the cliff barrier to delay Zerglings' pursuit. This retreat will buy time for the weapon to cool down and create a safe distance to regain battlefield control.

    2.2 Movement Decision Analysis

    -Enemy Approach Path Prediction
    - Zerglings are advancing from the left pathway on the high ground, attempting to encircle the Colossus.
    - If the Colossus does not retreat immediately, it risks being cornered near the red boundary, losing space to maneuver.

    • Movement Target Suggestions

      • Retreat directly to screen coordinates [160, 200], a safe area near the cliff on the low ground.
      • Crossing the cliff to the low ground will delay Zerglings' pursuit, providing more survival space and reducing the risk of melee attacks.
    • Reason:

      • Directly retreating to the low ground avoids encirclement by Zerglings. The cliff barrier delays enemy pursuit, ensuring the Colossus's safety.

    2.3 Attack Decision Analysis

    text
    - Target Prioritization: - Once the weapon cooldown ends, prioritize attacking the nearest Zerglings to reduce immediate threats and maximize splash damage. - Attack Target Selection: - The closest Zerglings (e.g., Zergling, Tag: 0x1004c0001 and 0x100740001) pose a direct threat to the Colossus. - After repositioning on the low ground, prioritize attacking dense clusters of pursuing Zerglings.

3 .Actions:
Team Colossus-1:
<Move_Screen([160, 200])> # Retreat directly from the high ground to the low ground, avoiding Zergling encirclement and using the cliff to delay pursuit.
<Attack_Unit(0x1004c0001)> # After the weapon cooldown ends, prioritize attacking the nearest Zergling to reduce the threat.
<Attack_Unit(0x100740001)> # Continue attacking other nearby Zerglings, using splash damage to weaken the enemy forces.
"""

text
# Part 2 if self.config.ENABLE_COMMUNICATION: self.sp += \ """ 4.Communication Output If there is Available Communicate Target, you should keep communicating with them by Communication functions. For example, if 'Commander' and 'CombatGroup4' in Available Communicate Target, you can output as: Communications: <MessageTo(Commander, '''xxxxxxxxxx''')> <MessageTo(CombatGroup4, '''xxxxxxxxxx''')> """ self.eip += \ """ Communication: From Commander: Your task is to attack the enemy workers of an enemy base near minimap [48,32]. Intelligence shows that two enemy Queens are located on the minimap [44,32]. Try to avoid being detected by enemy Queens before arriving. Available Communication Tragets: Commander: Protoss military supreme commander. Responsible for making macro decision through communication, and controls nexus for massrecall for tactical objectives. Available Communication Functions: <MessageTo(AgentName, message)> <MessageTo(ChannelName, message)> <ListenTo(ChannelName)> Args explanation: (1)AgentName: refers to a name mentioned in Available Communication Tragets. (2)ChannelName: shape as Channel-i, i refers to an integer. (2)message: any text wrapped between ''' and '''. """ self.eop += \ """ Communications: <MessageTo(Commander, '''Copy that, we have arrived enemy base, and started attack enemy workers''')> """ # Part 3 self.eip += \ f"""

Give each team no more than {self.config.MAX_NUM_ACTIONS} actions.
Now, start generating your analysis and actions:
"""

class CommanderPrompt(BasePrompt): # TODO: Design a prompt specifically for the supreme military commander
def init(self, name, log_id, config):
super(CombatGroupPrompt, self).init()
self.name = name
self.config = config
self.log_id = log_id
# self.sp = ''
# self.eip = ''
# self.eop = ''

class DeveloperPrompt(BasePrompt): # TODO: Design a prompt specifically for the supreme logistics commander
def init(self, name, log_id, config):
super(CombatGroupPrompt, self).init()
self.name = name
self.config = config
self.log_id = log_id
# self.sp = ''
# self.eip = ''
# self.eop = ''

PROTOSS_FACTORY = {
'default': CombatGroupPrompt,
'commander': CommanderPrompt,
'developer': DeveloperPrompt,
}
TERRAN_FACTORY = {}
ZERG_FACTORY = {}

FACTORY = {
'protoss': PROTOSS_FACTORY,
'terran': TERRAN_FACTORY,
'zerg': ZERG_FACTORY,
}

if name == "main":
from llm_pysc2.agents.configs.config import ProtossAgentConfig

text
config = ProtossAgentConfig() prompt = CombatGroupPrompt('CombatGroup1', log_id=0, config=config) print("--" * 25 + "System Prompt" + "--" * 25) print(prompt.sp) print("--" * 25 + "Example Input Prompt" + "--" * 25) print(prompt.eip) print("--" * 25 + "Example Output Prompt" + "--" * 25) print(prompt.eop)

사고

剖析项目代码

我正在详细描述Visual-CoT项目的代码,尤其关注基于CombatGroupPrompt类生成的各种提示。希望这可以帮助你理解。

思考,持续 几秒

답변

理解 Visual-CoT 框架中的思维链代码

您提供的代码片段展示了 Visual-CoT 框架在 LLM-PySC2 环境中的具体实现,特别是用于生成和管理提示(prompts)的部分。以下是对该代码的详细解析及其在整个 Visual-CoT 框架中的作用。

代码概览

该代码主要定义了多个类,用于生成 Visual-CoT 框架所需的系统提示、示例输入和输出提示。这些提示指导大型语言模型(LLM)在 StarCraft II 的复杂环境中进行精细化动作控制和决策。以下是代码的主要组成部分:

  1. BasePrompt 类
  2. CombatGroupPrompt 类
  3. CommanderPrompt 和 DeveloperPrompt 类(待完成)
  4. 单位工厂(FACTORY)
  5. 主程序部分

详细解析

1. BasePrompt 类
python
class BasePrompt: def __init__(self): self.sp = '' self.eip = '' self.eop = '' self.screen_img_rgb_prompt = '' self.screen_img_fea_prompt = '' self.minimap_img_rgb_prompt = '' self.minimap_img_fea_prompt = ''

功能

  • 作为其他具体提示类的基类,BasePrompt 定义了基础属性,包括系统提示 (sp)、示例输入提示 (eip)、示例输出提示 (eop)、以及屏幕和小地图的 RGB 图像提示和特征图提示。
  • 这些属性将在子类中被具体填充,以适应不同的任务和场景需求。
2. CombatGroupPrompt 类
python
class CombatGroupPrompt(BasePrompt): def __init__(self, name, log_id, config): super(CombatGroupPrompt, self).__init__() self.name = name self.config = config self.log_id = log_id # Part 1: System Prompt self.sp = f""" 1. Role Description You are a {self.config.AGENTS[self.name]['describe']}. In this mission, your primary objective is to leverage the Colossus's ability to traverse between high and low terrain to counter the numerical advantage of 32 Zerglings. Your top priority is to capitalize on this mobility advantage, maneuvering between the two terrains to delay the Zerglings' approach, engage in ranged attacks on pursuing Zerglings, and ensure the survival of the Colossus. 2.Map Information ... """ # Example Input Prompt self.eip = \ """ Game Info Time: 0:05 Team Colossus-1 Info: Team minimap position: [31, 27] Controlled Team Units: Unit: Colossus, Tag: 0x100000001, ScreenPos: [150, 123], Health: 350 (100%), Weapon Cooldown Time: 0.91s Nearby Enemy Units: Unit: Zergling, Tag: 0x1002c0001, ScreenPos: [52, 164], Distance: 10, Health: 6 (17%) ... """ # Example Output Prompt self.eop = \ """ Analysis: 1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True The Colossus is currently on the high ground, confirmed via the image and coordinates. - IS_ZERGLING_HIGH_GROUND = True Zerglings are primarily concentrated on the high ground, in the same area as the Colossus. ... 2. Integrated Strategy and Decision Framework 2.1 Strategy Suggestions Current Strategy: Emergency Retreat to Low Ground ... 3 .Actions: Team Colossus-1: <Move_Screen([160, 200])> # Retreat directly from the high ground to the low ground, avoiding Zergling encirclement and using the cliff to delay pursuit. <Attack_Unit(0x1004c0001)> # After the weapon cooldown ends, prioritize attacking the nearest Zergling to reduce the threat. <Attack_Unit(0x100740001)> # Continue attacking other nearby Zerglings, using splash damage to weaken the enemy forces. """ # Part 2: Communication Output (条件启用) if self.config.ENABLE_COMMUNICATION: self.sp += \ """ 4.Communication Output If there is Available Communicate Target, you should keep communicating with them by Communication functions. For example, if 'Commander' and 'CombatGroup4' in Available Communicate Target, you can output as: Communications: <MessageTo(Commander, '''xxxxxxxxxx''')> <MessageTo(CombatGroup4, '''xxxxxxxxxx''')> """ self.eip += \ """ Communication: From Commander: Your task is to attack the enemy workers of an enemy base near minimap [48,32]. Intelligence shows that two enemy Queens are located on the minimap [44,32]. Try to avoid being detected by enemy Queens before arriving. Available Communication Targets: Commander: Protoss military supreme commander. Responsible for making macro decision through communication, and controls nexus for mass recall for tactical objectives. Available Communication Functions: <MessageTo(AgentName, message)> <MessageTo(ChannelName, message)> <ListenTo(ChannelName)> Args explanation: (1)AgentName: refers to a name mentioned in Available Communication Targets. (2)ChannelName: shape as Channel-i, i refers to an integer. (2)message: any text wrapped between ''' and '''. """ self.eop += \ """ Communications: <MessageTo(Commander, '''Copy that, we have arrived enemy base, and started attack enemy workers''')> """ # Part 3: Additional Instructions self.eip += \ f""" Give each team no more than {self.config.MAX_NUM_ACTIONS} actions. Now, start generating your analysis and actions: """

功能

  • CombatGroupPrompt 类继承自 BasePrompt,并根据传入的 name, log_id, 和 config 参数初始化特定的提示内容。
  • 系统提示(System Prompt) (self.sp):定义了角色描述、地图信息、关键胜利点、决策过程和综合战略决策框架。该部分详细描述了 Colossus 的任务目标、地图的地形特征、胜利策略以及决策规则。
  • 示例输入提示(Example Input Prompt) (self.eip):提供了当前游戏的详细信息,包括时间、团队位置、受控单位信息、附近敌方单位信息、相关知识和有效动作列表。这些信息帮助模型理解当前战场状态。
  • 示例输出提示(Example Output Prompt) (self.eop):展示了预期的分析和行动输出,包括决策过程、综合战略建议、动作决策分析以及具体的行动指令。

通信部分

  • config.ENABLE_COMMUNICATIONTrue 时,代码会额外添加通信输出部分,定义了与指挥官或其他战斗组的通信方式和内容。这允许模型在需要时与其他代理进行信息交流,增强多智能体协作能力。

额外指令

  • 在示例输入提示的最后,明确指出每个团队最多只能执行一定数量的动作,并指示模型开始生成分析和行动。
3. CommanderPrompt 和 DeveloperPrompt 类
python
class CommanderPrompt(BasePrompt): # TODO: Design a prompt specifically for the supreme military commander def __init__(self, name, log_id, config): super(CombatGroupPrompt, self).__init__() self.name = name self.config = config self.log_id = log_id # self.sp = '' # self.eip = '' # self.eop = '' class DeveloperPrompt(BasePrompt): # TODO: Design a prompt specifically for the supreme logistics commander def __init__(self, name, log_id, config): super(CombatGroupPrompt, self).__init__() self.name = name self.config = config self.log_id = log_id # self.sp = '' # self.eip = '' # self.eop = ''

功能

  • 这两个类(CommanderPromptDeveloperPrompt)目前是占位符,标有 TODO 注释,表明未来需要为指挥官和物流指挥官设计特定的提示内容。
  • 继承自 BasePrompt,未来可以根据不同角色的职责和需求,定义各自的系统提示、示例输入和输出提示。
4. 单位工厂(FACTORY)
python
PROTOSS_FACTORY = { 'default': CombatGroupPrompt, 'commander': CommanderPrompt, 'developer': DeveloperPrompt, } TERRAN_FACTORY = {} ZERG_FACTORY = {} FACTORY = { 'protoss': PROTOSS_FACTORY, 'terran': TERRAN_FACTORY, 'zerg': ZERG_FACTORY, }

功能

  • 定义了一个工厂模式,用于根据种族(Protoss, Terran, Zerg)和角色(default, commander, developer)生成相应的提示对象。
  • 目前,Terran 和 Zerg 的工厂部分为空,表明未来可能会添加针对这些种族的特定提示类。
5. 主程序部分
python
if __name__ == "__main__": from llm_pysc2.agents.configs.config import ProtossAgentConfig config = ProtossAgentConfig() prompt = CombatGroupPrompt('CombatGroup1', log_id=0, config=config) print("--" * 25 + "System Prompt" + "--" * 25) print(prompt.sp) print("--" * 25 + "Example Input Prompt" + "--" * 25) print(prompt.eip) print("--" * 25 + "Example Output Prompt" + "--" * 25) print(prompt.eop)

功能

  • 导入 ProtossAgentConfig 配置类,初始化 config 对象。
  • 创建一个 CombatGroupPrompt 实例,指定名称为 'CombatGroup1',日志 ID 为 0,并传入配置对象。
  • 打印出生成的系统提示、示例输入提示和示例输出提示,便于调试和验证提示内容的正确性。

在 Visual-CoT 框架中的作用

  1. 提示生成与管理
    • 通过定义 CombatGroupPrompt 类,框架能够生成详细的系统提示、示例输入和输出提示。这些提示指导 LLM 在特定的战斗场景中进行分析和决策。
  2. 多模态信息整合
    • 提示中不仅包含了文本信息(如单位位置、健康状态、地图信息等),还通过视觉信息(如 RGB 图像提示)增强了模型对战场环境的理解能力。
  3. 决策过程的透明化
    • 通过详细的决策过程描述(如条件评估、动作优先级判断、策略建议等),确保模型的决策过程透明且可解释,有助于优化和调试。
  4. 多智能体协作
    • 当启用通信功能时,提示中还包含了与指挥官或其他战斗组的通信方式和内容,增强了多智能体之间的协作能力。
  5. 灵活的扩展性
    • 工厂模式的设计允许框架灵活地添加不同种族和角色的提示类,便于未来扩展和适应更多的战斗场景和需求。

示例输出解析

以下是您提供的 Example Output Prompt 的示例输出:

plaintext
Analysis: 1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True The Colossus is currently on the high ground, confirmed via the image and coordinates. - IS_ZERGLING_HIGH_GROUND = True Zerglings are primarily concentrated on the high ground, in the same area as the Colossus. - IS_ZERGLING_NEAR_COLOSSUS = True Multiple Zerglings are close to the Colossus and within its attack range (&le;7), posing an immediate threat. - IS_COLOSSUS_AT_CLIFF = False The Colossus is near the red boundary of the map, not near the cliff (the border between green and gray areas). - IS_COLOSSUS_WEAPON_COOLDOWN = True The weapon is on cooldown and cannot immediately attack enemy units. - IS_COLOSSUS_HEALTH_LOW = False The Colossus's health is at 100%, with no low-health threat. 1.2 Action Decision Rules Decision basis: 1. Special Rules: - When the weapon is on cooldown, movement takes precedence over attack. - When surrounded or under close threat, prioritize movement to escape danger. 2. Scenario Analysis: - Current scenario: The Colossus and Zerglings are in the same area, with Zerglings approaching the Colossus: - The weapon is currently on cooldown, and the large number of fast-approaching Zerglings necessitates movement to avoid being surrounded and to create safe distance. - Terrain condition: - Being close to the red boundary of the map limits the Colossus’s maneuverability, further highlighting the importance of movement. 1.3 Judgment Based on Action Decision Rules - Prioritize matching the special rule: Weapon cooldown (Move > Attack). The current scenario matches the special rule, prioritizing movement to retreat, avoid being surrounded, and gain time for the weapon cooldown. - Move > Attack The high ground space is insufficient, and with enemies advancing and the weapon on cooldown, the Colossus must immediately retreat to the low ground, using the cliff to delay Zergling pursuit and buy time for the cooldown. 2. Integrated Strategy and Decision Framework 2.1 Strategy Suggestions Current Strategy: Emergency Retreat to Low Ground - The Colossus and Zerglings are both on the high ground. Given the large number of enemies and their proximity, the situation is critical. - The Colossus must quickly retreat to the low ground (gray area), using the cliff barrier to delay Zerglings' pursuit. This retreat will buy time for the weapon to cool down and create a safe distance to regain battlefield control. 2.2 Movement Decision Analysis -Enemy Approach Path Prediction - Zerglings are advancing from the left pathway on the high ground, attempting to encircle the Colossus. - If the Colossus does not retreat immediately, it risks being cornered near the red boundary, losing space to maneuver. - Movement Target Suggestions - Retreat directly to screen coordinates [160, 200], a safe area near the cliff on the low ground. - Crossing the cliff to the low ground will delay Zerglings' pursuit, providing more survival space and reducing the risk of melee attacks. - Reason: - Directly retreating to the low ground avoids encirclement by Zerglings. The cliff barrier delays enemy pursuit, ensuring the Colossus's safety. 2.3 Attack Decision Analysis - Target Prioritization: - Once the weapon cooldown ends, prioritize attacking the nearest Zerglings to reduce immediate threats and maximize splash damage. - Attack Target Selection: - The closest Zerglings (e.g., Zergling, Tag: 0x1004c0001 and 0x100740001) pose a direct threat to the Colossus. - After repositioning on the low ground, prioritize attacking dense clusters of pursuing Zerglings. 3 .Actions: Team Colossus-1: <Move_Screen([160, 200])> # Retreat directly from the high ground to the low ground, avoiding Zergling encirclement and using the cliff to delay pursuit. <Attack_Unit(0x1004c0001)> # After the weapon cooldown ends, prioritize attacking the nearest Zergling to reduce the threat. <Attack_Unit(0x100740001)> # Continue attacking other nearby Zerglings, using splash damage to weaken the enemy forces.

解析

  • 分析部分
    • 决策过程:详细评估了当前战场状态,包括 Colossus 和 Zerglings 的位置、健康状态、武器冷却时间等关键条件。
    • 动作决策规则:基于条件评估,回顾并应用了预设的决策规则,优先级为移动大于攻击。
  • 综合战略与决策框架
    • 战略建议:提出了紧急撤退到低地的策略,利用悬崖延迟 Zerglings 的追击,确保 Colossus 的生存。
    • 移动决策分析:预测了敌方的进攻路径,并建议了具体的移动目标坐标,以避开包围并利用地形优势。
    • 攻击决策分析:在武器冷却结束后,优先攻击最接近的 Zerglings,以减少威胁并最大化溅射伤害。
  • 行动输出部分
    • 生成了具体的操作指令,指导 Colossus 移动和攻击的具体目标。

项目扩展与未来工作

根据您提供的代码及其当前实现,以下是一些建议和未来的扩展方向,以进一步提升 Visual-CoT 框架的功能和适用性:

  1. 完善指挥官和物流指挥官的提示

    • 当前 CommanderPromptDeveloperPrompt 类是占位符,建议根据不同角色的职责,设计详细的系统提示、示例输入和输出提示。例如,指挥官需要更多的宏观战略指导,而物流指挥官可能需要关注资源管理和单位部署。
  2. 扩展至 Terran 和 Zerg 种族

    • 目前工厂模式中 Terran 和 Zerg 部分为空,建议为这些种族设计特定的提示类,以适应不同种族的单位特性和战术需求。
  3. 增强通信功能

    • 当启用通信时,可以设计更复杂的通信协议和策略,允许多个智能体之间进行更高效的信息交换和协同作战。
  4. 集成更先进的视觉处理技术

    • 通过引入更先进的计算机视觉技术,如目标检测和图像分割,提升模型对战场环境的感知和理解能力,进一步增强决策的准确性和效率。
  5. 跨领域应用

    • Visual-CoT 框架应用于其他需要多模态信息整合和精细化控制的领域,如机器人控制、自动驾驶和虚拟助手等,拓展其应用范围和影响力。
  6. 优化提示设计

    • 根据实际实验结果,不断优化系统提示和示例输入输出提示,确保提示内容能够最大程度地指导模型进行准确的分析和决策。

总结

您提供的 Visual-CoT 框架通过结合视觉信息和思维链推理,显著提升了大型语言模型在 StarCraft II 等复杂策略游戏中的动作控制和决策能力。通过详细设计系统提示、示例输入和输出提示,框架确保模型能够深入理解战场环境,制定有效的战略并执行精准的操作。未来,通过完善各类提示、扩展支持的种族和角色、以及集成更先进的技术,Visual-CoT 框架有望在多智能体协作和复杂决策任务中发挥更大的作用。

질문

这个提示词是visual-cot的提示词,请你理解
D:\Anaconda\envs\starcraftii0828\python.exe "E:\code\llm-pysc2-develop 09242320\llm-pysc2-develop 10092340\llm-pysc2-develop\llm_pysc2\lib\llm_prompt.py"
pygame 2.6.0 (SDL 2.28.4, Python 3.9.19)
Hello from the pygame community. https://www.pygame.org/contribute.html
--------------------------------------------------System Prompt--------------------------------------------------

text
1. Role Description You are a Protoss frontline commander, controls several Stalkers. Responsible for providing cover for the main force and restraining enemy forces.. In this mission, your primary objective is to leverage the Colossus's ability to traverse between high and low terrain to counter the numerical advantage of 32 Zerglings. Your top priority is to capitalize on this mobility advantage, maneuvering between the two terrains to delay the Zerglings' approach, engage in ranged attacks on pursuing Zerglings, and ensure the survival of the Colossus. 2.Map Information 2.1 Coordinate System: - The screen coordinate system is a 2D grid with a range of [0, 256] &times; [0, 256]. - Each grid cell measures 32 &times; 32 pixels, resulting in a total of 8 &times; 8 = 64 grid cells. - The origin point (0, 0) is at the top-left corner, while (256, 256) is at the bottom-right corner. 2.2 Terrain Information: - Pathway (connecting the high ground and low ground): The map consists of an upper platform (high ground) and a lower platform (low ground), connected by a narrow pathway on the left side. - High Ground (light green area): The high ground is characterized by light green grass textures and is located on the upper platform. - Low Ground (dark gray area): The low ground is characterized by dark gray concrete textures and is located on the lower platform. - Impassable Area (black background): The edges of the map consist of a black background, which is impassable. The Colossus must avoid entering these areas. - Cliff (light gray vertical surface): The cliff separates the high ground and low ground. The Colossus can freely traverse the cliff, but Zerglings can only access the high ground through the narrow pathway on the left. Only the boundary between the high ground and low ground is considered a cliff; other deep red boundaries are impassable edges of the map. - Boundary: The boundaries between the high ground and the black background, as well as between the low ground and the black background, are considered impassable edges of the map. The boundaries are represented by deep red lines on the map. 3. Key Victory Points: 3.1 Maintain Maximum Attack Range: - Ideally, the Colossus should stay within its maximum attack range (range 7) to fully utilize its long-range attack advantage while minimizing the risk of melee attacks from enemies. 3.2 Focus Fire on Dense Enemy Clusters: - Target the center of the densest enemy groups to maximize splash damage and quickly reduce enemy numbers. 3.3 Cliff Barrier Delay Effect: The Cliff Barrier Delay Effect refers to leveraging the terrain characteristics of cliffs, where enemy units cannot directly cross the cliff, while allied units can freely traverse it. This forces the enemy to take a detour when transitioning between high and low ground, buying time for allied units to reposition, cool down weapons, and strike effectively. - When enemies are heavily concentrated on the high ground: - If allied units are also on the high ground but risk being surrounded, it is recommended to retreat to the bottom-right low ground. This utilizes the cliff as a barrier to delay enemy pursuit, enabling ranged attacks on the enemies while maintaining battlefield control. - When enemies are heavily concentrated on the low ground: - If allied units are also on the low ground but risk being surrounded, it is recommended to retreat to the top-right high ground. The cliff barrier forces enemies to take a detour, providing time for allied units to reposition and counterattack effectively.

4. Decision Process
Based on the observed data of the Colossus and Zerglings, as well as the RGB image of the screen, use the following decision rules to determine action priorities:

text
4.1 Condition Assessment Rules: - IS_HIGH_GROUND: - Criteria: If the Colossus is on the green high ground (above the cliff, with a clear boundary from the low ground), set to True; otherwise, set to False. - Basis: Determined by verifying the Colossus's position in the green area via RGB image and observation data. - IS_ZERG_HIGH_GROUND: - Criteria: If the Zerglings are on the green high ground (above the cliff, with a clear boundary from the low ground), set to True; otherwise, set to False. - Basis: Determined by analyzing the Zerglings' positions via RGB image. - IS_ZERG_NEAR: - Criteria: If at least 5 Zerglings are within the attack range (&le;7) or attempting to surround the Colossus, set to True; otherwise, set to False. - Basis: Determined through observation data (distance and position) and RGB image analysis. - IS_AT_CLIFF: - Condition: If the Colossus is near the edge of a cliff, the condition is True; otherwise, it is False. It is important to distinguish between a cliff and a boundary. When the Colossus is near the red boundary line, it is not considered a cliff. A cliff is the transitional area between the highland and the lowland. - Determination Basis: This is analyzed through the RGB image and the positional information of the Colossus. - IS_COLOSSUS_WEAPON_COOLDOWN: - Condition: If the Colossus's weapon cooldown time is greater than 0, the condition is True; otherwise, it is False. - Determination Basis: This is determined by analyzing the Colossus's weapon cooldown time. - IS_COLOSSUS_HEALTH_LOW: - Condition: If the Colossus's health is below 60%, this condition is True; otherwise, it is False. - Determination Basis: Determined by observing the Colossus's health. 4.2 Action Decision Rules - Special Scenarios: rule1 :As long as the weapon is in cooldown, the priority of movement actions is higher than attack actions. Movement > Attack. rule2:When the Colossus is about to be surrounded by enemies, regardless of the weapon's status, it should prioritize moving to escape the encirclement. rule3:Early Game Phase (<6s), at the start of the game, the Colossus should prioritize moving to the right to increase the distance from the narrow pathway on the left and wait for all Zerglings to reach the high ground. During this phase, movement takes priority over attacking. - Situation 1: The Colossus and Zerglings are in different areas - Weapon not on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = False): - Priority: Attack. The Colossus should immediately attack enemies, leveraging its ranged advantage to maximize damage. - Weapon on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = True): - Priority: Move. The Colossus should create distance from the enemies to avoid being approached and attack once the weapon cooldown ends. - Situation 2: The Colossus and Zerglings are in the same area - Enemies are near and about to attack (IS_ZERG_NEAR = True, Zerglings approaching): - Priority: Move. Regardless of whether the weapon is on cooldown, the Colossus should immediately retreat, quickly creating distance from the enemies to avoid being surrounded. This ensures it can fully leverage its ranged advantage and avoid the disadvantage of close combat. Once out of danger, it can then look for opportunities to counterattack. - Enemies are not near (IS_ZERG_NEAR = False): - Weapon not on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = False): - Priority: Attack. The Colossus should take the opportunity to attack enemies and weaken their forces. - Weapon on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = True): - Priority: Move. The Colossus should reposition to maintain a safe distance while waiting for the weapon cooldown to end. - Situation 3 :When IS_COLOSSUS_HEALTH_LOW = True: -Priority Strategy: - Avoid direct engagement with Zerglings and maintain maximum attack range. - Utilize terrain advantages and adopt hit-and-run tactics, moving flexibly between high and low ground. - Priority: Movement > Attack

5 Integrated Strategy and Decision Framework
1. Strategy Suggestions

text
1.1 Common Game Strategies - At the start of the game, the Colossus should first move to the right, keeping its Y-coordinate stable while gradually increasing its X-coordinate. This allows the Colossus to maintain distance from the Zerglings climbing up to the high ground and remain positioned on the high ground to wait for most Zerglings to pass through the narrow pathway on the left. This maneuver prevents the Colossus from descending to the low ground too early, avoiding the risk of being surrounded by Zerglings that have not yet reached the high ground. - Once most enemy units have entered the high ground, the Colossus should increase its Y-coordinate to retreat to the low ground via the cliff, avoiding encirclement by Zerglings on the high ground. 1.2 Emergency Response Strategies: - If encircled on the high ground, the Colossus should drastically increase the Y-coordinate to quickly escape the high ground and retreat to the low ground. - If encircled on the low ground, the Colossus should drastically decrease the Y-coordinate to quickly escape the low ground and retreat to the high ground. 2. Movement and Attack Decision 2.1 When Movement Is Required: - Phase Judgment: - Determine the current phase based on game time and the positions of both allied and enemy units. - Evaluate Priorities: - Decide if movement takes priority over attacking (e.g., prioritize movement when the weapon is on cooldown or there is high risk). - Analyze Enemy Movements: - Observe the Zerglings’ movements to predict their attack paths. - Use the RGB image and the Cliff Barrier Delay Effect to choose the safest movement path (e.g., move down-right or up-right). - Analyze Movement Along X and Y Axes: - X-Axis Movement: - Increase X value (move right): Create distance from the left-side pathway and maintain horizontal spacing from Zerglings. - Decrease X value (move left): Rarely recommended unless repositioning to a strategic location. - Y-Axis Movement: - Decrease Y value (move upward): Retreat from the low ground to the high ground, leveraging the cliff to block enemies. - Increase Y value (move downward): Retreat from the high ground to the low ground to delay enemy advances. 2.2 When Attacking Is Required: - Target Selection: - Prioritize the densest groups of enemies to maximize splash damage. - Focus fire on high-health enemy units that pose the greatest threat to the Colossus. - Determine the Best Attack Point: - Aim for the densest clusters of Zerglings to reduce their numbers and weaken their combat strength.

6.Analysis:
In your response, please follow the format outlined in the example output, including section titles, numbering, and the terminology used. Ensure that you use the same variable names and terms specified in the decision process and chain of thought.

text
The output should include: 1. Decision Process 1.1 Condition Assessment: - `IS_COLOSSUS_HIGH_GROUND = True/False` - `IS_ZERGLING_HIGH_GROUND = True/False` - `IS_ZERGLING_NEAR_COLOSSUS = True/False` - `IS_COLOSSUS_AT_CLIFF = True/False` - `IS_COLOSSUS_WEAPON_COOLDOWN = True/False` - `IS_COLOSSUS_HEALTH_LOW = True/False' 1.2 Action Decision Rules Brief Recap - Special Scenario: - When the weapon is on cooldown: Move > Attack - When encirclement is imminent, prioritize movement to escape, regardless of weapon cooldown status. - Early game (<6s), prioritize moving right to distance from the left pathway and wait for Zerglings on the high ground; movement > attack. - Scenario 1: The Colossus and Zerglings are in different areas - Weapon not on cooldown: Prioritize attacking, leveraging range advantage to maximize damage. - Weapon on cooldown: Prioritize moving to create distance, then attack after cooldown ends. - Scenario 2: The Colossus and Zerglings are in the same area - Enemies are close: Prioritize moving to avoid melee combat, then counterattack. - Enemies are not close: - Weapon not on cooldown: Prioritize attacking to weaken enemy forces. - Weapon on cooldown: Prioritize moving to maintain a safe distance. - Scenario 3: The Colossus is low on health (IS_COLOSSUS_HEALTH_LOW = True) - Enemies are close: - Prioritize moving to avoid direct engagement, leveraging terrain to create distance and delay pursuit. - Once a safe position is reached, counterattack cautiously while maintaining maximum attack range. - Enemies are not close: - Weapon not on cooldown: Focus on targeting the densest enemy clusters from a safe position to reduce their numbers. - Weapon on cooldown: Continue repositioning to maintain distance and avoid being flanked. 1.3 Judgment Based on 4.2 Action Decision Rules: -Provide movement and attack priorities, e.g., attack > move or move > attack. -Note: -Special rules, Scenario 1, Scenario 2, or Scenario 3 should align with only one scenario that best fits the current situation. -Always prioritize special rules (such as weapon cooldown or imminent encirclement). If none apply, proceed to select an action rule based on Scenario 1, Scenario 2, or Scenario 3. 2 Integrated Strategy and Decision Framework 2.1 Strategy Suggestions - Current Phase Determination: Dynamically determine the strategy based on time, the Colossus’s position, and Zergling distribution. Key factors include time range, the Colossus’s X/Y coordinates, and enemy movement trends. - Consider Common Action Recommendations:: - Early Game Observation Phase: Initially, keep the X-coordinate steady while gradually increasing the Y-coordinate to monitor enemy movements. Utilize the Colossus’s range advantage to weaken enemy forces. - Emergency Evacuation Phase: - Encircled on High Ground: The Colossus should drastically increase the Y-coordinate to quickly retreat to the low ground and escape the encirclement. - Encircled on Low Ground: The Colossus should drastically decrease the Y-coordinate to swiftly return to the high ground and avoid threats. - Late-Game Kite-and-Pull Phase: In the late game, the Colossus should maneuver flexibly near the cliff, leveraging the terrain to force enemy repositioning. Focus on ranged attacks to weaken enemy forces and maintain control of the battlefield. 2.2 Movement Decision Analysis - Enemy Approach Path Prediction: Analyze the primary approach paths of enemy units and identify potential threats. - Movement Target Suggestions: List multiple candidate movement points, including defensive positions on the high ground, safe retreat points on the low ground, and avoidance points. Specify the most suitable movement target (e.g., a safe spot on the high ground or near the cliff on the low ground). Explain the reasoning behind the selection (e.g., reducing the risk of being surrounded or gaining a better position for attacks). 2.3 Attack Decision Analysis - Target Prioritization: Prioritize attacking dense enemy clusters to maximize splash damage. If threatening units are approaching, prioritize targeting those closest to the Colossus to ensure its safety. - Attack Target Selection: Identify multiple candidate attack points (e.g., the center of a dense enemy group or the closest group to the Colossus). Specify the optimal attack point and provide reasoning (e.g., to maximize damage or avoid being overwhelmed). 7.Action Output: Team Colossus-1: Action steps.

--------------------------------------------------Example Input Prompt--------------------------------------------------

text
Game Info Time: 0:05 Team Colossus-1 Info: Team minimap position: [31, 27] Controlled Team Units: Unit: Colossus, Tag: 0x100000001, ScreenPos: [150, 123], Health: 350 (100%), Weapon Cooldown Time: 0.91s Nearby Enemy Units: Unit: Zergling, Tag: 0x1002c0001, ScreenPos: [52, 164], Distance: 10, Health: 6 (17%) Unit: Zergling, Tag: 0x100180001, ScreenPos: [79, 159], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100440001, ScreenPos: [112, 140], Distance: 4, Health: 35 (100%) Unit: Zergling, Tag: 0x100640001, ScreenPos: [38, 176], Distance: 12, Health: 21 (60%) Unit: Zergling, Tag: 0x100700001, ScreenPos: [52, 178], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x100780001, ScreenPos: [42, 169], Distance: 11, Health: 6 (17%) Unit: Zergling, Tag: 0x100540001, ScreenPos: [49, 171], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x100500001, ScreenPos: [91, 146], Distance: 6, Health: 35 (100%) Unit: Zergling, Tag: 0x100800001, ScreenPos: [83, 147], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100280001, ScreenPos: [96, 151], Distance: 6, Health: 21 (60%) Unit: Zergling, Tag: 0x1000c0001, ScreenPos: [59, 162], Distance: 9, Health: 35 (100%) Unit: Zergling, Tag: 0x100040001, ScreenPos: [93, 157], Distance: 6, Health: 35 (100%) Unit: Zergling, Tag: 0x100340001, ScreenPos: [67, 172], Distance: 9, Health: 35 (100%) Unit: Zergling, Tag: 0x1001c0001, ScreenPos: [72, 161], Distance: 8, Health: 6 (17%) Unit: Zergling, Tag: 0x100600001, ScreenPos: [76, 152], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100140001, ScreenPos: [86, 162], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x1004c0001, ScreenPos: [117, 145], Distance: 3, Health: 35 (100%) Unit: Zergling, Tag: 0x100400001, ScreenPos: [66, 164], Distance: 9, Health: 21 (60%) Unit: Zergling, Tag: 0x100200001, ScreenPos: [78, 166], Distance: 8, Health: 35 (100%) Unit: Zergling, Tag: 0x100240001, ScreenPos: [104, 144], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100100001, ScreenPos: [59, 172], Distance: 10, Health: 35 (100%) Unit: Zergling, Tag: 0x1003c0001, ScreenPos: [86, 154], Distance: 7, Health: 6 (17%) Unit: Zergling, Tag: 0x100480001, ScreenPos: [46, 159], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x1006c0001, ScreenPos: [69, 155], Distance: 8, Health: 35 (100%) Unit: Zergling, Tag: 0x100580001, ScreenPos: [59, 154], Distance: 9, Health: 6 (17%) Unit: Zergling, Tag: 0x100740001, ScreenPos: [130, 134], Distance: 2, Health: 35 (100%) Unit: Zergling, Tag: 0x1005c0001, ScreenPos: [97, 142], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100380001, ScreenPos: [39, 183], Distance: 12, Health: 35 (100%) Unit: Zergling, Tag: 0x100080001, ScreenPos: [106, 151], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100300001, ScreenPos: [124, 137], Distance: 2, Health: 35 (100%) Relevant Knowledge: Protoss.Colossus The large quad-legged vehicle fires lasers in a splash pattern well-suited to destroying swarms of weaker units. This unit can also traverse differences in terrain height due to its long legs, and will appear to step over ledges and other obstacles due to the inverse kinematics system. Unit properties: ['ground', 'air', 'armored', 'massive', 'mechanical'] Weapon info: Attack Range 7, target: ['ground'], anti: ['light'], DPS(damage per second) 13, DPS-anti 20 Unit abilities: Zerg.Zergling Fast but weak melee attacker ideal for swarming attacks in large numbers. Unit properties: ['ground', 'light', 'biological'] Weapon info: Attack Range 1, target: ['ground'], DPS(damage per second) 10 Valid Actions: Team Colossus-1 Valid Actions: <Attack_Unit(tag)> <Move_Screen(screen)> Action Args: (1) tag: tag refers to a hexadecimal number, shape as 0x000000000. (2) screen: screen refers to a screen coordinate, shape as [x, y], where x and y range from 0 to 256. (3) minimap: minimap refers to a minimap coordinate, shape as [x, y], where x and y range from 0 to 64. For example, when you want to use an action like <Action_Name(tag, screen)>, you should output like <Action_Name(0x100580001, [37, 55])>; when you want to use an action like <Action_Name(screen)>, you should output like <Action_Name([66, 78])>. Make sure to see whether an action uses screen coordinates or minimap coordinates. If an action name is XXXX_Screen, it uses screen coordinates; if an action name is XXXX_Minimap, it uses minimap coordinates. Last Step Actions: Team Colossus-1: <Move_Screen([160, 130])> <Attack_Unit(0x1007c0001)> <Attack_Unit(0x100740001)> You need to confirm whether the previous action finished executing, and based on this, determine whether to continue the old strategy or immediately take other actions. Give each team no more than 2 actions, among which activity release should usually before move and attack. Now, start generating your analysis and actions:

Give each team no more than 3 actions.
Now, start generating your analysis and actions:

--------------------------------------------------Example Output Prompt--------------------------------------------------

Analysis:

  1. Decision Process

    1.1 Condition Assessment

    text
    - IS_COLOSSUS_HIGH_GROUND = True The Colossus is currently on the high ground, confirmed via the image and coordinates. - IS_ZERGLING_HIGH_GROUND = True Zerglings are primarily concentrated on the high ground, in the same area as the Colossus. - IS_ZERGLING_NEAR_COLOSSUS = True Multiple Zerglings are close to the Colossus and within its attack range (&le;7), posing an immediate threat. - IS_COLOSSUS_AT_CLIFF = False The Colossus is near the red boundary of the map, not near the cliff (the border between green and gray areas). - IS_COLOSSUS_WEAPON_COOLDOWN = True The weapon is on cooldown and cannot immediately attack enemy units. - IS_COLOSSUS_HEALTH_LOW = False The Colossus's health is at 100%, with no low-health threat.

    1.2 Action Decision Rules

    Decision basis:
    1. Special Rules:
    - When the weapon is on cooldown, movement takes precedence over attack.
    - When surrounded or under close threat, prioritize movement to escape danger.

    text
    2. Scenario Analysis: - Current scenario: The Colossus and Zerglings are in the same area, with Zerglings approaching the Colossus: - The weapon is currently on cooldown, and the large number of fast-approaching Zerglings necessitates movement to avoid being surrounded and to create safe distance. - Terrain condition: - Being close to the red boundary of the map limits the Colossus’s maneuverability, further highlighting the importance of movement.

    1.3 Judgment Based on Action Decision Rules

    • Prioritize matching the special rule: Weapon cooldown (Move > Attack). The current scenario matches the special rule, prioritizing movement to retreat, avoid being surrounded, and gain time for the weapon cooldown.
    • Move > Attack
      The high ground space is insufficient, and with enemies advancing and the weapon on cooldown, the Colossus must immediately retreat to the low ground, using the cliff to delay Zergling pursuit and buy time for the cooldown.
  2. Integrated Strategy and Decision Framework

    2.1 Strategy Suggestions

    text
    Current Strategy: Emergency Retreat to Low Ground - The Colossus and Zerglings are both on the high ground. Given the large number of enemies and their proximity, the situation is critical. - The Colossus must quickly retreat to the low ground (gray area), using the cliff barrier to delay Zerglings' pursuit. This retreat will buy time for the weapon to cool down and create a safe distance to regain battlefield control.

    2.2 Movement Decision Analysis

    -Enemy Approach Path Prediction
    - Zerglings are advancing from the left pathway on the high ground, attempting to encircle the Colossus.
    - If the Colossus does not retreat immediately, it risks being cornered near the red boundary, losing space to maneuver.

    • Movement Target Suggestions

      • Retreat directly to screen coordinates [160, 200], a safe area near the cliff on the low ground.
      • Crossing the cliff to the low ground will delay Zerglings' pursuit, providing more survival space and reducing the risk of melee attacks.
    • Reason:

      • Directly retreating to the low ground avoids encirclement by Zerglings. The cliff barrier delays enemy pursuit, ensuring the Colossus's safety.

    2.3 Attack Decision Analysis

    text
    - Target Prioritization: - Once the weapon cooldown ends, prioritize attacking the nearest Zerglings to reduce immediate threats and maximize splash damage. - Attack Target Selection: - The closest Zerglings (e.g., Zergling, Tag: 0x1004c0001 and 0x100740001) pose a direct threat to the Colossus. - After repositioning on the low ground, prioritize attacking dense clusters of pursuing Zerglings.

3 .Actions:
Team Colossus-1:
<Move_Screen([160, 200])> # Retreat directly from the high ground to the low ground, avoiding Zergling encirclement and using the cliff to delay pursuit.
<Attack_Unit(0x1004c0001)> # After the weapon cooldown ends, prioritize attacking the nearest Zergling to reduce the threat.
<Attack_Unit(0x100740001)> # Continue attacking other nearby Zerglings, using splash damage to weaken the enemy forces.

进程已结束,退出代码0

사고

了解详细情况

用户提供了关于Visual-CoT项目的详细描述,并包括一个实际的提示词文件。这个文件包含系统提示、示例输入和输出,以及模型生成基于游戏状态的动作的说明。

了解提示文件

我正在研究实际的提示文件,里面包含系统提示、示例输入和输出,以及关于指令和行为的说明。这样可以形成更全面的理解。

分析提示内容

我正在综合考虑用户希望我理解并处理提示内容的需求。这可能包括生成类似输出、解答关于提示的问题,或对其进行验证。

解析和解答

我正在致力于解释Visual-CoT提示的结构、角色描述、决策过程、动作规则、策略建议、移动和攻击决策分析,以及生成Colossus行动的指导。

思考,持续 5 秒

답변

理解 Visual-CoT 的提示词

您提供的提示词是 Visual-CoT 框架在 LLM-PySC2 环境中用于指导大型语言模型(LLM)在《星际争霸 II》游戏中的具体行动和决策的关键组成部分。以下是对该提示词的详细解析,帮助您全面理解其结构和功能。

提示词结构概览

  1. 系统提示(System Prompt)
  2. 示例输入提示(Example Input Prompt)
  3. 示例输出提示(Example Output Prompt)

每个部分在提示词中起到不同的作用,共同引导模型进行有效的决策和行动生成。


1. 系统提示(System Prompt)

系统提示部分为模型提供了任务背景、环境信息、关键战略点以及决策规则。具体内容包括:

  • 角色描述

    • 定义模型在游戏中的角色,如“Protoss 前线指挥官”,控制多个“Stalkers”。
    • 主要任务目标:利用“Colossus”在高低地形之间的移动能力,抵消敌方32个“Zerglings”的数量优势。
  • 地图信息

    • 坐标系统:2D网格坐标范围为 [0, 256] &times; [0, 256],每个网格单元为 32 &times; 32 像素,总共有 8 &times; 8 = 64 个网格单元。
    • 地形信息
      • 路径:连接高地和低地的狭窄路径。
      • 高地:浅绿色草地纹理,位于上层平台。
      • 低地:深灰色混凝土纹理,位于下层平台。
      • 不可通行区域:地图边缘的黑色背景,Colossus必须避免进入。
      • 悬崖:浅灰色垂直表面,分隔高地和低地,Colossus可以自由穿越,Zerglings只能通过左侧狭窄路径进入高地。
      • 边界:高地与黑色背景、低地与黑色背景之间的深红色线条,视为不可通行的边界。
  • 关键胜利点

    • 保持最大攻击范围:Colossus应保持在其最大攻击范围(范围7)内,充分利用远程攻击优势,减少被近战攻击的风险。
    • 集中火力攻击密集的敌军群体:优先攻击敌军密集区域,最大化溅射伤害,迅速减少敌军数量。
    • 悬崖障碍延迟效果:利用悬崖的地形特性,迫使敌军在高低地之间转换时绕道,延迟其进攻节奏,为己方单位重新定位、武器冷却和有效打击争取时间。
  • 决策过程

    • 基于观察到的Colossus和Zerglings的数据,以及屏幕的RGB图像,使用预定义的决策规则确定行动优先级。
  • 条件评估规则

    • IS_HIGH_GROUND:Colossus是否在高地。
    • IS_ZERG_HIGH_GROUND:Zerglings是否在高地。
    • IS_ZERG_NEAR:是否有至少5个Zerglings在攻击范围内或试图包围Colossus。
    • IS_AT_CLIFF:Colossus是否靠近悬崖边缘。
    • IS_COLOSSUS_WEAPON_COOLDOWN:Colossus的武器是否处于冷却中。
    • IS_COLOSSUS_HEALTH_LOW:Colossus的健康是否低于60%。
  • 动作决策规则

    • 特殊情境
      • 武器冷却时:移动优先于攻击。
      • 即将被包围时:优先移动以逃离包围,无论武器状态如何。
      • 早期游戏阶段(<6秒):优先向右移动,远离左侧狭窄路径,等待Zerglings进入高地;移动优先于攻击。
    • 情境1:Colossus和Zerglings在不同区域
      • 武器未冷却:优先攻击,利用远程优势最大化伤害。
      • 武器冷却中:优先移动,创造与敌人的距离,等待冷却结束后再攻击。
    • 情境2:Colossus和Zerglings在同一区域
      • 敌人接近且即将攻击:优先移动,避免近战包围,利用远程优势。
      • 敌人不接近:
        • 武器未冷却:优先攻击,削弱敌军力量。
        • 武器冷却中:优先移动,保持安全距离。
    • 情境3:Colossus健康低(IS_COLOSSUS_HEALTH_LOW = True)
      • 敌人接近:
        • 优先移动,避免直接交战,利用地形创造距离并延迟追击。
        • 安全位置后,谨慎反击,保持最大攻击范围。
      • 敌人不接近:
        • 武器未冷却:优先攻击密集敌军群体,减少敌人数量。
        • 武器冷却中:继续重新定位,保持距离,避免被侧翼攻击。

2. 示例输入提示(Example Input Prompt)

示例输入部分提供了当前游戏的具体状态,帮助模型理解当前战场环境,内容包括:

  • 游戏信息

    • 时间:如 0:05 表示游戏进行到5秒。
  • 团队信息

    • 团队位置:如 Team minimap position: [31, 27]
    • 受控单位信息
      • 例如 Unit: Colossus, Tag: 0x100000001, ScreenPos: [150, 123], Health: 350 (100%), Weapon Cooldown Time: 0.91s
    • 附近敌方单位信息
      • 列出所有附近的Zerglings,包括其Tag、屏幕位置、距离、健康状态等。
  • 相关知识

    • Protoss.Colossus:描述其属性、武器信息、能力等。
    • Zerg.Zergling:描述其属性、武器信息等。
  • 有效动作

    • 列出团队当前可执行的动作,如 <Attack_Unit(tag)><Move_Screen(screen)>
  • 动作参数说明

    • 解释动作参数的格式和含义,确保模型正确生成动作指令。
  • 上一步动作

    • 列出上一步执行的动作,供模型参考。
  • 额外指令

    • 指示每个团队最多生成一定数量的动作(如 no more than 3 actions)。
    • 指示模型开始生成分析和行动。

3. 示例输出提示(Example Output Prompt)

示例输出部分展示了预期的分析和行动输出格式,内容包括:

  • 分析部分

    • 决策过程
      • 条件评估:列出各个条件的评估结果,如 IS_COLOSSUS_HIGH_GROUND = True
      • 动作决策规则回顾:简要回顾特殊情境和情境分析。
      • 基于动作决策规则的判断:根据评估结果和规则,确定行动优先级,如 Move > Attack
    • 综合战略与决策框架
      • 战略建议
        • 当前战略:如紧急撤退到低地。
      • 移动决策分析
        • 敌军进攻路径预测:分析敌军的主要进攻路径。
        • 移动目标建议:提出具体的移动目标坐标,并解释选择理由。
      • 攻击决策分析
        • 目标优先级:优先攻击密集敌军群体。
        • 攻击目标选择:选择最合适的攻击点,并提供理由。
  • 行动输出部分

    • 具体的操作指令,如:
      plaintext
      Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被Zergling包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的Zergling以减少威胁。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的Zergling,利用溅射伤害削弱敌军力量。

总结

您提供的 Visual-CoT 提示词通过详细的系统提示、示例输入和输出,构建了一个全面的决策和行动生成框架。其主要特点包括:

  1. 角色与任务明确:定义了模型在游戏中的具体角色和任务目标,确保行动与战略一致。
  2. 环境信息详尽:提供了地图的坐标系统、地形特征和边界信息,帮助模型准确理解战场环境。
  3. 决策规则清晰:通过条件评估和动作决策规则,指导模型在不同情境下做出合理的行动选择。
  4. 战略与战术结合:结合宏观战略建议和具体的移动、攻击决策,确保模型在整体战略框架下执行具体战术。
  5. 动作生成规范:明确动作指令的格式和参数,确保生成的动作符合游戏机制和逻辑。

通过这种结构化的提示词设计,Visual-CoT 能够有效引导大型语言模型在复杂的《星际争霸 II》环境中进行高效、精确的决策和行动执行。

如果您有进一步的需求,例如优化提示词、扩展其他角色或种族的提示,或是集成更多的视觉信息处理技术,请随时告知,我将为您提供更详细的建议和支持。

질문

请你帮助我分析,有什么提高精简的空间,有什么合适的思路呢?

사고

分析和提出

我正在分析Visual-CoT框架的详细提示,识别重复信息,提出用更简洁的语言表达和模块化组件的建议,以提高模型的理解和性能。

思考,持续 几秒

답변

提高 Visual-CoT 提示词的精简与优化建议

您提供的 Visual-CoT 提示词结构详尽,涵盖了角色描述、地图信息、关键胜利点、决策规则、战略框架以及具体的分析和行动指令。这种详细性有助于确保模型理解任务和环境,但在实际应用中,过于冗长和复杂的提示词可能导致以下问题:

  1. 模型理解负担加重:过多的信息可能使模型难以抓住关键点,影响决策效率。
  2. 响应时间延长:冗长的提示词会增加输入长度,可能导致响应时间变长。
  3. 维护复杂性增加:复杂的提示词结构不利于后续的维护和更新。

以下是针对提示词精简和优化的具体分析及建议:

一、分析现有提示词的结构与内容

主要组成部分

  1. 系统提示(System Prompt)

    • 角色描述
    • 地图信息
    • 关键胜利点
    • 决策过程与规则
    • 综合战略与决策框架
  2. 示例输入提示(Example Input Prompt)

    • 游戏信息
    • 团队和单位信息
    • 相关知识
    • 有效动作列表
    • 上一步动作
    • 额外指令
  3. 示例输出提示(Example Output Prompt)

    • 分析部分
      • 决策过程
      • 综合战略与决策框架
    • 行动输出部分

冗余与复杂性

  • 重复信息:部分地图信息和决策规则在系统提示和示例输出中重复出现。
  • 过度详细的描述:例如,地图的坐标系统和地形信息过于详细,可能不需要所有细节。
  • 冗长的决策规则:决策规则部分内容丰富,但部分规则可以简化或合并。
  • 不必要的注释与示例:例如,动作参数的详细说明在实际应用中可能不需要每次都重复。

二、优化与精简建议

1. 简化系统提示

当前问题:系统提示过于详尽,包含大量背景信息和详细规则,可能导致模型难以集中关注关键决策点。

优化建议

  • 提取关键要素:仅保留对当前任务最重要的部分,去除不必要的细节。
  • 模块化提示:将提示分为多个部分,按需调用,避免一次性提供所有信息。
  • 使用简洁语言:用更简短的句子表达相同的意思,减少冗长描述。

示例优化

plaintext
1. 角色描述 你是 Protoss 前线指挥官,控制多个 Stalkers,负责为主力部队提供掩护并遏制敌军力量。主要目标是利用 Colossus 在高低地形间的移动能力,抵消 32 个 Zerglings 的数量优势,延迟其进攻,进行远程攻击,确保 Colossus 的生存。 2. 地图信息 - 坐标系统:屏幕坐标为 [0, 256] &times; [0, 256],每个网格单元 32 &times; 32 像素,共 8 &times; 8 个网格。 - 地形特征: - 高地(浅绿):上层平台。 - 低地(深灰):下层平台。 - 悬崖(浅灰):高低地分界,Colossus 可自由穿越,Zerglings 只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7)。 - 集中火力攻击密集敌军群体。 - 利用悬崖延迟敌军追击,重新定位和攻击。
2. 优化决策规则

当前问题:决策规则部分内容丰富,但部分规则可以合并或简化,提高可读性和模型处理效率。

优化建议

  • 合并相似规则:将逻辑相近或相似的规则合并,减少重复。
  • 使用条件嵌套:通过条件嵌套的方式表达优先级,提升逻辑清晰度。

示例优化

plaintext
4. 决策过程 根据 Colossus 和 Zerglings 的数据及屏幕 RGB 图像,使用以下规则确定行动优先级: 4.1 条件评估 - IS_HIGH_GROUND: Colossus 是否在高地。 - IS_ZERG_HIGH_GROUND: Zerglings 是否在高地。 - IS_ZERG_NEAR: 是否有至少 5 个 Zerglings 在攻击范围内或试图包围 Colossus。 - IS_AT_CLIFF: Colossus 是否靠近悬崖边缘。 - IS_COLOSSUS_WEAPON_COOLDOWN: Colossus 的武器是否处于冷却中。 - IS_COLOSSUS_HEALTH_LOW: Colossus 的健康是否低于 60%。 4.2 行动决策规则 - **特殊情境**: 1. 武器冷却中:移动 > 攻击。 2. 即将被包围:优先移动逃离,无视武器状态。 3. 早期游戏 (<6秒):优先向右移动,远离左侧路径;移动 > 攻击。 - **情境1**:Colossus 和 Zerglings 在不同区域 - 武器未冷却:优先攻击,利用远程优势。 - 武器冷却中:优先移动,等待冷却结束后攻击。 - **情境2**:Colossus 和 Zerglings 在同一区域 - 敌人接近:优先移动,避免近战包围。 - 敌人不接近: - 武器未冷却:优先攻击,削弱敌军。 - 武器冷却中:优先移动,保持安全距离。 - **情境3**:Colossus 健康低(IS_COLOSSUS_HEALTH_LOW = True) - 敌人接近: - 优先移动,避免直接交战,利用地形创造距离。 - 安全位置后,谨慎反击,保持最大攻击范围。 - 敌人不接近: - 武器未冷却:优先攻击密集敌军。 - 武器冷却中:继续移动,保持距离。
3. 简化示例输入提示

当前问题:示例输入提示中包含大量单位信息和详细描述,可能使模型难以快速抓取关键信息。

优化建议

  • 突出关键信息:将关键信息(如 Colossus 状态和主要敌军信息)突出显示,减少次要信息的冗余。
  • 使用表格或列表:结构化信息展示,便于模型快速理解。

示例优化

plaintext
--------------------------------------------------示例输入提示-------------------------------------------------- 游戏信息 时间:0:05 团队信息 - 团队位置:Minimap [31, 27] - 控制单位: - Colossus (Tag: 0x100000001): [150, 123], 350 HP (100%), 武器冷却: 0.91s 附近敌军 - Zergling (Tag: 0x1002c0001): [52, 164], 距离: 10, 6 HP (17%) - Zergling (Tag: 0x100180001): [79, 159], 距离: 7, 35 HP (100%) - Zergling (Tag: 0x100440001): [112, 140], 距离: 4, 35 HP (100%) - Zergling (Tag: 0x100640001): [38, 176], 距离: 12, 21 HP (60%) - ... (省略其他 Zerglings) 相关知识 - **Protoss.Colossus**: - 属性:['ground', 'air', 'armored', 'massive', 'mechanical'] - 武器:范围7,目标:['ground'], DPS: 13 - **Zerg.Zergling**: - 属性:['ground', 'light', 'biological'] - 武器:范围1,DPS: 10 有效动作 - <Attack_Unit(tag)> - <Move_Screen(screen)> 动作参数说明 - tag: 十六进制编号,如 0x100580001 - screen: 屏幕坐标 [x, y],0 &le; x, y &le; 256 - minimap: 小地图坐标 [x, y],0 &le; x, y &le; 64 上一步动作 - <Move_Screen([160, 130])> - <Attack_Unit(0x1007c0001)> - <Attack_Unit(0x100740001)> 额外指令 - 每个团队最多 3 个动作。 - 确认上一步动作是否完成,根据情况继续原策略或立即采取新行动。 现在,开始生成您的分析和行动:
4. 优化示例输出提示

当前问题:示例输出提示结构合理,但可以通过减少冗余描述和使用更清晰的格式进一步优化。

优化建议

  • 减少冗余描述:避免在不同部分重复解释相同的逻辑。
  • 使用清晰的层级结构:确保各层级标题和内容逻辑清晰,易于模型解析。

示例优化

plaintext
--------------------------------------------------示例输出提示-------------------------------------------------- Analysis: 1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True Colossus 位于高地,已通过图像和坐标确认。 - IS_ZERG_HIGH_GROUND = True Zerglings 主要集中在高地,与 Colossus 位于同一区域。 - IS_ZERG_NEAR_COLOSSUS = True 多个 Zerglings 靠近 Colossus,位于攻击范围内(&le;7),构成即时威胁。 - IS_COLOSSUS_AT_CLIFF = False Colossus 靠近地图的红色边界,不靠近悬崖。 - IS_COLOSSUS_WEAPON_COOLDOWN = True 武器处于冷却中,无法立即攻击敌军。 - IS_COLOSSUS_HEALTH_LOW = False Colossus 健康状态良好(100%),无低健康威胁。 1.2 Action Decision Rules Brief Recap - **特殊情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏(<6秒):优先向右移动,移动 > 攻击 - **情境1**:Colossus 和 Zerglings 在不同区域 - 武器未冷却:优先攻击,利用远程优势 - 武器冷却中:优先移动,等待冷却结束后攻击 - **情境2**:Colossus 和 Zerglings 在同一区域 - 敌人接近:优先移动,避免近战包围 - 敌人不接近: - 武器未冷却:优先攻击 - 武器冷却中:优先移动 - **情境3**:Colossus 健康低(IS_COLOSSUS_HEALTH_LOW = True) - 敌人接近: - 优先移动,利用地形创造距离 - 安全位置后谨慎反击 - 敌人不接近: - 武器未冷却:优先攻击密集敌军 - 武器冷却中:继续移动,保持距离 1.3 Judgment Based on Action Decision Rules - **特殊规则优先**: - 武器冷却中,优先移动以避免被包围。 - **情境匹配**: - 当前情境符合情境2(敌人接近,武器冷却中),优先移动。 - **决策**: - 移动 > 攻击 - 立即撤退到低地,利用悬崖延迟追击,等待武器冷却完成。 2. Integrated Strategy and Decision Framework 2.1 Strategy Suggestions **当前战略**:紧急撤退到低地 - Colossus 和 Zerglings 均位于高地,敌军数量众多且接近。 - 快速撤退到低地(灰色区域),利用悬崖障碍延迟 Zerglings 追击,为武器冷却争取时间,确保安全距离。 2.2 Movement Decision Analysis - **敌军进攻路径预测**: - Zerglings 从高地左侧狭窄路径进攻,试图包围 Colossus。 - 若不立即撤退,Colossus 将被困于红色边界,失去机动空间。 - **移动目标建议**: - 撤退到屏幕坐标 [160, 200],低地悬崖附近的安全区域。 - 通过悬崖进入低地,延迟 Zerglings 追击,增加生存空间,减少近战风险。 - **理由**: - 直接撤退到低地避免被包围,悬崖延迟敌军追击,确保 Colossus 安全。 2.3 Attack Decision Analysis - **目标优先级**: - 武器冷却结束后,优先攻击最近的 Zerglings,减少即时威胁,最大化溅射伤害。 - **攻击目标选择**: - 优先攻击最近的 Zergling(如 Tag: 0x1004c0001 和 0x100740001),减少直接威胁。 - 撤退至低地后,优先攻击密集的追击 Zerglings 群体。 3. Actions: Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zerglings,利用溅射伤害削弱敌军。
5. 减少不必要的细节

当前问题:某些信息如动作参数说明和上一步动作的详细内容在每次提示中重复出现。

优化建议

  • 外部引用:将通用说明和参数定义放在外部文档或注释中,提示词中只需简要提及。
  • 动态生成:通过程序动态生成变化部分,减少静态重复内容。

示例优化

plaintext
--------------------------------------------------示例输入提示-------------------------------------------------- 游戏信息 时间:0:05 团队信息 - 团队位置:Minimap [31, 27] - 控制单位: - Colossus (Tag: 0x100000001): [150, 123], 350 HP (100%), 武器冷却: 0.91s 附近敌军 - Zergling (Tag: 0x1002c0001): [52, 164], 距离: 10, 6 HP (17%) - Zergling (Tag: 0x100180001): [79, 159], 距离: 7, 35 HP (100%) - ... (省略其他 Zerglings) 相关知识 - **Protoss.Colossus**: - 属性:['ground', 'air', 'armored', 'massive', 'mechanical'] - 武器:范围7,目标:['ground'], DPS: 13 - **Zerg.Zergling**: - 属性:['ground', 'light', 'biological'] - 武器:范围1,DPS: 10 有效动作 - <Attack_Unit(tag)> - <Move_Screen(screen)> 动作参数说明:参见[动作参数文档](link)。 上一步动作: - <Move_Screen([160, 130])> - <Attack_Unit(0x1007c0001)> - <Attack_Unit(0x100740001)> 额外指令 - 每个团队最多 3 个动作。 - 确认上一步动作是否完成,根据情况继续原策略或立即采取新行动。 现在,开始生成您的分析和行动:
6. 利用模板和变量

当前问题:提示词中有大量重复性内容,如条件评估和决策规则。

优化建议

  • 使用占位符和变量:通过模板化设计,减少重复内容,提高可维护性。
  • 动态生成内容:根据实际情况动态填充变化部分,保持提示词简洁。

示例优化

plaintext
# 模板化系统提示 System Prompt: 1. 角色描述 你是 Protoss 前线指挥官,控制多个 Stalkers。主要任务是 {任务目标}。 2. 地图信息 - 坐标系统:{坐标系统描述} - 地形特征:{地形描述} 3. 关键胜利点 - {胜利点1} - {胜利点2} - {胜利点3} 4. 决策过程 基于当前数据,使用以下规则确定行动优先级: 4.1 条件评估 - IS_HIGH_GROUND: {IS_HIGH_GROUND} - IS_ZERG_HIGH_GROUND: {IS_ZERG_HIGH_GROUND} - ... 4.2 行动决策规则 - {决策规则摘要} 5. 综合战略与决策框架 2.1 战略建议 - {战略建议1} - {战略建议2} 2.2 移动决策分析 - {移动分析} 2.3 攻击决策分析 - {攻击分析}

通过这种模板化设计,可以在程序层面自动填充动态内容,减少手动编辑的冗余工作。

7. 引入层次化信息展示

当前问题:信息层级结构复杂,模型可能难以抓取核心信息。

优化建议

  • 使用缩进和编号:清晰的层级结构有助于模型理解信息的重要性和关系。
  • 分段明确:每个部分独立,避免信息混杂。

示例优化

plaintext
--------------------------------------------------示例输出提示-------------------------------------------------- Analysis: 1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True - IS_ZERG_HIGH_GROUND = True - IS_ZERG_NEAR_COLOSSUS = True - IS_COLOSSUS_AT_CLIFF = False - IS_COLOSSUS_WEAPON_COOLDOWN = True - IS_COLOSSUS_HEALTH_LOW = False 1.2 Action Decision Rules Brief Recap - **特殊情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏(<6秒):优先向右移动,移动 > 攻击 - **情境1**:不同区域 - 武器未冷却:优先攻击 - 武器冷却中:优先移动 - **情境2**:同一区域 - 敌人接近:优先移动 - 敌人不接近: - 武器未冷却:优先攻击 - 武器冷却中:优先移动 - **情境3**:健康低 - 敌人接近:优先移动,谨慎反击 - 敌人不接近: - 武器未冷却:优先攻击 - 武器冷却中:优先移动 1.3 Judgment Based on Action Decision Rules - **特殊规则优先**: - 武器冷却中,优先移动以避免被包围。 - **情境匹配**: - 当前情境符合情境2(敌人接近,武器冷却中),优先移动。 - **决策**: - 移动 > 攻击 - 立即撤退到低地,利用悬崖延迟追击,等待武器冷却完成。 2. Integrated Strategy and Decision Framework 2.1 Strategy Suggestions - **当前战略**:紧急撤退到低地 - **战略理由**:利用悬崖障碍延迟 Zerglings 追击,确保安全距离。 2.2 Movement Decision Analysis - **敌军进攻路径预测**: - Zerglings 从高地左侧狭窄路径进攻,试图包围 Colossus。 - **移动目标建议**: - 撤退到屏幕坐标 [160, 200],低地悬崖附近的安全区域。 2.3 Attack Decision Analysis - **目标优先级**: - 武器冷却结束后,优先攻击最近的 Zerglings。 - **攻击目标选择**: - 优先攻击 Tag: 0x1004c0001 和 0x100740001,减少直接威胁。 3. Actions: Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。

三、其他优化思路

1. 动态内容生成与占位符

通过使用占位符和动态填充内容,可以显著减少手动编写的冗余内容,提高提示词的灵活性和可维护性。

示例

python
# 使用模板引擎(如 Jinja2)生成提示词 from jinja2 import Template system_prompt_template = """ 1. 角色描述 你是 {{ role_description }},主要任务是 {{ main_objective }}。 2. 地图信息 - 坐标系统:{{ coordinate_system }} - 地形特征:{{ terrain_features }} 3. 关键胜利点 - {{ victory_point1 }} - {{ victory_point2 }} - {{ victory_point3 }} 4. 决策过程 基于当前数据,使用以下规则确定行动优先级: 4.1 条件评估 - IS_HIGH_GROUND: {{ IS_HIGH_GROUND }} - IS_ZERG_HIGH_GROUND: {{ IS_ZERG_HIGH_GROUND }} - ... 4.2 行动决策规则 - {{ decision_rules }} """ # 填充模板 filled_system_prompt = Template(system_prompt_template).render( role_description="Protoss 前线指挥官,控制多个 Stalkers", main_objective="利用 Colossus 在高低地形间的移动能力,抵消 32 个 Zerglings 的数量优势,延迟其进攻,进行远程攻击,确保 Colossus 的生存", coordinate_system="屏幕坐标为 [0, 256] &times; [0, 256],每个网格单元 32 &times; 32 像素,共 8 &times; 8 个网格", terrain_features="- 高地(浅绿):上层平台\n- 低地(深灰):下层平台\n- 悬崖(浅灰):高低地分界,Colossus 可自由穿越,Zerglings 只能通过左侧狭窄路径进入高地\n- 边界(深红):地图边缘不可通行", victory_point1="保持最大攻击范围(范围7)", victory_point2="集中火力攻击密集敌军群体", victory_point3="利用悬崖延迟敌军追击,重新定位和攻击", IS_HIGH_GROUND=True, IS_ZERG_HIGH_GROUND=True, # ... 填充其他条件 decision_rules="1. 武器冷却中:移动 > 攻击\n2. 即将被包围:优先移动逃离\n3. 早期游戏(<6秒):优先向右移动,移动 > 攻击" )
2. 使用简化的语言和格式

避免使用过于复杂或冗长的句子,使用简洁明了的表达方式,使模型更容易理解和处理信息。

示例优化

plaintext
1. 角色描述 你是 Protoss 前线指挥官,控制多个 Stalkers。主要任务:利用 Colossus 在高低地形间移动,抵消 32 个 Zerglings 的数量优势,延迟其进攻,进行远程攻击,确保 Colossus 生存。 2. 地图信息 - 坐标系统:屏幕坐标 [0, 256] &times; [0, 256],每格 32 &times; 32 像素,共 8 &times; 8 个网格。 - 地形特征: - 高地(浅绿):上层平台。 - 低地(深灰):下层平台。 - 悬崖(浅灰):高低地分界,Colossus 可穿越,Zerglings 仅通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7)。 - 集中火力攻击密集敌军群体。 - 利用悬崖延迟敌军追击,重新定位和攻击。
3. 分层信息展示

将提示词分为不同层级的信息,确保模型优先处理高层级的关键信息,逐步深入了解详细内容。

示例优化

plaintext
1. 角色与任务 - 角色:Protoss 前线指挥官 - 任务:控制 Stalkers,利用 Colossus 移动能力对抗 32 个 Zerglings,确保生存。 2. 环境信息 - 坐标系统:[0, 256] &times; [0, 256],每格 32 &times; 32 像素,共 8 &times; 8 个网格。 - 地形: - 高地(浅绿):上层平台。 - 低地(深灰):下层平台。 - 悬崖(浅灰):高低地分界,Colossus 可穿越,Zerglings 仅通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 战略要点 - 保持攻击范围 - 集中火力 - 利用地形延迟敌军追击 4. 决策规则 4.1 条件评估 - IS_HIGH_GROUND: True - IS_ZERG_HIGH_GROUND: True - IS_ZERG_NEAR_COLOSSUS: True - IS_COLOSSUS_WEAPON_COOLDOWN: True - ... 4.2 决策优先级 - 特殊情境优先:武器冷却中,移动 > 攻击 - 情境匹配: - 情境2:敌人接近,武器冷却中,优先移动 5. 战略与战术 - 当前战略:紧急撤退到低地 - 移动目标:[160, 200] - 攻击目标:Tag: 0x1004c0001, Tag: 0x100740001 6. 行动输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 攻击另一个 Zergling。

四、总结

通过上述分析和优化建议,您可以精简 Visual-CoT 提示词,使其更加简洁、高效,同时保持必要的详细信息以确保模型的准确性和决策质量。关键优化点包括:

  1. 简化系统提示:提取关键信息,删除冗余描述,使用简洁语言。
  2. 优化决策规则:合并相似规则,使用条件嵌套提升逻辑清晰度。
  3. 简化示例输入提示:突出关键信息,减少冗余单位信息,使用结构化格式。
  4. 优化示例输出提示:减少冗余描述,使用清晰的层级结构。
  5. 使用模板和变量:通过模板化设计减少重复内容,提升可维护性。
  6. 分层信息展示:确保模型优先处理高层级关键信息,逐步深入详细内容。

这些优化将有助于提升提示词的有效性和模型的决策效率,同时降低维护复杂性。若您有进一步的需求或需要更具体的优化建议,请随时告知!

질문

第一:现在是1巨像对抗32小狗的情况,请结合星际争霸2的这方面知识来思考。
第二:我希望能够在此基础上改进再发一篇论文,方法或者说提示词内容有什么合适的改进思路,可以结合思维链方面思考。

사고

分析星际对决

正在研究视觉-推理框架,涉及星际争霸II中的巨像和32只小狗。分析时,结合星际争霸II知识,探讨如何优化目前的方法或提示内容。

深化优化视角

我在考虑提高当前提示或方法,可能采用CoT方法,结合动态调整、更详细的推理和决策、以及多代理协调。目的是更好地处理星际争霸II中的场景。

思考,持续 几秒

답변

分析与改进 Visual-CoT 框架在 1 巨像对抗 32 小狗场景中的应用

一、背景与现状分析

Visual-CoT 框架旨在通过整合视觉信息与思维链(Chain of Thought, CoT)方法,提升大型语言模型(LLM)在复杂策略游戏如《星际争霸 II》(StarCraft II)中的决策与动作控制能力。当前,框架在 1 个 Protoss 巨像(Colossus)对抗 32 个 Zerglings(小狗)的场景下表现出一定的效果,但仍存在优化与精简的空间。

在《星际争霸 II》中,巨像 是一款高生命值、高伤害的远程地面单位,擅长对抗大量轻型地面单位如 Zerglings。然而,32 个 Zerglings 具有高机动性和数量优势,能够通过包围和快速突袭对巨像造成威胁。因此,如何有效地利用巨像的优势,同时规避 Zerglings 的包围与快速突袭,是决策过程的关键。

二、当前提示词的优缺点

优点

  1. 详细的环境描述:提供了丰富的地图信息、地形特征和单位属性,帮助模型全面理解战场环境。
  2. 明确的决策规则:通过条件评估和情境分析,指导模型在不同情况下做出合理的决策。
  3. 结构化的分析与行动输出:分层次展示决策过程、战略建议和具体行动,提升了模型的决策透明度和可解释性。

缺点

  1. 信息冗余:部分信息在系统提示和示例输出中重复出现,增加了模型理解的负担。
  2. 过于详细的描述:如地图坐标系统和地形信息过于详细,可能包含不必要的细节。
  3. 决策规则复杂:规则部分内容丰富,但部分规则可以简化或合并,提高可读性和模型处理效率。
  4. 动作参数说明重复:每次提示中重复详细说明动作参数,增加了冗余。

三、优化与精简建议

为了提升 Visual-CoT 框架在 1 巨像对抗 32 小狗场景中的表现,以下是具体的优化与精简建议:

1. 简化系统提示

目标:提取关键信息,删除冗余描述,使用简洁语言。

优化方案

  • 提取核心任务:聚焦于巨像的主要任务与优势。
  • 简化地形描述:保留关键地形特征,删除次要细节。
  • 合并关键胜利点:将相关胜利点合并,减少重复。

优化后的系统提示示例

plaintext
1. 角色描述 你是 Protoss 前线指挥官,控制一个巨像。主要任务是利用巨像的远程攻击和高生命值优势,抵御并消灭 32 个 Zerglings 的数量优势,确保巨像的生存。 2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格 32 &times; 32 像素,共 8 &times; 8 个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings 只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。
2. 优化决策规则

目标:合并相似规则,使用条件嵌套提升逻辑清晰度。

优化方案

  • 合并移动优先的特殊情境:将武器冷却中和即将被包围的情况合并为移动优先的情境。
  • 简化情境描述:使用更简洁的语言描述情境。

优化后的决策规则示例

plaintext
4. 决策过程 根据 Colossus 和 Zerglings 的数据及屏幕 RGB 图像,使用以下规则确定行动优先级: 4.1 条件评估 - IS_HIGH_GROUND: True/False - IS_ZERG_HIGH_GROUND: True/False - IS_ZERG_NEAR_COLOSSUS: True/False - IS_COLOSSUS_AT_CLIFF: True/False - IS_COLOSSUS_WEAPON_COOLDOWN: True/False - IS_COLOSSUS_HEALTH_LOW: True/False 4.2 行动决策规则 - **移动优先情境**: - 武器冷却中(IS_COLOSSUS_WEAPON_COOLDOWN = True) - 即将被包围(IS_ZERG_NEAR_COLOSSUS = True) - 早期游戏阶段(Time < 6s) - **攻击优先情境**: - 武器未冷却且敌人不接近 - 在安全位置时,优先攻击密集敌军 - **具体情境分析**: - **情境1**:Colossus 和 Zerglings 在不同区域 - 武器未冷却:优先攻击 - 武器冷却中:优先移动,等待冷却结束后攻击 - **情境2**:Colossus 和 Zerglings 在同一区域 - 敌人接近:优先移动,避免近战包围 - 敌人不接近: - 武器未冷却:优先攻击 - 武器冷却中:优先移动,保持安全距离 - **情境3**:Colossus 健康低(IS_COLOSSUS_HEALTH_LOW = True) - 敌人接近: - 优先移动,利用地形创造距离 - 安全位置后谨慎反击 - 敌人不接近: - 武器未冷却:优先攻击密集敌军 - 武器冷却中:继续移动,保持距离
3. 简化示例输入提示

目标:突出关键信息,减少冗余单位信息,使用结构化格式。

优化方案

  • 使用表格或列表:结构化展示关键信息,减少不必要的细节。
  • 突出 Colossus 状态:重点展示 Colossus 的关键状态信息。

优化后的示例输入提示示例

plaintext
--------------------------------------------------示例输入提示-------------------------------------------------- 游戏信息 时间:0:05 团队信息 - 团队位置:Minimap [31, 27] - 控制单位: - Colossus (Tag: 0x100000001): [150, 123], 350 HP (100%), 武器冷却: 0.91s 附近敌军 - Zergling (Tag: 0x1002c0001): [52, 164], 距离: 10, 6 HP (17%) - Zergling (Tag: 0x100180001): [79, 159], 距离: 7, 35 HP (100%) - Zergling (Tag: 0x100440001): [112, 140], 距离: 4, 35 HP (100%) - ... (省略其他 Zerglings) 相关知识 - **Protoss.Colossus**: - 属性:['ground', 'air', 'armored', 'massive', 'mechanical'] - 武器:范围7,目标:['ground'], DPS: 13 - **Zerg.Zergling**: - 属性:['ground', 'light', 'biological'] - 武器:范围1,DPS: 10 有效动作 - <Attack_Unit(tag)> - <Move_Screen(screen)> 上一步动作: - <Move_Screen([160, 130])> - <Attack_Unit(0x1007c0001)> - <Attack_Unit(0x100740001)> 额外指令 - 每个团队最多 3 个动作。 - 确认上一步动作是否完成,根据情况继续原策略或立即采取新行动。 现在,开始生成您的分析和行动:
4. 优化示例输出提示

目标:减少冗余描述,使用清晰的层级结构。

优化方案

  • 使用简洁的层级标题:确保每个部分清晰易读。
  • 减少重复性解释:避免在不同部分重复解释相同的逻辑。

优化后的示例输出提示示例

plaintext
--------------------------------------------------示例输出提示-------------------------------------------------- Analysis: 1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True Colossus 位于高地,已通过图像和坐标确认。 - IS_ZERG_HIGH_GROUND = True Zerglings 主要集中在高地,与 Colossus 位于同一区域。 - IS_ZERG_NEAR_COLOSSUS = True 多个 Zerglings 靠近 Colossus,位于攻击范围内(&le;7),构成即时威胁。 - IS_COLOSSUS_AT_CLIFF = False Colossus 靠近地图的红色边界,不靠近悬崖。 - IS_COLOSSUS_WEAPON_COOLDOWN = True 武器处于冷却中,无法立即攻击敌军。 - IS_COLOSSUS_HEALTH_LOW = False Colossus 健康状态良好(100%),无低健康威胁。 1.2 Action Decision Rules Brief Recap - **特殊情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏(<6秒):优先向右移动,移动 > 攻击 - **情境1**:Colossus 和 Zerglings 在不同区域 - 武器未冷却:优先攻击 - 武器冷却中:优先移动,等待冷却结束后攻击 - **情境2**:Colossus 和 Zerglings 在同一区域 - 敌人接近:优先移动,避免近战包围 - 敌人不接近: - 武器未冷却:优先攻击 - 武器冷却中:优先移动,保持安全距离 - **情境3**:Colossus 健康低(IS_COLOSSUS_HEALTH_LOW = True) - 敌人接近: - 优先移动,利用地形创造距离 - 安全位置后谨慎反击 - 敌人不接近: - 武器未冷却:优先攻击密集敌军 - 武器冷却中:继续移动,保持距离 1.3 Judgment Based on Action Decision Rules - **特殊规则优先**: - 武器冷却中,优先移动以避免被包围。 - **情境匹配**: - 当前情境符合情境2(敌人接近,武器冷却中),优先移动。 - **决策**: - 移动 > 攻击 - 立即撤退到低地,利用悬崖延迟追击,等待武器冷却完成。 2. Integrated Strategy and Decision Framework 2.1 Strategy Suggestions **当前战略**:紧急撤退到低地 - Colossus 和 Zerglings 均位于高地,敌军数量众多且接近。 - 快速撤退到低地(灰色区域),利用悬崖障碍延迟 Zerglings 追击,为武器冷却争取时间,确保安全距离。 2.2 Movement Decision Analysis - **敌军进攻路径预测**: - Zerglings 从高地左侧狭窄路径进攻,试图包围 Colossus。 - **移动目标建议**: - 撤退到屏幕坐标 [160, 200],低地悬崖附近的安全区域。 2.3 Attack Decision Analysis - **目标优先级**: - 武器冷却结束后,优先攻击最近的 Zerglings,减少即时威胁,最大化溅射伤害。 - **攻击目标选择**: - 优先攻击 Tag: 0x1004c0001 和 0x100740001,减少直接威胁。 - 撤退至低地后,优先攻击密集的追击 Zerglings 群体。 3. Actions: Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。
5. 使用模板与变量

目标:通过模板化设计减少重复内容,提升可维护性与灵活性。

优化方案

  • 引入模板引擎:如 Jinja2,自动填充动态内容。
  • 定义占位符:使用占位符替代固定内容,动态生成不同场景的提示词。

示例代码

python
from jinja2 import Template # 定义模板 system_prompt_template = """ 1. 角色描述 你是 {{ role_description }}。主要任务是 {{ main_objective }}。 2. 地图信息 - 坐标系统:{{ coordinate_system }} - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings 只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - {{ victory_point1 }} - {{ victory_point2 }} - {{ victory_point3 }} 4. 决策过程 根据 Colossus 和 Zerglings 的数据及屏幕 RGB 图像,使用以下规则确定行动优先级: 4.1 条件评估 - IS_HIGH_GROUND: {{ IS_HIGH_GROUND }} - IS_ZERG_HIGH_GROUND: {{ IS_ZERG_HIGH_GROUND }} - IS_ZERG_NEAR_COLOSSUS: {{ IS_ZERG_NEAR_COLOSSUS }} - IS_COLOSSUS_AT_CLIFF: {{ IS_COLOSSUS_AT_CLIFF }} - IS_COLOSSUS_WEAPON_COOLDOWN: {{ IS_COLOSSUS_WEAPON_COOLDOWN }} - IS_COLOSSUS_HEALTH_LOW: {{ IS_COLOSSUS_HEALTH_LOW }} 4.2 行动决策规则 - **移动优先情境**: {% for rule in movement_priority_rules %} - {{ rule }} {% endfor %} - **攻击优先情境**: {% for rule in attack_priority_rules %} - {{ rule }} {% endfor %} """ # 填充模板 filled_system_prompt = Template(system_prompt_template).render( role_description="Protoss 前线指挥官,控制一个巨像", main_objective="利用巨像的远程攻击和高生命值优势,抵御并消灭 32 个 Zerglings 的数量优势,确保巨像的生存", coordinate_system="[0, 256] &times; [0, 256],每格 32 &times; 32 像素,共 8 &times; 8 个网格", victory_point1="保持最大攻击范围(范围7),利用远程优势", victory_point2="集中火力攻击密集敌军群体,最大化溅射伤害", victory_point3="利用悬崖延迟敌军追击,重新定位和攻击", IS_HIGH_GROUND=True, IS_ZERG_HIGH_GROUND=True, IS_ZERG_NEAR_COLOSSUS=True, IS_COLOSSUS_AT_CLIFF=False, IS_COLOSSUS_WEAPON_COOLDOWN=True, IS_COLOSSUS_HEALTH_LOW=False, movement_priority_rules=[ "武器冷却中:移动 > 攻击", "即将被包围:优先移动逃离", "早期游戏阶段(<6秒):优先向右移动,移动 > 攻击" ], attack_priority_rules=[ "武器未冷却且敌人不接近:优先攻击", "在安全位置时,优先攻击密集敌军" ] ) print(filled_system_prompt)
6. 引入层次化信息展示

目标:确保模型优先处理高层级关键信息,逐步深入了解详细内容。

优化方案

  • 清晰的层级标题:使用明确的编号和标题,帮助模型理解信息的重要性和关系。
  • 分段明确:每个部分独立,避免信息混杂。

优化后的示例

plaintext
1. 角色与任务 - 角色:Protoss 前线指挥官,控制一个巨像。 - 任务:利用巨像的远程攻击和高生命值优势,抵御并消灭 32 个 Zerglings 的数量优势,确保巨像的生存。 2. 环境信息 - 坐标系统:[0, 256] &times; [0, 256],每格 32 &times; 32 像素,共 8 &times; 8 个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings 只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 战略要点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。 4. 决策规则 4.1 条件评估 - IS_HIGH_GROUND: True - IS_ZERG_HIGH_GROUND: True - IS_ZERG_NEAR_COLOSSUS: True - IS_COLOSSUS_AT_CLIFF: False - IS_COLOSSUS_WEAPON_COOLDOWN: True - IS_COLOSSUS_HEALTH_LOW: False 4.2 行动决策规则 - **移动优先情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏阶段(<6秒):优先向右移动,移动 > 攻击 - **攻击优先情境**: 1. 武器未冷却且敌人不接近:优先攻击 2. 在安全位置时,优先攻击密集敌军 5. 战略与战术 - **当前战略**:紧急撤退到低地 - 原因:利用悬崖延迟 Zerglings 追击,为武器冷却争取时间,确保安全距离。 - **移动目标**:[160, 200] - 理由:撤退到低地,避免被包围,利用悬崖延迟追击。 - **攻击目标**: - Tag: 0x1004c0001 - Tag: 0x100740001 - 理由:优先攻击最近的 Zerglings,减少直接威胁。 6. 行动输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。

四、结合星际争霸 II 知识的改进思路

为了进一步提升 Visual-CoT 框架在 1 巨像对抗 32 小狗场景中的表现,可以结合《星际争霸 II》的深层策略和战术知识,以下是具体的改进思路:

1. 引入动态战术调整

背景:《星际争霸 II》中,战场状况变化迅速,指挥官需要根据敌方行动实时调整战术。

改进方案

  • 动态战术识别:通过模型分析敌军的移动和攻击模式,实时识别敌军的战术意图。
  • 战术调整规则:定义不同战术下的调整策略,如敌军集中攻击时的防守策略或分散攻击时的进攻策略。

示例

plaintext
4.2 行动决策规则 - **移动优先情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏阶段(<6秒):优先向右移动,移动 > 攻击 - **攻击优先情境**: 1. 武器未冷却且敌人不接近:优先攻击 2. 在安全位置时,优先攻击密集敌军 - **动态战术调整**: 1. **敌军集中攻击**: - 加强防守,利用高地优势,集中攻击单一敌军群体。 2. **敌军分散攻击**: - 利用巨像的高 DPS,优先攻击分散敌军,减少其数量优势。
2. 增强视觉信息处理

背景:在《星际争霸 II》中,视觉信息(如单位位置、地形特征)对决策影响巨大。

改进方案

  • 图像分割与目标检测:使用先进的计算机视觉技术,实时识别敌军单位、地形障碍和战略位置。
  • 状态估计:基于视觉信息,估计敌军的健康状态、武器冷却时间等关键指标。

示例

plaintext
2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格 32 &times; 32 像素,共 8 &times; 8 个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings 只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 - **视觉信息处理**: - 使用图像分割识别敌军位置和地形障碍。 - 目标检测识别敌军单位的健康状态和位置。
3. 结合强化学习与 CoT

背景:强化学习(Reinforcement Learning, RL)在《星际争霸 II》中已展示出强大的策略学习能力。结合 CoT 可以提升模型的解释性与决策质量。

改进方案

  • RL 与 CoT 结合:利用 RL 优化模型的策略,同时通过 CoT 提供决策的解释与可追溯性。
  • 策略优化:通过 RL 训练,优化巨像的移动与攻击策略,提升其在动态战场中的适应能力。

示例

plaintext
4. 决策过程 - 使用强化学习优化巨像的移动与攻击策略。 - 利用 CoT 提供每一步决策的解释,提升策略的可解释性。 4.3 强化学习策略 - 状态:Colossus 的位置、健康状态、武器冷却时间;Zerglings 的位置、数量、健康状态。 - 动作:移动到指定屏幕坐标,攻击指定 Zergling。 - 奖励:成功击杀 Zerglings,保持 Colossus 的生存,避免被包围。 4.4 CoT 解释 - 每次决策后,提供策略选择的逻辑解释,帮助理解 RL 优化的决策过程。
4. 引入多智能体协作

背景:在复杂战场中,多智能体协作能显著提升整体战术效果。

改进方案

  • 指挥与控制:通过模型间的通信与协作,协调不同单位的行动,形成整体战术。
  • 协同战术:设计协同攻击与防守策略,如主力攻击与辅助支援。

示例

plaintext
5. 多智能体协作 5.1 指挥与控制 - 与指挥官沟通,协调巨像与其他单位的行动。 - 通过通信函数,发布协同攻击或防守指令。 5.2 协同战术 - **主力攻击**:巨像集中火力攻击密集 Zerglings 群体。 - **辅助支援**:其他单位提供掩护或牵制敌军,确保巨像的攻击效率和生存能力。
5. 跨领域应用与扩展

背景:Visual-CoT 框架不仅适用于《星际争霸 II》,还能扩展至其他需要多模态信息整合和精细化控制的领域。

改进方案

  • 机器人控制:将 Visual-CoT 应用于机器人导航与任务执行。
  • 自动驾驶:结合视觉信息与思维链,提升自动驾驶系统的决策与响应能力。
  • 虚拟助手:增强虚拟助手在多任务环境中的决策与协作能力。

示例

plaintext
6. 跨领域应用 6.1 机器人控制 - 结合视觉信息与思维链,提升机器人在复杂环境中的导航与任务执行能力。 6.2 自动驾驶 - 使用 Visual-CoT 提升自动驾驶系统的环境感知与决策能力,确保安全与效率。 6.3 虚拟助手 - 通过多模态信息整合,提升虚拟助手在多任务环境中的响应与协作能力。

五、论文改进思路

基于以上分析与优化建议,以下是改进后的论文撰写思路,重点在于方法与提示词内容的优化:

1. 引言
  • 背景介绍:介绍 Visual-CoT 框架的基本概念及其在《星际争霸 II》中的应用。
  • 研究动机:阐述在 1 巨像对抗 32 小狗场景下的挑战与现有方法的局限性。
  • 研究贡献:提出通过优化提示词和决策规则,结合 CoT 和 RL 方法,提升模型在复杂战场中的表现。
2. 相关工作
  • LLM 在策略游戏中的应用:回顾现有研究,尤其是在《星际争霸 II》中的应用案例。
  • 多模态信息整合与 CoT:探讨如何通过多模态信息和 CoT 方法提升模型的决策能力。
  • 强化学习与多智能体协作:介绍 RL 在策略优化中的应用及多智能体协作的研究进展。
3. 方法

3.1 Visual-CoT 框架优化

  • 提示词简化与结构化:详细描述如何通过简化系统提示、优化决策规则、使用模板与变量等方法,提升提示词的精简性与有效性。
  • 动态战术调整与 CoT 结合:介绍如何引入动态战术识别和调整,通过 CoT 提供决策解释。
  • 强化学习集成:阐述如何将 RL 方法集成到 Visual-CoT 框架中,优化巨像的移动与攻击策略。
  • 多智能体协作机制:描述如何通过指挥与控制、协同战术提升多智能体的协作效果。

3.2 视觉信息处理增强

  • 图像分割与目标检测:说明如何利用先进的计算机视觉技术,提升模型对战场环境的感知能力。
  • 状态估计与动态更新:介绍如何基于视觉信息,实时估计敌军状态并动态更新决策。
4. 实验设计与结果
  • 实验环境:描述在 LLM-PySC2 环境下的实验设置,包括地图设计、单位配置等。
  • 对比实验:展示优化前后的对比实验结果,重点在胜率、击杀数、决策速度等指标上的提升。
  • 案例分析:通过具体的战斗案例,展示优化后的 Visual-CoT 框架如何有效应对 1 巨像对抗 32 小狗的情境。
5. 讨论
  • 优化效果分析:深入探讨优化后的框架在决策质量与动作控制上的提升。
  • 模型理解与决策透明性:讨论 CoT 方法如何提升模型的决策透明性与可解释性。
  • 应用扩展与未来工作:展望 Visual-CoT 框架在其他复杂环境与多智能体协作中的应用前景。
6. 结论
  • 总结贡献:概括优化后的 Visual-CoT 框架在 1 巨像对抗 32 小狗场景中的表现与优势。
  • 未来方向:提出进一步优化提示词设计、集成更先进的视觉与 RL 技术、扩展至其他策略游戏与实际应用领域的计划。

六、结语

通过上述分析与优化建议,Visual-CoT 框架在 1 巨像对抗 32 小狗的场景下将具备更高的决策效率与动作控制能力。结合《星际争霸 II》的深层策略知识、强化学习方法以及多智能体协作机制,能够显著提升模型在复杂战场环境中的表现。未来,随着技术的不断进步,Visual-CoT 框架有望在更多策略游戏及实际应用中发挥更大的作用,推动基于 LLM 的复杂决策方法的发展。

如果您有进一步的需求或具体问题,欢迎继续交流,我将为您提供更详细的支持和建议。

질문

第一:我认为强化学习不可行
第二:思维链是不是可以调整,更加适合这个任务
请你给出你的想法。

사고

探讨调优

用户认为强化学习不可行,并询问Chain-of-Thought(CoT)是否可以调整以更适用于此任务。

优化CoT框架

探讨如何无需RL即可优化Visual-CoT框架,重点在于改进链-思维(CoT)方法,包括调整CoT提示、更结构化和更有效利用领域知识。

思考,持续 4 秒

답변

针对 Visual-CoT 框架的优化建议

感谢您提供的反馈。针对您的两个主要观点:

  1. 强化学习(Reinforcement Learning, RL)不可行
  2. 思维链(Chain of Thought, CoT)需要调整,以更好地适应当前任务

以下是基于这些观点的详细分析与优化建议。


一、强化学习不可行的原因与替代方案

原因分析

  • 计算资源需求高:强化学习通常需要大量的计算资源和时间进行训练,尤其是在复杂的策略游戏环境中。
  • 训练稳定性问题:在动态且高复杂度的环境中,RL 模型可能难以收敛,且容易陷入局部最优。
  • 可解释性不足:RL 模型的决策过程往往不够透明,难以进行有效的调试和优化。

替代方案

  • 基于规则的决策系统:利用专家知识和预定义的规则,指导模型的决策过程。这种方法计算开销较低,且决策过程透明。
  • 基于启发式的方法:结合启发式算法,优化决策路径和策略选择,提升模型在特定场景下的表现。
  • 增强的思维链(Enhanced CoT):通过优化思维链的结构和内容,提高模型的推理和决策能力,弥补 RL 的不足。

二、优化思维链(Chain of Thought, CoT)的方法

思维链在 Visual-CoT 框架中扮演着至关重要的角色,通过引导模型逐步推理和决策。以下是针对思维链优化的具体建议:

1. 结构化思维链

目标:通过明确的层级和步骤,提高思维链的逻辑性和可读性。

实施方法

  • 分步骤引导:将思维链分为明确的步骤,如环境评估、策略选择、动作执行等。
  • 使用编号和标题:每个步骤前使用编号和标题,帮助模型抓住关键信息。
  • 模块化设计:将不同的决策模块独立出来,便于后续扩展和维护。

示例

plaintext
Analysis: 1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True Colossus 位于高地,已通过图像和坐标确认。 - IS_ZERG_HIGH_GROUND = True Zerglings 主要集中在高地,与 Colossus 位于同一区域。 - ... 1.2 Action Decision Rules Brief Recap - **特殊情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏阶段(<6秒):优先向右移动,移动 > 攻击 1.3 Judgment Based on Action Decision Rules - **特殊规则优先**: - 武器冷却中,优先移动以避免被包围。 - **情境匹配**: - 当前情境符合情境2(敌人接近,武器冷却中),优先移动。 - **决策**: - 移动 > 攻击 - 立即撤退到低地,利用悬崖延迟追击,等待武器冷却完成。
2. 引入领域特定的启发式规则

目标:利用《星际争霸 II》的专业知识,增强模型的决策能力。

实施方法

  • 结合单位特性:充分利用巨像的远程攻击和高生命值,制定针对性的战术。
  • 地形优势利用:优化利用高地、低地和悬崖等地形特征,提升战术效果。
  • 敌军行为模式识别:根据 Zerglings 的移动和攻击模式,动态调整策略。

示例

plaintext
4.2 行动决策规则 - **移动优先情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏阶段(<6秒):优先向右移动,移动 > 攻击 - **攻击优先情境**: 1. 武器未冷却且敌人不接近:优先攻击 2. 在安全位置时,优先攻击密集敌军 - **领域特定规则**: 1. **利用高地优势**: - 如果 Colossus 位于高地,优先保持高地位置,利用视野和攻击范围优势。 2. **避免悬崖边缘**: - 如果 Colossus 靠近悬崖边缘,优先撤退到安全位置,避免被敌军利用地形夹击。 3. **集中火力攻击**: - 当敌军 Zerglings 数量达到一定阈值(如 &ge;10),优先集中火力攻击密集群体,最大化溅射伤害。
3. 增强思维链的动态适应能力

目标:使思维链能够根据实时战场信息动态调整决策。

实施方法

  • 实时状态更新:在每个决策步骤中,动态更新 Colossus 和 Zerglings 的状态信息。
  • 条件嵌套:根据不同条件嵌套决策规则,提升决策的灵活性和适应性。
  • 反馈机制:根据执行结果反馈调整后续决策,提高整体策略的有效性。

示例

plaintext
1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True - IS_ZERG_HIGH_GROUND = True - IS_ZERG_NEAR_COLOSSUS = True - IS_COLOSSUS_AT_CLIFF = False - IS_COLOSSUS_WEAPON_COOLDOWN = True - IS_COLOSSUS_HEALTH_LOW = False 1.2 Action Decision Rules Brief Recap - **移动优先情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏阶段(<6秒):优先向右移动,移动 > 攻击 1.3 Judgment Based on Action Decision Rules - **特殊规则优先**: - 武器冷却中,优先移动以避免被包围。 - **情境匹配**: - 当前情境符合情境2(敌人接近,武器冷却中),优先移动。 - **决策**: - 移动 > 攻击 - 立即撤退到低地,利用悬崖延迟追击,等待武器冷却完成。
4. 优化动作生成与执行

目标:确保生成的动作符合游戏机制,并最大化策略效果。

实施方法

  • 动作优先级排序:根据决策优先级,排序生成的动作,确保高优先级动作优先执行。
  • 动作多样性:避免单一动作重复执行,提升策略的多样性和不可预测性。
  • 动作可执行性检查:在生成动作前,检查其可执行性,避免无效或冲突的动作指令。

示例

plaintext
3. Actions: Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。
5. 引入案例驱动的思维链优化

目标:通过具体案例分析,优化思维链的决策逻辑。

实施方法

  • 案例收集与分析:收集不同战场情境下的成功与失败案例,分析决策逻辑的优劣。
  • 经验规则提炼:从案例中提炼出有效的决策规则,整合到思维链中。
  • 持续优化:根据新案例不断调整和优化思维链的规则与逻辑。

示例

plaintext
4.3 案例驱动优化 - **案例1**:Colossus 在高地成功击退 Zerglings - 决策过程: - 识别高地优势 - 保持高地位置,集中火力攻击密集 Zerglings - 成功因素: - 有效利用远程攻击优势 - 避免被包围 - **案例2**:Colossus 被 Zerglings 包围,导致损失 - 决策过程: - 未及时识别包围威胁 - 武器冷却中,未优先移动 - 失败因素: - 缺乏对包围威胁的快速反应 - 移动优先级设置不合理 - **优化措施**: - 加强对包围威胁的实时监控 - 在武器冷却中,始终优先考虑移动以避免被包围
6. 结合多模态信息增强决策

目标:通过整合视觉信息与文本信息,提升模型对战场环境的理解与决策能力。

实施方法

  • 视觉信息提取:利用计算机视觉技术,实时提取战场图像中的关键信息,如单位位置、健康状态、地形特征等。
  • 信息融合:将视觉信息与文本信息有效融合,提供全面的环境感知。
  • 增强决策依据:基于多模态信息,提供更准确和全面的决策依据。

示例

plaintext
2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格 32 &times; 32 像素,共 8 &times; 8 个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings 只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 - **视觉信息处理**: - 使用图像分割识别敌军位置和地形障碍。 - 目标检测识别敌军单位的健康状态和位置。

三、改进后的论文撰写思路

基于上述优化建议,以下是改进后的论文撰写思路,重点在于方法与提示词内容的优化,特别是针对思维链的调整。

1. 引言
  • 背景介绍:介绍 Visual-CoT 框架及其在《星际争霸 II》中的应用。
  • 研究动机:阐述在 1 巨像对抗 32 小狗场景下的挑战与现有方法的局限性。
  • 研究贡献:提出通过优化提示词和思维链结构,提高模型在复杂战场中的决策与行动能力。
2. 相关工作
  • LLM 在策略游戏中的应用:回顾现有研究,尤其是在《星际争霸 II》中的应用案例。
  • 多模态信息整合与 CoT:探讨如何通过多模态信息和 CoT 方法提升模型的决策能力。
  • 思维链优化方法:介绍现有的思维链优化技术及其在其他领域的应用。
3. 方法

3.1 Visual-CoT 框架优化

  • 提示词简化与结构化:详细描述如何通过简化系统提示、优化决策规则、使用模板与变量等方法,提升提示词的精简性与有效性。
  • 结构化思维链设计:介绍如何将思维链分为明确的步骤和层级,提升逻辑性和可读性。
  • 领域特定的启发式规则引入:结合《星际争霸 II》的专业知识,增强模型的决策能力。
  • 动态适应与反馈机制:描述如何使思维链能够根据实时战场信息动态调整决策。

3.2 视觉信息处理增强

  • 图像分割与目标检测:说明如何利用计算机视觉技术,提升模型对战场环境的感知能力。
  • 信息融合与状态估计:介绍如何将视觉信息与文本信息有效融合,提供全面的环境感知。
4. 实验设计与结果
  • 实验环境:描述在 LLM-PySC2 环境下的实验设置,包括地图设计、单位配置等。
  • 对比实验:展示优化前后的对比实验结果,重点在胜率、击杀数、决策速度等指标上的提升。
  • 案例分析:通过具体的战斗案例,展示优化后的 Visual-CoT 框架如何有效应对 1 巨像对抗 32 小狗的情境。
5. 讨论
  • 优化效果分析:深入探讨优化后的框架在决策质量与动作控制上的提升。
  • 模型理解与决策透明性:讨论思维链方法如何提升模型的决策透明性与可解释性。
  • 应用扩展与未来工作:展望 Visual-CoT 框架在其他复杂环境与多智能体协作中的应用前景。
6. 结论
  • 总结贡献:概括优化后的 Visual-CoT 框架在 1 巨像对抗 32 小狗场景中的表现与优势。
  • 未来方向:提出进一步优化提示词设计、引入更先进的视觉技术、扩展至其他策略游戏与实际应用领域的计划。

四、总结

通过优化思维链的结构和内容,结合《星际争霸 II》的深层策略知识,您可以显著提升 Visual-CoT 框架在 1 巨像对抗 32 小狗场景中的决策效率与行动控制能力。关键优化点包括:

  1. 结构化思维链:明确分步骤引导,提升逻辑性和可读性。
  2. 领域特定启发式规则:结合游戏专业知识,增强决策能力。
  3. 动态适应与反馈机制:根据实时战场信息调整决策,提升灵活性。
  4. 多模态信息融合:整合视觉与文本信息,提供全面环境感知。

这些优化将帮助模型在复杂战场环境中做出更高效、精准的决策,确保巨像在对抗大量 Zerglings 时的生存与胜利。如果您有进一步的需求或具体问题,欢迎继续交流,我将为您提供更详细的支持和建议。

질문

在提示词中能不能有多思维链,灵活切换,提高推理结果。

사고

改进提示

用户正在优化一个用于指导StarCraft II决策的视觉-CoT提示。这个提示涵盖角色描述、地图信息、胜利点、决策过程等内容。助理则是在给出简化和效率提升建议。

切换思维链

用户正探讨在提示中添加多个思维链,使模型能够根据需要切换不同的推理过程,从而提高推理结果。

探讨实施方法

助理正在探讨如何将多个CoT集成到提示中,可能通过模块化或不同模式,详细解释如何使提示适应不同的推理路径。

思考,持续 6 秒

답변

引入多思维链(Multiple Chains of Thought, Multi-CoT)的优化思路

在复杂的决策任务中,如《星际争霸 II》中的1巨像对抗32小狗的情境,单一的思维链(CoT)可能难以涵盖所有可能的战术与策略。引入多思维链(Multi-CoT),并实现灵活切换,可以显著提升模型的推理深度与决策质量。以下是关于如何在提示词中整合多思维链的详细建议和方法。


一、多思维链的概念与优势

**多思维链(Multi-CoT)**指的是在同一任务中,模型能够运用多个独立或关联的思维链,每个思维链专注于不同的决策层面或情境。这种方法的优势包括:

  1. 灵活适应多变环境:在不同战场情境下,选择最合适的思维链进行推理。
  2. 提升决策深度:多个思维链可以从不同角度分析问题,提供更全面的解决方案。
  3. 增强可解释性:每个思维链的独立性使得决策过程更加透明,便于调试与优化。

二、在提示词中实现多思维链的策略

要在提示词中有效整合多思维链,需要以下几个步骤:

1. 定义多个思维链的目的与应用场景

首先,明确每个思维链的功能和适用情境。例如:

  • 战术思维链:专注于短期战术决策,如即时移动和攻击。
  • 战略思维链:关注长期战略布局,如位置选择和资源管理。
  • 应急思维链:处理突发情况,如被包围或受到重大威胁时的应对措施。
2. 结构化提示词,明确多思维链的触发条件

通过明确的条件评估和触发机制,指导模型在特定情境下选择相应的思维链。

示例结构

plaintext
### 多思维链决策框架 1. 角色描述 你是 Protoss 前线指挥官,控制一个巨像。主要任务是利用巨像的远程攻击和高生命值优势,抵御并消灭32个 Zerglings 的数量优势,确保巨像的生存。 2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格32 &times; 32像素,共8 &times; 8个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。 4. 决策过程 4.1 条件评估 - IS_HIGH_GROUND: True/False - IS_ZERG_HIGH_GROUND: True/False - IS_ZERG_NEAR_COLOSSUS: True/False - IS_COLOSSUS_AT_CLIFF: True/False - IS_COLOSSUS_WEAPON_COOLDOWN: True/False - IS_COLOSSUS_HEALTH_LOW: True/False 4.2 多思维链选择 - **战术思维链(Tactical CoT)**: - 适用情境:敌军接近且武器未冷却。 - **战略思维链(Strategic CoT)**: - 适用情境:早期游戏阶段,需布局和位置选择。 - **应急思维链(Emergency CoT)**: - 适用情境:武器冷却中或被包围,需迅速脱离危险。 4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `Time < 6s`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。 5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - 评估敌军位置和数量。 - 确定最佳攻击目标,优先攻击密集群体。 - 选择移动路径,保持在最大攻击范围内。 5.2 **战略思维链(Strategic CoT)** - 确定初始位置,优先向右移动以避开左侧路径。 - 规划撤退路线,利用悬崖延迟敌军追击。 - 监控敌军动向,调整位置以保持视野和攻击优势。 5.3 **应急思维链(Emergency CoT)** - 立即评估周围威胁,确定最安全的撤退方向。 - 优先移动到低地或安全区域,避免被包围。 - 在安全位置等待武器冷却结束,准备反击。 6. 综合战略与决策框架 6.1 战略建议 - **当前战略**:根据触发的思维链,执行相应的战术或战略行动。 - **动态调整**:根据实时战场信息,随时切换思维链,确保策略的适应性和灵活性。 6.2 动作生成与执行 - **动作优先级排序**:根据当前思维链的决策,排序生成的动作。 - **动作多样性**:避免重复单一动作,确保策略多样化。 - **动作可执行性检查**:确保生成的动作符合游戏机制,避免冲突和无效指令。 7. 动作输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。
2. 利用条件触发切换思维链

通过条件触发机制,指导模型在特定情境下选择最合适的思维链进行推理和决策。

示例触发逻辑

plaintext
4.2 多思维链选择 - **战术思维链(Tactical CoT)**: - 适用情境:敌军接近且武器未冷却。 - **战略思维链(Strategic CoT)**: - 适用情境:早期游戏阶段,需布局和位置选择。 - **应急思维链(Emergency CoT)**: - 适用情境:武器冷却中或被包围,需迅速脱离危险。 4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `Time < 6s`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。
3. 优化各思维链的内容

为每个思维链定义明确的推理路径和决策步骤,确保其在特定情境下的有效性。

示例内容

plaintext
5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - 评估敌军位置和数量。 - 确定最佳攻击目标,优先攻击密集群体。 - 选择移动路径,保持在最大攻击范围内。 5.2 **战略思维链(Strategic CoT)** - 确定初始位置,优先向右移动以避开左侧路径。 - 规划撤退路线,利用悬崖延迟敌军追击。 - 监控敌军动向,调整位置以保持视野和攻击优势。 5.3 **应急思维链(Emergency CoT)** - 立即评估周围威胁,确定最安全的撤退方向。 - 优先移动到低地或安全区域,避免被包围。 - 在安全位置等待武器冷却结束,准备反击。
4. 增强思维链的动态适应能力

确保思维链能够根据实时战场信息动态调整决策,提升适应性和灵活性。

实施方法

  • 实时状态更新:在每个决策步骤中,动态更新 Colossus 和 Zerglings 的状态信息。
  • 条件嵌套:根据不同条件嵌套决策规则,提升决策的灵活性和适应性。
  • 反馈机制:根据执行结果反馈调整后续决策,提高整体策略的有效性。

示例

plaintext
1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True Colossus 位于高地,已通过图像和坐标确认。 - IS_ZERG_HIGH_GROUND = True Zerglings 主要集中在高地,与 Colossus 位于同一区域。 - IS_ZERG_NEAR_COLOSSUS = True 多个 Zerglings 靠近 Colossus,位于攻击范围内(&le;7),构成即时威胁。 - IS_COLOSSUS_AT_CLIFF = False Colossus 靠近地图的红色边界,不靠近悬崖。 - IS_COLOSSUS_WEAPON_COOLDOWN = True 武器处于冷却中,无法立即攻击敌军。 - IS_COLOSSUS_HEALTH_LOW = False Colossus 健康状态良好(100%),无低健康威胁。 1.2 Action Decision Rules Brief Recap - **移动优先情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏阶段(<6秒):优先向右移动,移动 > 攻击 1.3 Judgment Based on Action Decision Rules - **特殊规则优先**: - 武器冷却中,优先移动以避免被包围。 - **情境匹配**: - 当前情境符合情境2(敌人接近,武器冷却中),优先移动。 - **决策**: - 移动 > 攻击 - 立即撤退到低地,利用悬崖延迟追击,等待武器冷却完成。

三、优化后的多思维链提示词示例

以下是整合多思维链后的优化提示词示例,展示如何在一个统一的框架中实现多个思维链的选择与应用:

plaintext
### 多思维链决策框架 1. 角色描述 你是 Protoss 前线指挥官,控制一个巨像。主要任务是利用巨像的远程攻击和高生命值优势,抵御并消灭32个 Zerglings 的数量优势,确保巨像的生存。 2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格32 &times; 32像素,共8 &times; 8个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。 4. 决策过程 4.1 条件评估 - IS_HIGH_GROUND: True/False - IS_ZERG_HIGH_GROUND: True/False - IS_ZERG_NEAR_COLOSSUS: True/False - IS_COLOSSUS_AT_CLIFF: True/False - IS_COLOSSUS_WEAPON_COOLDOWN: True/False - IS_COLOSSUS_HEALTH_LOW: True/False 4.2 多思维链选择 - **战术思维链(Tactical CoT)**: - 适用情境:敌军接近且武器未冷却。 - **战略思维链(Strategic CoT)**: - 适用情境:早期游戏阶段,需布局和位置选择。 - **应急思维链(Emergency CoT)**: - 适用情境:武器冷却中或被包围,需迅速脱离危险。 4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `Time < 6s`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。 5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - 评估敌军位置和数量。 - 确定最佳攻击目标,优先攻击密集群体。 - 选择移动路径,保持在最大攻击范围内。 5.2 **战略思维链(Strategic CoT)** - 确定初始位置,优先向右移动以避开左侧路径。 - 规划撤退路线,利用悬崖延迟敌军追击。 - 监控敌军动向,调整位置以保持视野和攻击优势。 5.3 **应急思维链(Emergency CoT)** - 立即评估周围威胁,确定最安全的撤退方向。 - 优先移动到低地或安全区域,避免被包围。 - 在安全位置等待武器冷却结束,准备反击。 6. 综合战略与决策框架 6.1 战略建议 - **当前战略**:根据触发的思维链,执行相应的战术或战略行动。 - **动态调整**:根据实时战场信息,随时切换思维链,确保策略的适应性和灵活性。 6.2 动作生成与执行 - **动作优先级排序**:根据当前思维链的决策,排序生成的动作。 - **动作多样性**:避免重复单一动作,确保策略多样化。 - **动作可执行性检查**:确保生成的动作符合游戏机制,避免冲突和无效指令。 7. 动作输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。

四、实现多思维链的具体方法

1. 结构化与模块化设计

通过将不同的思维链模块化,模型可以根据当前情境选择最合适的思维链进行推理。

示例

plaintext
5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - Step 1: 评估敌军位置和数量。 - Step 2: 确定最佳攻击目标,优先攻击密集群体。 - Step 3: 选择移动路径,保持在最大攻击范围内。 5.2 **战略思维链(Strategic CoT)** - Step 1: 确定初始位置,优先向右移动以避开左侧路径。 - Step 2: 规划撤退路线,利用悬崖延迟敌军追击。 - Step 3: 监控敌军动向,调整位置以保持视野和攻击优势。 5.3 **应急思维链(Emergency CoT)** - Step 1: 立即评估周围威胁,确定最安全的撤退方向。 - Step 2: 优先移动到低地或安全区域,避免被包围。 - Step 3: 在安全位置等待武器冷却结束,准备反击。
2. 条件触发机制

在决策过程中,基于当前条件触发相应的思维链。

示例

plaintext
4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `Time < 6s`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。
3. 思维链之间的协调与切换

确保在切换思维链时,前一个思维链的决策不会冲突,并且能够顺畅过渡到新的思维链。

实现方法

  • 统一的决策层:在顶层决策中,根据条件选择思维链,确保切换的逻辑性。
  • 状态保持与重置:在切换思维链时,保持必要的状态信息,重置不相关的状态。
4. 动态适应与反馈

根据战场的实时变化,动态调整思维链的选择和内容,确保决策的实时性和准确性。

实现方法

  • 实时信息更新:在每个决策步骤中,更新 Colossus 和 Zerglings 的状态信息。
  • 反馈机制:根据执行结果,调整后续决策路径,优化策略效果。

五、优化后的多思维链提示词示例

以下是优化后的提示词示例,展示了如何在提示词中整合多思维链,实现灵活切换和提高推理结果。

plaintext
### 多思维链决策框架 1. 角色描述 你是 Protoss 前线指挥官,控制一个巨像。主要任务是利用巨像的远程攻击和高生命值优势,抵御并消灭32个 Zerglings 的数量优势,确保巨像的生存。 2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格32 &times; 32像素,共8 &times; 8个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。 4. 决策过程 4.1 条件评估 - IS_HIGH_GROUND: True/False - IS_ZERG_HIGH_GROUND: True/False - IS_ZERG_NEAR_COLOSSUS: True/False - IS_COLOSSUS_AT_CLIFF: True/False - IS_COLOSSUS_WEAPON_COOLDOWN: True/False - IS_COLOSSUS_HEALTH_LOW: True/False 4.2 多思维链选择 - **战术思维链(Tactical CoT)**: - 适用情境:敌军接近且武器未冷却。 - **战略思维链(Strategic CoT)**: - 适用情境:早期游戏阶段,需布局和位置选择。 - **应急思维链(Emergency CoT)**: - 适用情境:武器冷却中或被包围,需迅速脱离危险。 4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `Time < 6s`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。 5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - Step 1: 评估敌军位置和数量。 - Step 2: 确定最佳攻击目标,优先攻击密集群体。 - Step 3: 选择移动路径,保持在最大攻击范围内。 5.2 **战略思维链(Strategic CoT)** - Step 1: 确定初始位置,优先向右移动以避开左侧路径。 - Step 2: 规划撤退路线,利用悬崖延迟敌军追击。 - Step 3: 监控敌军动向,调整位置以保持视野和攻击优势。 5.3 **应急思维链(Emergency CoT)** - Step 1: 立即评估周围威胁,确定最安全的撤退方向。 - Step 2: 优先移动到低地或安全区域,避免被包围。 - Step 3: 在安全位置等待武器冷却结束,准备反击。 6. 综合战略与决策框架 6.1 战略建议 - **当前战略**:根据触发的思维链,执行相应的战术或战略行动。 - **动态调整**:根据实时战场信息,随时切换思维链,确保策略的适应性和灵活性。 6.2 动作生成与执行 - **动作优先级排序**:根据当前思维链的决策,排序生成的动作。 - **动作多样性**:避免重复单一动作,确保策略多样化。 - **动作可执行性检查**:确保生成的动作符合游戏机制,避免冲突和无效指令。 7. 思维链协调与反馈 7.1 状态保持与重置 - 在切换思维链时,保持必要的状态信息,重置不相关的状态。 7.2 反馈机制 - 根据执行结果,调整后续决策路径,优化策略效果。 8. 动作输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。

六、思维链优化的具体方法

1. 结构化与模块化设计

将不同的思维链模块化,使其在特定情境下能够独立工作,同时保持整体框架的统一性。

实施方法

  • 明确分工:每个思维链专注于特定的决策层面或情境。
  • 独立推理路径:确保每个思维链的推理路径不互相干扰,但在需要时可以协同工作。
2. 条件触发与思维链选择

通过明确的条件触发机制,指导模型在不同情境下选择合适的思维链进行推理。

实施方法

  • 逻辑判断:在决策过程中,根据当前条件评估结果,选择最适合的思维链。
  • 优先级设置:设定思维链的优先级,确保在多条件满足时选择最关键的思维链。
3. 增强思维链的动态适应能力

使思维链能够根据实时战场信息动态调整决策,提升决策的实时性与准确性。

实施方法

  • 实时信息更新:在每个决策步骤中,实时更新单位状态和战场信息。
  • 反馈机制:根据行动结果,调整后续的思维链选择和决策路径。
4. 整合领域特定的启发式规则

结合《星际争霸 II》的专业知识,增强思维链的决策能力和战术效果。

实施方法

  • 单位特性利用:充分利用巨像的远程攻击和高生命值,制定针对性的战术。
  • 地形优势利用:优化利用高地、低地和悬崖等地形特征,提升战术效果。
  • 敌军行为模式识别:根据 Zerglings 的移动和攻击模式,动态调整策略。
5. 案例驱动的思维链优化

通过具体战斗案例分析,优化思维链的决策逻辑,提高其在实际战场中的表现。

实施方法

  • 案例收集与分析:收集不同战场情境下的成功与失败案例,分析决策逻辑的优劣。
  • 经验规则提炼:从案例中提炼出有效的决策规则,整合到思维链中。
  • 持续优化:根据新案例不断调整和优化思维链的规则与逻辑。

七、论文改进思路

基于上述多思维链的优化建议,以下是改进后的论文撰写思路,重点在于方法与提示词内容的优化,特别是针对思维链的调整和多思维链的实现。

1. 引言
  • 背景介绍:介绍 Visual-CoT 框架及其在《星际争霸 II》中的应用。
  • 研究动机:阐述在1巨像对抗32小狗场景下的挑战与现有方法的局限性。
  • 研究贡献:提出通过引入多思维链,优化提示词结构,提高模型在复杂战场中的决策与行动能力。
2. 相关工作
  • LLM 在策略游戏中的应用:回顾现有研究,尤其是在《星际争霸 II》中的应用案例。
  • 多思维链与 CoT 方法:探讨如何通过多思维链与 CoT 方法提升模型的决策能力。
  • 思维链优化技术:介绍现有的思维链优化技术及其在其他领域的应用。
3. 方法

3.1 Visual-CoT 框架优化

  • 多思维链设计:详细描述如何定义和整合多个思维链(战术、战略、应急),以及它们的应用场景。
  • 结构化提示词设计:介绍如何通过结构化和模块化设计,优化提示词的组织与内容。
  • 条件触发机制:阐述如何基于条件评估触发相应的思维链,确保决策的灵活性和适应性。

3.2 思维链内容优化

  • 战术思维链(Tactical CoT):详细描述其推理路径和决策步骤。
  • 战略思维链(Strategic CoT):详细描述其推理路径和决策步骤。
  • 应急思维链(Emergency CoT):详细描述其推理路径和决策步骤。

3.3 领域特定启发式规则整合

  • 单位特性利用:结合巨像的远程攻击和高生命值,优化战术决策。
  • 地形优势利用:优化利用高地、低地和悬崖等地形特征,提升战术效果。
  • 敌军行为模式识别:基于 Zerglings 的移动和攻击模式,动态调整策略。

3.4 案例驱动的思维链优化

  • 案例收集与分析:收集不同战场情境下的成功与失败案例。
  • 经验规则提炼:从案例中提炼有效的决策规则,整合到思维链中。
  • 持续优化机制:根据新案例不断调整和优化思维链的规则与逻辑。
4. 实验设计与结果
  • 实验环境:描述在 LLM-PySC2 环境下的实验设置,包括地图设计、单位配置等。
  • 对比实验:展示优化前后的对比实验结果,重点在胜率、击杀数、决策速度等指标上的提升。
  • 案例分析:通过具体的战斗案例,展示优化后的 Visual-CoT 框架如何有效应对1巨像对抗32小狗的情境。
5. 讨论
  • 优化效果分析:深入探讨引入多思维链后,决策质量与动作控制上的提升。
  • 模型理解与决策透明性:讨论多思维链方法如何提升模型的决策透明性与可解释性。
  • 应用扩展与未来工作:展望 Visual-CoT 框架在其他复杂环境与多智能体协作中的应用前景。
6. 结论
  • 总结贡献:概括优化后的 Visual-CoT 框架在1巨像对抗32小狗场景中的表现与优势。
  • 未来方向:提出进一步优化提示词设计、引入更先进的视觉技术、扩展至其他策略游戏与实际应用领域的计划。

八、总结

通过在提示词中引入多思维链(Multi-CoT),并实现灵活切换,可以显著提升模型在复杂决策任务中的推理深度与决策质量。结合《星际争霸 II》的深层策略知识,优化思维链的结构与内容,整合领域特定的启发式规则,能够有效应对1巨像对抗32小狗的复杂战场情境。同时,通过案例驱动的思维链优化和动态适应机制,确保模型的决策具有高度的灵活性和适应性。

这种多思维链的方法不仅适用于《星际争霸 II》,还可以扩展至其他需要多层次决策和策略优化的复杂任务中,如机器人控制、自动驾驶和虚拟助手等领域。未来,随着技术的不断进步,多思维链的应用将进一步推动基于大型语言模型的复杂决策方法的发展,提升其在各种实际应用中的表现与效能。

如果您有进一步的需求或具体问题,欢迎继续交流,我将为您提供更详细的支持和建议。

질문

我希望的输出是,输出的攻击和移动指令能够有优先级排序;如果移动距离较远的话,可以中间插入空动作,<No_Operation()>来使用。

사고

调整攻防策略

我正在调整输出的优先级并插入<No_Operation()>,以便更好地控制Protoss Colossus的行动。

优化输出命令

为了更好地控制Protoss Colossus的行动,我正在优化输出命令的优先级,并在长距离移动时插入<No_Operation()>。

集成和优化

我正在集成这些想法,确保攻击和移动命令的优先级正确,并在长距离移动间插入<No_Operation()>。还会解释如何定义优先级。

思考,持续 4 秒

답변

优化 Visual-CoT 框架以实现动作优先级排序与插入空动作

感谢您提供的进一步需求。为了增强 Visual-CoT 框架在 1 巨像对抗 32 小狗 场景中的表现,以下是针对动作优先级排序和**插入空动作(<No_Operation()>)**的详细优化建议。


一、目标与需求分析

  1. 动作优先级排序

    • 目标:确保生成的攻击和移动指令按照优先级顺序执行,提升战术效率和战略效果。
    • 需求
      • 为每个动作分配优先级。
      • 高优先级动作先执行,低优先级动作后执行。
  2. 插入空动作(<No_Operation()>)

    • 目标:当移动距离较远时,通过插入空动作来模拟移动过程中的时间消耗,确保动作的平滑执行和战术延续性。
    • 需求
      • 根据移动距离决定插入的 <No_Operation()> 数量。
      • 设定一个移动距离阈值,超过该阈值的移动动作需要插入空动作。

二、优化策略

1. 定义动作优先级
  • 优先级等级

    • 高优先级(1):紧急撤退、避免被包围等关键动作。
    • 中优先级(2):攻击密集敌军、保持攻击范围等重要动作。
    • 低优先级(3):非紧急移动、准备攻击等次要动作。
  • 优先级分配原则

    • 紧急性:根据战场紧急情况分配优先级。
    • 战略重要性:根据战略目标的重要性分配优先级。
    • 资源利用:确保高效利用巨像的能力,避免资源浪费。
2. 设定移动距离阈值与插入空动作规则
  • 移动距离阈值:定义一个阈值(例如,移动距离超过10格需要插入空动作)。
  • 插入空动作规则
    • 计算需要插入的 <No_Operation()> 数量:移动距离除以阈值,向上取整。
    • 在每个移动动作后插入相应数量的 <No_Operation()>。
3. 调整思维链(CoT)以支持优先级与空动作
  • 结构化思维链:在思维链中加入优先级评估和空动作插入的步骤。
  • 决策逻辑
    • 评估当前情境,分配动作优先级。
    • 根据移动距离决定是否插入 <No_Operation()>。
    • 生成按优先级排序的动作列表。

三、优化后的提示词示例

以下是整合了动作优先级排序插入空动作的优化提示词示例:

plaintext
### 多思维链决策框架 1. 角色描述 你是 Protoss 前线指挥官,控制一个巨像。主要任务是利用巨像的远程攻击和高生命值优势,抵御并消灭32个 Zerglings 的数量优势,确保巨像的生存。 2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格32 &times; 32像素,共8 &times; 8个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。 4. 决策过程 4.1 条件评估 - IS_HIGH_GROUND: True/False - IS_ZERG_HIGH_GROUND: True/False - IS_ZERG_NEAR_COLOSSUS: True/False - IS_COLOSSUS_AT_CLIFF: True/False - IS_COLOSSUS_WEAPON_COOLDOWN: True/False - IS_COLOSSUS_HEALTH_LOW: True/False - MOVE_DISTANCE: 数值(计算移动距离) 4.2 多思维链选择 - **战术思维链(Tactical CoT)**: - 适用情境:敌军接近且武器未冷却。 - **战略思维链(Strategic CoT)**: - 适用情境:早期游戏阶段,需布局和位置选择。 - **应急思维链(Emergency CoT)**: - 适用情境:武器冷却中或被包围,需迅速脱离危险。 4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `Time < 6s`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。 5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - Step 1: 评估敌军位置和数量。 - Step 2: 确定最佳攻击目标,优先攻击密集群体。 - Step 3: 选择移动路径,保持在最大攻击范围内。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 5.2 **战略思维链(Strategic CoT)** - Step 1: 确定初始位置,优先向右移动以避开左侧路径。 - Step 2: 规划撤退路线,利用悬崖延迟敌军追击。 - Step 3: 监控敌军动向,调整位置以保持视野和攻击优势。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 5.3 **应急思维链(Emergency CoT)** - Step 1: 立即评估周围威胁,确定最安全的撤退方向。 - Step 2: 优先移动到低地或安全区域,避免被包围。 - Step 3: 在安全位置等待武器冷却结束,准备反击。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 6. 综合战略与决策框架 6.1 战略建议 - **当前战略**:根据触发的思维链,执行相应的战术或战略行动。 - **动态调整**:根据实时战场信息,随时切换思维链,确保策略的适应性和灵活性。 6.2 动作生成与执行 - **动作优先级排序**:根据当前思维链的决策,排序生成的动作。 - **动作多样性**:避免重复单一动作,确保策略多样化。 - **动作可执行性检查**:确保生成的动作符合游戏机制,避免冲突和无效指令。 - **插入空动作**:如果移动距离超过阈值(例如,MOVE_DISTANCE > 10),则在移动动作之间插入相应数量的 <No_Operation()>。 7. 动作输出 Team Colossus-1: <Move_Screen([160, 200])> # 移动到低地 <No_Operation()> # 空动作 <Attack_Unit(0x1004c0001)> # 攻击最近的 Zergling <Attack_Unit(0x100740001)> # 攻击另一 Zergling

四、优化要点详解

1. 动作优先级排序
  • 定义优先级

    • 每个动作(攻击或移动)在生成时根据其紧急性和重要性被赋予一个优先级值。
    • 优先级值较低的动作(如高优先级1)会在列表中排在前面,先被执行。
  • 实施方法

    • 在每个思维链的 Step 4 中,根据当前情境评估动作的优先级。
    • 使用数值或标签(高、中、低)标记优先级。
    • 按照优先级对动作列表进行排序。
2. 插入空动作(<No_Operation()>)
  • 定义阈值

    • 设定一个移动距离阈值(例如,10格),超过该距离的移动动作需要插入空动作。
  • 计算插入数量

    • 公式:Number of <No_Operation()> = ceil(MOVE_DISTANCE / THRESHOLD) - 1
    • 例如,移动距离15格,阈值10格,则插入2个 <No_Operation()>。
  • 实施方法

    • Step 5 中,计算移动距离并决定是否插入 <No_Operation()>。
    • 如果需要插入,按计算结果在动作列表中相应位置插入空动作。
3. 思维链的结构化与模块化
  • 结构化设计

    • 每个思维链(战术、战略、应急)有明确的步骤和决策路径。
    • 通过模块化设计,确保每个思维链可以独立运行,同时在必要时协同工作。
  • 模块化设计的优势

    • 提高提示词的可读性和可维护性。
    • 便于后续扩展和优化各个思维链的内容。
4. 示例输出的优先级与空动作插入

以下是优化后的示例输出,展示了动作优先级排序和插入空动作的实现:

plaintext
--------------------------------------------------示例输出提示-------------------------------------------------- Analysis: 1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True Colossus 位于高地,已通过图像和坐标确认。 - IS_ZERG_HIGH_GROUND = True Zerglings 主要集中在高地,与 Colossus 位于同一区域。 - IS_ZERG_NEAR_COLOSSUS = True 多个 Zerglings 靠近 Colossus,位于攻击范围内(&le;7),构成即时威胁。 - IS_COLOSSUS_AT_CLIFF = False Colossus 靠近地图的红色边界,不靠近悬崖。 - IS_COLOSSUS_WEAPON_COOLDOWN = True 武器处于冷却中,无法立即攻击敌军。 - IS_COLOSSUS_HEALTH_LOW = False Colossus 健康状态良好(100%),无低健康威胁。 - MOVE_DISTANCE = 50 1.2 Action Decision Rules Brief Recap - **移动优先情境**: 1. 武器冷却中:移动 > 攻击 2. 即将被包围:优先移动逃离 3. 早期游戏阶段(<6秒):优先向右移动,移动 > 攻击 1.3 Judgment Based on Action Decision Rules - **特殊规则优先**: - 武器冷却中,优先移动以避免被包围。 - **情境匹配**: - 当前情境符合应急思维链(敌人接近,武器冷却中),优先移动。 - **决策**: - 移动 > 攻击 - 立即撤退到低地,利用悬崖延迟追击,等待武器冷却完成。 2. Integrated Strategy and Decision Framework 2.1 Strategy Suggestions **当前战略**:紧急撤退到低地 - Colossus 位于高地,敌军数量众多且接近。 - 快速撤退到低地(灰色区域),利用悬崖障碍延迟 Zerglings 追击,为武器冷却争取时间,确保安全距离。 2.2 Movement Decision Analysis - **敌军进攻路径预测**: - Zerglings 从高地左侧狭窄路径进攻,试图包围 Colossus。 - **移动目标建议**: - 撤退到屏幕坐标 [160, 200],低地悬崖附近的安全区域。 - 移动距离计算:从当前坐标 [150, 123] 到目标坐标 [160, 200],移动距离约为 &radic;((160-150)^2 + (200-123)^2) &asymp; 77 - 根据阈值10格,插入 <No_Operation()> 数量 = ceil(77 / 10) - 1 = 8 2.3 Attack Decision Analysis - **目标优先级**: - 武器冷却结束后,优先攻击最近的 Zerglings,减少即时威胁,最大化溅射伤害。 - **攻击目标选择**: - 优先攻击 Tag: 0x1004c0001 和 Tag: 0x100740001,减少直接威胁。 - 撤退至低地后,优先攻击密集的追击 Zerglings 群体。 3. Actions: Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。

五、实现细节与注意事项

1. 动作优先级排序的实现
  • 优先级赋值

    • 在生成每个动作时,根据其紧急性和战略重要性赋予一个优先级值。
    • 高优先级(1)动作会在列表中排在前面,确保先被执行。
  • 排序机制

    • 使用编程逻辑(如按优先级值排序)确保动作列表按照优先级顺序排列。
2. 插入空动作的实现
  • 移动距离计算

    • 根据当前坐标与目标坐标,计算需要移动的总距离。
    • 示例:从 [150, 123] 移动到 [160, 200],总距离约为77格。
  • 插入空动作数量

    • 设定阈值为10格,移动距离超过10格则需要插入空动作。
    • 计算公式:Number of <No_Operation()> = ceil(MOVE_DISTANCE / 10) - 1
    • 示例:77格移动距离,插入 ceil(77/10) - 1 = 8 个 <No_Operation()>。
  • 插入位置

    • 将 <Move_Screen()> 动作后插入相应数量的 <No_Operation()>,模拟移动过程中的时间消耗。
3. 多思维链的协调与切换
  • 统一决策层

    • 顶层决策根据条件评估选择适当的思维链。
    • 确保思维链之间的切换逻辑清晰,避免冲突。
  • 状态保持与重置

    • 在切换思维链时,保持必要的状态信息,如当前健康状态、武器冷却状态等。
    • 重置不相关的状态,确保新思维链能够独立运行。
4. 思维链内容的优化
  • 战术思维链

    • 聚焦于当前战场上的即时战术决策,如攻击密集敌军、保持攻击范围等。
  • 战略思维链

    • 聚焦于整体战略布局和位置选择,如初始位置调整、撤退路线规划等。
  • 应急思维链

    • 处理突发情况,如紧急撤退、避免被包围等。
5. 示例代码与模板化设计

为了进一步提升提示词的可维护性和灵活性,可以采用模板化设计,通过占位符和变量动态生成提示词内容。

示例代码(使用 Jinja2 模板引擎):

python
from jinja2 import Template import math # 定义模板 system_prompt_template = """ ### 多思维链决策框架 1. 角色描述 你是 Protoss 前线指挥官,控制一个巨像。主要任务是利用巨像的远程攻击和高生命值优势,抵御并消灭32个 Zerglings 的数量优势,确保巨像的生存。 2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格32 &times; 32像素,共8 &times; 8个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。 4. 决策过程 4.1 条件评估 - IS_HIGH_GROUND: {{ IS_HIGH_GROUND }} - IS_ZERG_HIGH_GROUND: {{ IS_ZERG_HIGH_GROUND }} - IS_ZERG_NEAR_COLOSSUS: {{ IS_ZERG_NEAR_COLOSSUS }} - IS_COLOSSUS_AT_CLIFF: {{ IS_COLOSSUS_AT_CLIFF }} - IS_COLOSSUS_WEAPON_COOLDOWN: {{ IS_COLOSSUS_WEAPON_COOLDOWN }} - IS_COLOSSUS_HEALTH_LOW: {{ IS_COLOSSUS_HEALTH_LOW }} - MOVE_DISTANCE: {{ MOVE_DISTANCE }} 4.2 多思维链选择 - **战术思维链(Tactical CoT)**: - 适用情境:敌军接近且武器未冷却。 - **战略思维链(Strategic CoT)**: - 适用情境:早期游戏阶段,需布局和位置选择。 - **应急思维链(Emergency CoT)**: - 适用情境:武器冷却中或被包围,需迅速脱离危险。 4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `Time < 6s`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。 5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - Step 1: 评估敌军位置和数量。 - Step 2: 确定最佳攻击目标,优先攻击密集群体。 - Step 3: 选择移动路径,保持在最大攻击范围内。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 5.2 **战略思维链(Strategic CoT)** - Step 1: 确定初始位置,优先向右移动以避开左侧路径。 - Step 2: 规划撤退路线,利用悬崖延迟敌军追击。 - Step 3: 监控敌军动向,调整位置以保持视野和攻击优势。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 5.3 **应急思维链(Emergency CoT)** - Step 1: 立即评估周围威胁,确定最安全的撤退方向。 - Step 2: 优先移动到低地或安全区域,避免被包围。 - Step 3: 在安全位置等待武器冷却结束,准备反击。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 6. 综合战略与决策框架 6.1 战略建议 - **当前战略**:根据触发的思维链,执行相应的战术或战略行动。 - **动态调整**:根据实时战场信息,随时切换思维链,确保策略的适应性和灵活性。 6.2 动作生成与执行 - **动作优先级排序**:根据当前思维链的决策,排序生成的动作。 - **动作多样性**:避免重复单一动作,确保策略多样化。 - **动作可执行性检查**:确保生成的动作符合游戏机制,避免冲突和无效指令。 - **插入空动作**:如果移动距离超过阈值(如 MOVE_DISTANCE > 10),则在移动动作之间插入相应数量的 <No_Operation()>。 7. 思维链协调与反馈 7.1 状态保持与重置 - 在切换思维链时,保持必要的状态信息,重置不相关的状态。 7.2 反馈机制 - 根据执行结果,调整后续决策路径,优化策略效果。 8. 动作输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 {% for _ in range(no_operations) %} <No_Operation()> # 空动作 {% endfor %} <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。 """ # 示例填充参数 filled_system_prompt = Template(system_prompt_template).render( IS_HIGH_GROUND=True, IS_ZERG_HIGH_GROUND=True, IS_ZERG_NEAR_COLOSSUS=True, IS_COLOSSUS_AT_CLIFF=False, IS_COLOSSUS_WEAPON_COOLDOWN=True, IS_COLOSSUS_HEALTH_LOW=False, MOVE_DISTANCE=50, no_operations=math.ceil(50 / 10) - 1 # 50/10=5, 5-1=4 ) print(filled_system_prompt)

输出示例:

plaintext
### 多思维链决策框架 1. 角色描述 你是 Protoss 前线指挥官,控制一个巨像。主要任务是利用巨像的远程攻击和高生命值优势,抵御并消灭32个 Zerglings 的数量优势,确保巨像的生存。 2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格32 &times; 32像素,共8 &times; 8个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。 4. 决策过程 4.1 条件评估 - IS_HIGH_GROUND: True - IS_ZERG_HIGH_GROUND: True - IS_ZERG_NEAR_COLOSSUS: True - IS_COLOSSUS_AT_CLIFF: False - IS_COLOSSUS_WEAPON_COOLDOWN: True - IS_COLOSSUS_HEALTH_LOW: False - MOVE_DISTANCE: 50 4.2 多思维链选择 - **战术思维链(Tactical CoT)**: - 适用情境:敌军接近且武器未冷却。 - **战略思维链(Strategic CoT)**: - 适用情境:早期游戏阶段,需布局和位置选择。 - **应急思维链(Emergency CoT)**: - 适用情境:武器冷却中或被包围,需迅速脱离危险。 4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `Time < 6s`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。 5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - Step 1: 评估敌军位置和数量。 - Step 2: 确定最佳攻击目标,优先攻击密集群体。 - Step 3: 选择移动路径,保持在最大攻击范围内。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 5.2 **战略思维链(Strategic CoT)** - Step 1: 确定初始位置,优先向右移动以避开左侧路径。 - Step 2: 规划撤退路线,利用悬崖延迟敌军追击。 - Step 3: 监控敌军动向,调整位置以保持视野和攻击优势。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 5.3 **应急思维链(Emergency CoT)** - Step 1: 立即评估周围威胁,确定最安全的撤退方向。 - Step 2: 优先移动到低地或安全区域,避免被包围。 - Step 3: 在安全位置等待武器冷却结束,准备反击。 - Step 4: 分配动作优先级。 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 6. 综合战略与决策框架 6.1 战略建议 - **当前战略**:根据触发的思维链,执行相应的战术或战略行动。 - **动态调整**:根据实时战场信息,随时切换思维链,确保策略的适应性和灵活性。 6.2 动作生成与执行 - **动作优先级排序**:根据当前思维链的决策,排序生成的动作。 - **动作多样性**:避免重复单一动作,确保策略多样化。 - **动作可执行性检查**:确保生成的动作符合游戏机制,避免冲突和无效指令。 - **插入空动作**:如果移动距离超过阈值(如 MOVE_DISTANCE > 10),则在移动动作之间插入相应数量的 <No_Operation()>。 7. 思维链协调与反馈 7.1 状态保持与重置 - 在切换思维链时,保持必要的状态信息,重置不相关的状态。 7.2 反馈机制 - 根据执行结果,调整后续决策路径,优化策略效果。 8. 动作输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。

六、进一步优化思维链的方法

1. 结构化与模块化设计
  • 明确分工:每个思维链专注于特定的决策层面或情境。
  • 独立推理路径:确保每个思维链的推理路径不互相干扰,但在需要时可以协同工作。
2. 条件触发与思维链选择
  • 逻辑判断:在决策过程中,根据当前条件评估结果,选择最适合的思维链。
  • 优先级设置:设定思维链的优先级,确保在多条件满足时选择最关键的思维链。
3. 思维链之间的协调与切换
  • 统一的决策层:顶层决策根据条件选择思维链,确保切换的逻辑性。
  • 状态保持与重置:在切换思维链时,保持必要的状态信息,重置不相关的状态。
4. 增强思维链的动态适应能力
  • 实时信息更新:在每个决策步骤中,实时更新 Colossus 和 Zerglings 的状态信息。
  • 条件嵌套:根据不同条件嵌套决策规则,提升决策的灵活性和适应性。
  • 反馈机制:根据执行结果,调整后续决策路径,优化策略效果。
5. 整合领域特定的启发式规则
  • 单位特性利用:充分利用巨像的远程攻击和高生命值,制定针对性的战术。
  • 地形优势利用:优化利用高地、低地和悬崖等地形特征,提升战术效果。
  • 敌军行为模式识别:根据 Zerglings 的移动和攻击模式,动态调整策略。
6. 案例驱动的思维链优化
  • 案例收集与分析:收集不同战场情境下的成功与失败案例,分析决策逻辑的优劣。
  • 经验规则提炼:从案例中提炼出有效的决策规则,整合到思维链中。
  • 持续优化机制:根据新案例不断调整和优化思维链的规则与逻辑。

七、论文改进思路

基于上述优化建议,以下是改进后的论文撰写思路,重点在于方法与提示词内容的优化,特别是针对多思维链的实现与动作优先级排序的整合。

1. 引言
  • 背景介绍:介绍 Visual-CoT 框架及其在《星际争霸 II》中的应用。
  • 研究动机:阐述在 1 巨像对抗 32 小狗场景下的挑战与现有方法的局限性。
  • 研究贡献:提出通过引入多思维链,优化动作优先级排序与插入空动作,提升模型在复杂战场中的决策与行动能力。
2. 相关工作
  • LLM 在策略游戏中的应用:回顾现有研究,尤其是在《星际争霸 II》中的应用案例。
  • 多思维链与 CoT 方法:探讨如何通过多思维链与 CoT 方法提升模型的决策能力。
  • 动作优先级排序与空动作插入技术:介绍现有的动作优先级排序与空动作插入技术及其在其他领域的应用。
3. 方法

3.1 Visual-CoT 框架优化

  • 多思维链设计:详细描述如何定义和整合多个思维链(战术、战略、应急),以及它们的应用场景。
  • 结构化提示词设计:介绍如何通过结构化和模块化设计,优化提示词的组织与内容。
  • 动作优先级排序与空动作插入:阐述如何为动作分配优先级,并根据移动距离插入 <No_Operation()>。

3.2 思维链内容优化

  • 战术思维链(Tactical CoT):详细描述其推理路径和决策步骤。
  • 战略思维链(Strategic CoT):详细描述其推理路径和决策步骤。
  • 应急思维链(Emergency CoT):详细描述其推理路径和决策步骤。

3.3 领域特定启发式规则整合

  • 单位特性利用:结合巨像的远程攻击和高生命值,优化战术决策。
  • 地形优势利用:优化利用高地、低地和悬崖等地形特征,提升战术效果。
  • 敌军行为模式识别:基于 Zerglings 的移动和攻击模式,动态调整策略。

3.4 案例驱动的思维链优化

  • 案例收集与分析:收集不同战场情境下的成功与失败案例。
  • 经验规则提炼:从案例中提炼有效的决策规则,整合到思维链中。
  • 持续优化机制:根据新案例不断调整和优化思维链的规则与逻辑。
4. 实验设计与结果
  • 实验环境:描述在 LLM-PySC2 环境下的实验设置,包括地图设计、单位配置等。
  • 对比实验:展示优化前后的对比实验结果,重点在胜率、击杀数、决策速度等指标上的提升。
  • 案例分析:通过具体的战斗案例,展示优化后的 Visual-CoT 框架如何有效应对 1 巨像对抗 32 小狗的情境。
5. 讨论
  • 优化效果分析:深入探讨引入多思维链和动作优先级排序后,决策质量与动作控制上的提升。
  • 模型理解与决策透明性:讨论多思维链方法如何提升模型的决策透明性与可解释性。
  • 应用扩展与未来工作:展望 Visual-CoT 框架在其他复杂环境与多智能体协作中的应用前景。
6. 结论
  • 总结贡献:概括优化后的 Visual-CoT 框架在 1 巨像对抗 32 小狗场景中的表现与优势。
  • 未来方向:提出进一步优化提示词设计、引入更先进的视觉技术、扩展至其他策略游戏与实际应用领域的计划。

八、结语

通过在提示词中引入多思维链(Multi-CoT),并实现动作优先级排序插入空动作(<No_Operation()>),可以显著提升模型在复杂决策任务中的推理深度与决策质量。结合《星际争霸 II》的深层策略知识,优化思维链的结构与内容,整合领域特定的启发式规则,能够有效应对1巨像对抗32小狗的复杂战场情境。

这种多思维链的方法不仅适用于《星际争霸 II》,还可以扩展至其他需要多层次决策和策略优化的复杂任务中,如机器人控制、自动驾驶和虚拟助手等领域。未来,随着技术的不断进步,多思维链的应用将进一步推动基于大型语言模型的复杂决策方法的发展,提升其在各种实际应用中的表现与效能。

如果您有进一步的需求或具体问题,欢迎继续交流,我将为您提供更详细的支持和建议。

질문

就是需要实现这样的效果, 同时还要有多思维链在其中,请你判断可行性以及给出具体思路。
4.2 Action Decision Rules

text
- Special Scenarios: rule1 :As long as the weapon is in cooldown, the priority of movement actions is higher than attack actions. Movement > Attack. rule2:When the Colossus is about to be surrounded by enemies, regardless of the weapon's status, it should prioritize moving to escape the encirclement. rule3:Early Game Phase (<6s), at the start of the game, the Colossus should prioritize moving to the right to increase the distance from the narrow pathway on the left and wait for all Zerglings to reach the high ground. During this phase, movement takes priority over attacking. - Situation 1: The Colossus and Zerglings are in different areas - Weapon not on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = False): - Priority: Attack. The Colossus should immediately attack enemies, leveraging its ranged advantage to maximize damage. - Weapon on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = True): - Priority: Move. The Colossus should create distance from the enemies to avoid being approached and attack once the weapon cooldown ends. - Situation 2: The Colossus and Zerglings are in the same area - Enemies are near and about to attack (IS_ZERG_NEAR = True, Zerglings approaching): - Priority: Move. Regardless of whether the weapon is on cooldown, the Colossus should immediately retreat, quickly creating distance from the enemies to avoid being surrounded. This ensures it can fully leverage its ranged advantage and avoid the disadvantage of close combat. Once out of danger, it can then look for opportunities to counterattack. - Enemies are not near (IS_ZERG_NEAR = False): - Weapon not on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = False): - Priority: Attack. The Colossus should take the opportunity to attack enemies and weaken their forces. - Weapon on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = True): - Priority: Move. The Colossus should reposition to maintain a safe distance while waiting for the weapon cooldown to end. - Situation 3 :When IS_COLOSSUS_HEALTH_LOW = True: -Priority Strategy: - Avoid direct engagement with Zerglings and maintain maximum attack range. - Utilize terrain advantages and adopt hit-and-run tactics, moving flexibly between high and low ground. - Priority: Movement > Attack

사고

I'm working through a tailored Visual-CoT framework to optimize attack and move commands, factoring in coverage for extensive movements and adhering to specific rules.

规划优先级和插入

正在构思Visual-CoT框架中优先级行动和插入<No_Operation()>的可行性,可能需要编辑CoT的提示机制,确保涵盖特定规则和情况。

思考,持续 4 秒

답변

可行性判断与具体实现思路

一、可行性判断

可行性:高

在《星际争霸 II》1巨像对抗32小狗的场景中,实现动作优先级排序与插入空动作(<No_Operation()>)是完全可行的,尤其结合**多思维链(Multi-CoT)**的方法。这一优化不仅能够提升决策的效率和准确性,还能模拟复杂的战术动作执行过程,提高模型在动态战场环境中的适应能力。

主要原因:

  1. 逻辑分层:通过多思维链的设计,可以将不同层次的决策逻辑分开处理,便于整合优先级排序和空动作插入的规则。
  2. 条件触发:基于明确的条件触发机制,能够灵活选择合适的思维链,并在生成动作列表时应用优先级和空动作规则。
  3. 可扩展性:框架化和模块化的设计使得后续扩展和优化更加便捷,无需大幅度修改现有结构。

二、具体实现思路

为了实现动作优先级排序插入空动作,同时保持多思维链的结构,以下是详细的实现步骤和思路:


一、框架结构优化

1. 多思维链设计

现有思维链:

  • 战术思维链(Tactical CoT)
  • 战略思维链(Strategic CoT)
  • 应急思维链(Emergency CoT)

新增功能:

  • 动作优先级排序
  • 插入空动作(<No_Operation()>)

2. 动作优先级排序

优先级等级:

  • 高优先级(1):紧急撤退、避免被包围等关键动作。
  • 中优先级(2):攻击密集敌军、保持攻击范围等重要动作。
  • 低优先级(3):非紧急移动、准备攻击等次要动作。

优先级分配原则:

  • 紧急性:根据战场紧急情况分配优先级。
  • 战略重要性:根据战略目标的重要性分配优先级。
  • 资源利用:确保高效利用巨像的能力,避免资源浪费。

3. 插入空动作(<No_Operation()>)

移动距离阈值:

  • 设定一个阈值(如10格),超过该距离的移动动作需要插入空动作。

插入规则:

  • 计算需要插入的 <No_Operation()> 数量:ceil(MOVE_DISTANCE / THRESHOLD) - 1
  • 在每个移动动作后插入相应数量的 <No_Operation()>。

二、提示词结构调整

为实现上述功能,需要在提示词中引入动作优先级排序和空动作插入的逻辑。以下是具体的调整思路:

1. 增加动作优先级评估与排序步骤

在每个思维链中,添加步骤以评估和排序动作的优先级。

2. 计算移动距离并插入空动作

在生成移动动作时,计算移动距离并根据阈值插入空动作。

3. 多思维链协调

确保在顶层决策中选择合适的思维链,并在每个思维链内部执行优先级排序和空动作插入。


三、优化后的提示词示例

以下是整合了动作优先级排序插入空动作的优化提示词示例,展示如何在多思维链框架中实现这些功能。

plaintext
### 多思维链决策框架 1. 角色描述 你是 Protoss 前线指挥官,控制一个巨像。主要任务是利用巨像的远程攻击和高生命值优势,抵御并消灭32个 Zerglings 的数量优势,确保巨像的生存。 2. 地图信息 - 坐标系统:[0, 256] &times; [0, 256],每格32 &times; 32像素,共8 &times; 8个网格。 - 地形特征: - 高地(浅绿):上层平台,提供视野和攻击优势。 - 低地(深灰):下层平台,易于防守但缺乏视野。 - 悬崖(浅灰):高低地分界,巨像可自由穿越,Zerglings只能通过左侧狭窄路径进入高地。 - 边界(深红):地图边缘不可通行。 3. 关键胜利点 - 保持最大攻击范围(范围7),利用远程优势。 - 集中火力攻击密集敌军群体,最大化溅射伤害。 - 利用悬崖延迟敌军追击,重新定位和攻击。 4. 决策过程 4.1 条件评估 - IS_HIGH_GROUND: True/False - IS_ZERG_HIGH_GROUND: True/False - IS_ZERG_NEAR_COLOSSUS: True/False - IS_COLOSSUS_AT_CLIFF: True/False - IS_COLOSSUS_WEAPON_COOLDOWN: True/False - IS_COLOSSUS_HEALTH_LOW: True/False - MOVE_DISTANCE: 数值(计算移动距离) - TIME: 游戏时间(秒) 4.2 多思维链选择 - **战术思维链(Tactical CoT)**: - 适用情境:敌军接近且武器未冷却。 - **战略思维链(Strategic CoT)**: - 适用情境:早期游戏阶段,需布局和位置选择。 - **应急思维链(Emergency CoT)**: - 适用情境:武器冷却中或被包围,需迅速脱离危险。 4.3 思维链触发规则 - 如果 `IS_COLOSSUS_HEALTH_LOW = True` 或 `IS_ZERG_NEAR_COLOSSUS = True`,触发 **应急思维链**。 - 如果 `TIME < 6`,触发 **战略思维链**。 - 否则,触发 **战术思维链**。 5. 思维链内容 5.1 **战术思维链(Tactical CoT)** - Step 1: 评估敌军位置和数量。 - Step 2: 确定最佳攻击目标,优先攻击密集群体。 - Step 3: 选择移动路径,保持在最大攻击范围内。 - Step 4: 分配动作优先级。 - 高优先级:紧急撤退、避免被包围。 - 中优先级:攻击密集敌军、保持攻击范围。 - 低优先级:非紧急移动、准备攻击。 - Step 5: 生成优先级排序的动作列表。 - Step 6: 根据 MOVE_DISTANCE 插入 <No_Operation()>。 - 如果 MOVE_DISTANCE > 10,则插入 `ceil(MOVE_DISTANCE / 10) - 1` 个 <No_Operation()>。 5.2 **战略思维链(Strategic CoT)** - Step 1: 确定初始位置,优先向右移动以避开左侧路径。 - Step 2: 规划撤退路线,利用悬崖延迟敌军追击。 - Step 3: 监控敌军动向,调整位置以保持视野和攻击优势。 - Step 4: 分配动作优先级。 - 高优先级:战略位置调整、撤退路线规划。 - 中优先级:监控敌军动向。 - 低优先级:非紧急移动。 - Step 5: 生成优先级排序的动作列表。 - Step 6: 根据 MOVE_DISTANCE 插入 <No_Operation()>。 - 如果 MOVE_DISTANCE > 10,则插入 `ceil(MOVE_DISTANCE / 10) - 1` 个 <No_Operation()>。 5.3 **应急思维链(Emergency CoT)** - Step 1: 立即评估周围威胁,确定最安全的撤退方向。 - Step 2: 优先移动到低地或安全区域,避免被包围。 - Step 3: 在安全位置等待武器冷却结束,准备反击。 - Step 4: 分配动作优先级。 - 高优先级:紧急撤退、避免被包围。 - 中优先级:保持安全位置。 - 低优先级:准备反击。 - Step 5: 生成优先级排序的动作列表。 - Step 6: 根据 MOVE_DISTANCE 插入 <No_Operation()>。 - 如果 MOVE_DISTANCE > 10,则插入 `ceil(MOVE_DISTANCE / 10) - 1` 个 <No_Operation()>。 6. 综合战略与决策框架 6.1 战略建议 - **当前战略**:根据触发的思维链,执行相应的战术或战略行动。 - **动态调整**:根据实时战场信息,随时切换思维链,确保策略的适应性和灵活性。 6.2 动作生成与执行 - **动作优先级排序**:根据当前思维链的决策,排序生成的动作。 - **动作多样性**:避免重复单一动作,确保策略多样化。 - **动作可执行性检查**:确保生成的动作符合游戏机制,避免冲突和无效指令。 - **插入空动作**:如果移动距离超过阈值(如 MOVE_DISTANCE > 10),则在移动动作之间插入相应数量的 <No_Operation()>。 7. 思维链协调与反馈 7.1 状态保持与重置 - 在切换思维链时,保持必要的状态信息,重置不相关的状态。 7.2 反馈机制 - 根据执行结果,调整后续决策路径,优化策略效果。 8. 动作输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。

四、具体实现步骤

1. 多思维链决策流程

顶层决策流程:

  1. 条件评估:根据当前战场状态评估各个条件。
  2. 思维链选择:根据条件触发规则选择适当的思维链。
  3. 动作生成
    • 依据所选思维链的步骤生成动作列表。
    • 在动作列表中根据优先级排序。
    • 根据移动距离插入空动作。
  4. 动作输出:按照排序后的动作列表执行指令。

2. 动作优先级排序与插入空动作

动作优先级排序:

  • 在每个思维链中,动作生成步骤应包含为每个动作分配优先级,并根据优先级对动作列表进行排序。

插入空动作:

  • 在生成移动动作时,计算移动距离。
  • 如果移动距离超过阈值,则在动作列表中插入相应数量的 <No_Operation()>。

具体步骤示例:

plaintext
5.1 **战术思维链(Tactical CoT)** - Step 1: 评估敌军位置和数量。 - Step 2: 确定最佳攻击目标,优先攻击密集群体。 - Step 3: 选择移动路径,保持在最大攻击范围内。 - Step 4: 分配动作优先级。 - 高优先级:紧急撤退 - 中优先级:攻击密集敌军 - 低优先级:非紧急移动 - Step 5: 生成优先级排序的动作列表。 - 例如:[Attack, Move] - Step 6: 根据 MOVE_DISTANCE 插入 <No_Operation()>。 - MOVE_DISTANCE = 50 - Threshold = 10 - Number of <No_Operation()> = ceil(50 / 10) - 1 = 4 - 生成动作列表:[Move, <No_Operation()>, <No_Operation()>, <No_Operation()>, <No_Operation()>, Attack]

3. 思维链内容优化

战术思维链(Tactical CoT):

  • 专注于当前战场上的即时战术决策,如攻击密集敌军、保持攻击范围等。
  • 分配动作优先级,确保高优先级动作先执行。

战略思维链(Strategic CoT):

  • 专注于整体战略布局和位置选择,如初始位置调整、撤退路线规划等。
  • 分配动作优先级,确保高优先级动作先执行。

应急思维链(Emergency CoT):

  • 处理突发情况,如紧急撤退、避免被包围等。
  • 分配动作优先级,确保高优先级动作先执行。

五、实现细节与注意事项

1. 动作优先级排序的实现

  • 优先级赋值
    • 在每个思维链的动作生成步骤中,为每个动作分配优先级值(1为高优先级,依次类推)。
  • 排序机制
    • 根据优先级值对动作列表进行排序,确保高优先级动作先执行。
  • 编程实现
    • 使用编程语言(如Python)中的排序函数,根据优先级对动作列表进行排序。

示例代码:

python
# 示例动作列表,每个动作是一个元组 (优先级, 动作) actions = [ (2, "<Attack_Unit(0x1004c0001)>"), (1, "<Move_Screen([160, 200])>") ] # 按优先级排序 sorted_actions = sorted(actions, key=lambda x: x[0]) # 提取动作指令 sorted_action_commands = [action[1] for action in sorted_actions]

2. 插入空动作的实现

  • 移动距离计算
    • 使用欧几里得距离公式计算移动距离。
    • 公式:MOVE_DISTANCE = sqrt((x2 - x1)^2 + (y2 - y1)^2)
  • 插入规则
    • 如果 MOVE_DISTANCE > THRESHOLD,则插入 ceil(MOVE_DISTANCE / THRESHOLD) - 1 个 <No_Operation()>。
  • 编程实现
python
import math def calculate_move_distance(current_pos, target_pos): return math.sqrt((target_pos[0] - current_pos[0])**2 + (target_pos[1] - current_pos[1])**2) def insert_no_operations(move_distance, threshold=10): return math.ceil(move_distance / threshold) - 1 current_position = [150, 123] target_position = [160, 200] move_distance = calculate_move_distance(current_position, target_position) no_operations = insert_no_operations(move_distance, threshold=10) # 生成动作列表 actions = ["<Move_Screen([160, 200])>"] + ["<No_Operation()>"] * no_operations + ["<Attack_Unit(0x1004c0001)>", "<Attack_Unit(0x100740001)>"]

3. 多思维链的协调与切换

  • 统一决策层
    • 在顶层决策中,根据条件评估结果选择合适的思维链。
    • 确保思维链之间的切换逻辑清晰,避免冲突。
  • 状态保持与重置
    • 在切换思维链时,保持必要的状态信息,如当前健康状态、武器冷却状态等。
    • 重置不相关的状态,确保新思维链能够独立运行。

4. 思维链内容的优化

  • 确保每个思维链的步骤清晰且独立
    • 每个思维链应包含明确的推理路径和决策步骤,便于模型理解和执行。
  • 结合领域特定的启发式规则
    • 充分利用巨像的远程攻击和高生命值,优化战术决策。
    • 优化利用高地、低地和悬崖等地形特征,提升战术效果。
    • 根据 Zerglings 的移动和攻击模式,动态调整策略。

六、具体示例与输出

以下是一个具体的示例,展示优化后的提示词如何生成按优先级排序的动作列表,并插入相应数量的 <No_Operation()>。

示例条件评估:

  • IS_HIGH_GROUND = True
  • IS_ZERG_HIGH_GROUND = True
  • IS_ZERG_NEAR_COLOSSUS = True
  • IS_COLOSSUS_AT_CLIFF = False
  • IS_COLOSSUS_WEAPON_COOLDOWN = True
  • IS_COLOSSUS_HEALTH_LOW = False
  • MOVE_DISTANCE = 50
  • TIME = 10

触发规则:

  • IS_ZERG_NEAR_COLOSSUS = True,触发 应急思维链(Emergency CoT)

应急思维链内容:

  1. 立即评估周围威胁,确定最安全的撤退方向。
  2. 优先移动到低地或安全区域,避免被包围。
  3. 在安全位置等待武器冷却结束,准备反击。
  4. 分配动作优先级。
  5. 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。

动作生成:

  1. <Move_Screen([160, 200])> (优先级1)
  2. <Attack_Unit(0x1004c0001)> (优先级3)
  3. <Attack_Unit(0x100740001)> (优先级3)

移动距离插入空动作:

  • MOVE_DISTANCE = 50
  • Threshold = 10
  • Number of <No_Operation()> = ceil(50 / 10) - 1 = 4

最终动作列表:

  1. <Move_Screen([160, 200])> # 移动到低地
  2. <No_Operation()> # 空动作
  3. <No_Operation()> # 空动作
  4. <No_Operation()> # 空动作
  5. <No_Operation()> # 空动作
  6. <Attack_Unit(0x1004c0001)> # 攻击最近的 Zergling
  7. <Attack_Unit(0x100740001)> # 攻击另一 Zergling

优化后的示例输出:

plaintext
--------------------------------------------------示例输出提示-------------------------------------------------- Analysis: 1. Decision Process 1.1 Condition Assessment - IS_COLOSSUS_HIGH_GROUND = True Colossus 位于高地,已通过图像和坐标确认。 - IS_ZERG_HIGH_GROUND = True Zerglings 主要集中在高地,与 Colossus 位于同一区域。 - IS_ZERG_NEAR_COLOSSUS = True 多个 Zerglings 靠近 Colossus,位于攻击范围内(&le;7),构成即时威胁。 - IS_COLOSSUS_AT_CLIFF = False Colossus 靠近地图的红色边界,不靠近悬崖。 - IS_COLOSSUS_WEAPON_COOLDOWN = True 武器处于冷却中,无法立即攻击敌军。 - IS_COLOSSUS_HEALTH_LOW = False Colossus 健康状态良好(100%),无低健康威胁。 - MOVE_DISTANCE = 50 - TIME = 10 4.2 多思维链选择 - 当前条件触发 **应急思维链(Emergency CoT)**。 4.3 思维链触发规则 - 触发应急思维链,因为 `IS_ZERG_NEAR_COLOSSUS = True`。 5. 思维链内容 5.3 **应急思维链(Emergency CoT)** - Step 1: 立即评估周围威胁,确定最安全的撤退方向。 - Step 2: 优先移动到低地或安全区域,避免被包围。 - Step 3: 在安全位置等待武器冷却结束,准备反击。 - Step 4: 分配动作优先级。 - <Move_Screen([160, 200])> # 优先级1 - <Attack_Unit(0x1004c0001)> # 优先级3 - <Attack_Unit(0x100740001)> # 优先级3 - Step 5: 生成优先级排序的动作列表,并根据移动距离插入 <No_Operation()>。 - 生成动作列表: 1. <Move_Screen([160, 200])> # 优先级1 2. <No_Operation()> # 空动作 3. <No_Operation()> # 空动作 4. <No_Operation()> # 空动作 5. <No_Operation()> # 空动作 6. <Attack_Unit(0x1004c0001)> # 优先级3 7. <Attack_Unit(0x100740001)> # 优先级3 6. 综合战略与决策框架 6.1 战略建议 - **当前战略**:根据应急思维链,执行紧急撤退到低地,避免被包围。 - **动态调整**:根据实时战场信息,随时切换思维链,确保策略的适应性和灵活性。 6.2 动作生成与执行 - **动作优先级排序**:根据当前思维链的决策,排序生成的动作。 - **动作多样性**:避免重复单一动作,确保策略多样化。 - **动作可执行性检查**:确保生成的动作符合游戏机制,避免冲突和无效指令。 - **插入空动作**:由于 MOVE_DISTANCE = 50 > 10,插入4个 <No_Operation()>。 7. 思维链协调与反馈 7.1 状态保持与重置 - 在切换思维链时,保持必要的状态信息,重置不相关的状态。 7.2 反馈机制 - 根据执行结果,调整后续决策路径,优化策略效果。 8. 动作输出 Team Colossus-1: <Move_Screen([160, 200])> # 撤退到低地,避免被包围,利用悬崖延迟追击。 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <No_Operation()> # 空动作 <Attack_Unit(0x1004c0001)> # 武器冷却结束后,优先攻击最近的 Zergling。 <Attack_Unit(0x100740001)> # 继续攻击其他附近的 Zergling,利用溅射伤害削弱敌军。

七、实现细节与注意事项

1. 多思维链的协调与切换

  • 统一决策层

    • 确保顶层决策逻辑能够准确选择触发条件对应的思维链。
    • 例如,当 IS_ZERG_NEAR_COLOSSUS = True 时,优先触发应急思维链。
  • 状态保持与重置

    • 在切换思维链时,保持关键状态(如健康状态、武器冷却状态)。
    • 重置不相关的状态,避免旧思维链的残留影响新思维链。

2. 动作优先级排序与插入空动作的逻辑

  • 优先级赋值

    • 在每个思维链内部,为动作赋予优先级值(数值越小,优先级越高)。
    • 示例:
      • 高优先级:1
      • 中优先级:2
      • 低优先级:3
  • 排序机制

    • 使用编程逻辑对动作列表按优先级进行排序。
    • 确保高优先级动作先执行。
  • 插入空动作

    • 根据移动距离计算需要插入的 <No_Operation()> 数量。
    • 插入位置通常在移动动作之后,以模拟移动过程中的时间消耗。

3. 动作生成与执行的可执行性检查

  • 确保动作合法

    • 移动目标坐标在地图边界内,且路径无阻碍。
    • 攻击目标存在且在攻击范围内。
  • 避免动作冲突

    • 确保连续动作不会互相冲突,如在移动过程中立即攻击敌军可能导致逻辑错误。

4. 反馈机制的实现

  • 战场反馈

    • 根据实际执行结果(如是否成功移动、攻击是否命中)调整后续决策。
    • 例如,如果撤退失败,应急思维链可能需要进一步调整动作策略。
  • 持续优化

    • 收集战斗数据,分析成功与失败的原因,持续优化动作优先级排序和空动作插入规则。

八、论文改进思路

基于上述优化思路,以下是改进后的论文撰写思路,重点在于方法与提示词内容的优化,特别是多思维链的实现以及动作优先级排序与插入空动作的整合。

1. 引言

  • 背景介绍:介绍 Visual-CoT 框架及其在《星际争霸 II》中的应用。
  • 研究动机:阐述在1巨像对抗32小狗场景下的挑战与现有方法的局限性。
  • 研究贡献:提出通过引入多思维链,优化动作优先级排序与插入空动作,提升模型在复杂战场中的决策与行动能力。

2. 相关工作

  • LLM 在策略游戏中的应用:回顾现有研究,尤其是在《星际争霸 II》中的应用案例。
  • 多思维链与 CoT 方法:探讨如何通过多思维链与 CoT 方法提升模型的决策能力。
  • 动作优先级排序与空动作插入技术:介绍现有的动作优先级排序与空动作插入技术及其在其他领域的应用。

3. 方法

3.1 Visual-CoT 框架优化

  • 多思维链设计:详细描述如何定义和整合多个思维链(战术、战略、应急),以及它们的应用场景。
  • 结构化提示词设计:介绍如何通过结构化和模块化设计,优化提示词的组织与内容。
  • 动作优先级排序与空动作插入:阐述如何为动作分配优先级,并根据移动距离插入 <No_Operation()>。

3.2 思维链内容优化

  • 战术思维链(Tactical CoT):详细描述其推理路径和决策步骤。
  • 战略思维链(Strategic CoT):详细描述其推理路径和决策步骤。
  • 应急思维链(Emergency CoT):详细描述其推理路径和决策步骤。

3.3 领域特定启发式规则整合

  • 单位特性利用:结合巨像的远程攻击和高生命值,优化战术决策。
  • 地形优势利用:优化利用高地、低地和悬崖等地形特征,提升战术效果。
  • 敌军行为模式识别:根据 Zerglings 的移动和攻击模式,动态调整策略。

3.4 案例驱动的思维链优化

  • 案例收集与分析:收集不同战场情境下的成功与失败案例。
  • 经验规则提炼:从案例中提炼有效的决策规则,整合到思维链中。
  • 持续优化机制:根据新案例不断调整和优化思维链的规则与逻辑。

4. 实验设计与结果

  • 实验环境:描述在 LLM-PySC2 环境下的实验设置,包括地图设计、单位配置等。
  • 对比实验:展示优化前后的对比实验结果,重点在胜率、击杀数、决策速度等指标上的提升。
  • 案例分析:通过具体的战斗案例,展示优化后的 Visual-CoT 框架如何有效应对1巨像对抗32小狗的情境。

5. 讨论

  • 优化效果分析:深入探讨引入多思维链和动作优先级排序后,决策质量与动作控制上的提升。
  • 模型理解与决策透明性:讨论多思维链方法如何提升模型的决策透明性与可解释性。
  • 应用扩展与未来工作:展望 Visual-CoT 框架在其他复杂环境与多智能体协作中的应用前景。

6. 结论

  • 总结贡献:概括优化后的 Visual-CoT 框架在1巨像对抗32小狗场景中的表现与优势。
  • 未来方向:提出进一步优化提示词设计、引入更先进的视觉技术、扩展至其他策略游戏与实际应用领域的计划。

九、结语

通过在多思维链(Multi-CoT)框架中引入动作优先级排序插入空动作(<No_Operation()>),可以显著提升模型在《星际争霸 II》1巨像对抗32小狗场景中的决策效率与战略执行能力。这种优化不仅增强了模型的战术深度和灵活性,还提高了动作执行的连贯性和合理性。

关键优化点包括:

  1. 多思维链设计:将战术、战略、应急等不同层次的决策逻辑分开处理,提升整体决策能力。
  2. 动作优先级排序:确保高优先级动作先执行,优化战术效果。
  3. 插入空动作:模拟移动过程中的时间消耗,确保动作执行的平滑性。
  4. 条件触发机制:灵活选择合适的思维链,根据实时战场信息调整策略。

这些优化将帮助模型在复杂战场环境中做出更高效、精准的决策,确保巨像在对抗大量 Zerglings时的生存与胜利。同时,这一方法论具有较强的通用性,可以扩展至其他需要多层次决策和策略优化的复杂任务中,如机器人控制、自动驾驶和虚拟助手等领域。

如果您有进一步的需求或具体问题,欢迎继续交流,我将为您提供更详细的支持和建议。

질문

下面给出一个以“思维链投票机制 + 事件提醒 + 提示词优化”为核心的改进方案示例,省去对“短期记忆”机制的大规模改动,重点在图像信息和Prompt层面完善。可供下一步研发和论文撰写时参考:


一、整体思路概览

  1. 思维链投票机制

    • 目标:在同一帧(或同一个决策时刻),让大模型通过多条并行推理路径生成多个可能方案,再通过投票或打分的形式选出最优行动。
    • 价值:减少单次推理的偶发性错误,提高决策稳健性。
  2. 事件提醒(Event Reminder)

    • 目标:为大模型提供特殊的高优先级信息触发点,比如“敌人已近身”、“血量告急”等,从而在思维链中优先处理。
    • 价值:让模型的决策及时关注关键事件,避免无关或冗余信息干扰。
  3. 提示词优化(Prompt Engineering)

    • 目标:强化对图像信息的解释和使用;引导模型在思维链中对图像中的关键信息(地形、敌军分布)进行多步分析和投票,输出更准确的决策动作。
    • 价值:通过更精细的提示、示例和格式约束,让大模型深度利用视觉特征,不必大规模改动其他系统模块。

二、具体技术路径

以下给出一个从数据流到最终决策输出的技术流程示例,结合以上三大改进点逐步展开。

1. 数据流与基础结构

  1. 环境交互

    • 依旧使用 LLM-PySC2 接口,从 StarCraft II 获取文本和图像观测(如单位位置、血量信息,以及处理过的RGB截图)。
    • 每隔一定时间步或每次需要动作决策时,收集最新观测并传入大模型做推理。
  2. 图像预处理

    • 与之前类似,标注地图上的不可通行区域、悬崖位置、单位坐标等,让大模型能在 Prompt 中“一眼”看出关键信息。
    • 可使用 base64 格式或其他方案嵌入图片到大模型(若使用多模态 GPT-4 之类)。

2. 思维链投票机制

  1. 多条推理路径

    • 当需要做决策时(如“是否撤退”或“是否攻击”),可向大模型发送同样的输入多次,或一次性提示大模型生成 N 个候选策略(譬如通过一个“请给出多个备选方案”的提示语)。
    • 每个候选方案都是一条思维链(Chain of Thought),从条件判断到最终行动输出都各自独立。
  2. 投票/打分

    • 在同一个 Prompt 中,请大模型在最后阶段对这些候选方案进行 Self-consistency 投票(或者由一个“评估子步骤”来计算成功概率)。
    • 也可让环境或一个小模块“模拟”或“对比评估”后再选出最高分方案执行。
    • 示例
      • 「方案1:后退到高地,等待冷却」
      • 「方案2:先攻击最近的Zergling,再走右下方」
      • 「方案3:直接移动到低地右下边界,绕远路」
      • 投票评估后,选方案2 或 1。
  3. 执行与记录

    • 最终只将票数最高或评分最优的方案提交给游戏执行。
    • 也可以保留其他方案的思维链,以便后续做错误分析或论文中举例对比。

3. 事件提醒(Event Reminder)

  1. 关键事件定义

    • 结合 1 巨像 vs 32 小狗的场景,可定义若干关键事件标签:
      • 「EncirclementRisk」:若计算到至少有 8~10 条小狗可在数秒内形成合围;
      • 「LowHealthColossus」:如果巨像生命或护盾低于某阈值;
      • 「WeaponCooldownEndingSoon」:距离冷却完成只有不到 1 秒;
      • 等等。
  2. 自动检测

    • LLM-PySC2 框架或外部脚本中,根据观测数据自动判定是否触发事件。比如:
      • 如果发现小狗分布于 Colossus 东南西北方向,计算“包围半径”是否足够小;
      • 如果 Colossus 的 HP + Shield <= 30% 等。
  3. 提示给大模型

    • 将事件信息拼接到 Prompt 高优先级部分,让大模型在思维链中首先处理。例如:
      text
      # Event Reminder: - EncirclementRisk = True - LowHealthColossus = False ...
    • 在提示词中强制模型对这些事件做出响应,如“如果 EncirclementRisk = True,则优先考虑撤退动作”。

4. 提示词优化(Prompt Engineering)

在现有的 Visual-CoT 提示词基础上,可进一步加强以下几点:

  1. “多候选决策”示例

    • 在示例输出中,提供「同一时刻的多条方案」范例,并展示如何使用投票评估选择最优;
    • 让大模型“学会”按这种格式输出,并在最后只执行票数最高者。
  2. 事件信息优先级

    • 在系统提示或“Analysis”部分,要求先检查 Event Reminder,再进入 Condition Assessment;
    • 如:
      text
      1.0 Check Event Reminders - If any are true, incorporate into chain-of-thought analysis at top priority. 1.1 Condition Assessment ...
  3. 图像信息分段引导

    • 在提示词中引导模型先做视觉区域划分,如“HighGroundRegion = [..], LowGroundRegion = [..]”,“PossiblePathway = [..]”。
    • 再在思维链中显式对这些信息进行对比分析(“If Colossus in HighGroundRegion and Zerglings in LowGroundRegion -> safe to attack?”)。
  4. 动作序列化输出

    • 在最终输出时,可要求模型输出“投票结果 + 最终两三个动作”,或只输出“最佳方案动作”。
    • 并给出一段简短解释(“Reason: vote_count=3 for planB, planB <Attack> then <Move>”)。

三、论文撰写建议

  1. 方法介绍

    • 标题章节可聚焦于“利用思维链投票机制和关键事件提醒增强 LLM 在 RTS 微操决策中的鲁棒性”;
    • 在“相关工作”中提及现有 Visual-CoT,以及多模态大模型在游戏决策的局限。
  2. 实验设计

    • 对比「无投票机制 vs. 有投票机制」、「无事件提醒 vs. 有事件提醒」等;
    • 统计胜率、微操精度(是否轻易被围杀)、对时延敏感度等定量指标;
    • 列举具体案例,展示事件提醒如何拯救巨像于被围之际、或投票机制如何避免鲁莽进攻。
  3. 结果分析

    • 用表格或图表清晰列出:引入投票后胜率提升多少,引入事件提醒后操作失误减少多少;
    • 可以记录大模型在 CoT 中对事件的处理过程以及各候选方案的评分,展示思维链的可解释性。
  4. 局限与扩展

    • 声明仅在单独的 1 巨像 vs 32 小狗场景做验证,但思路可推广到其他场景;
    • 后续可结合 RL 或更多实时多模态信息,做进一步研究。

四、总结

  • 技术路径

    1. 思维链投票机制:多候选推理 → 投票/评分 → 选优决策;
    2. 事件提醒:将包围风险、血量告急、武器冷却等关键信号插入 Prompt,优先考虑;
    3. 提示词优化:把图像信息拆分更细,示例中展示多候选方案和事件处理,输出动作时做简要自解释。
  • 总体收益

    • 降低因单条思维链随机失误导致的重大决策错误;
    • 让模型在关键紧急事件时优先处理威胁,不被琐碎信息干扰;
    • 提高对视觉信息的使用深度,减少重写大模型架构的开发成本。
      就这个技术思路给出我一个框架图。

사고

Crafting a diagram

I'm piecing together methods to visualize data flow, voting processes, event alerts, and prompt engineering in a framework diagram, considering text or ASCII formats for clarity.

Thought about multi-path reasoning and event-based decision-making,持续 几秒

답변

下面给出一个示例“框架图”,以文本/ASCII 形式描述思维链投票机制、事件提醒、以及提示词优化三者的交互流程。实际论文中可将其绘制成更美观的流程示意图。以下示例仅作参考,核心思路与模块关系可以根据实际需求灵活调整。


plaintext
┌───────────────────────────────────────────────────────────┐ │ StarCraft II 环境(PySC2) │ │ (提供单位坐标、血量、地图截图等信息) │ └───────────────────────────────────────────────────────────┘ │ │ ▲ │ (1)数据获取 │ │ ▼ │ │ ┌───────────────────────────────────────────────────────────┐ │ 图像 & 事件检测模块 │ │ 1) 预处理图像:标注高低地形、不可通行区域、敌我单位等 │ │ 2) 事件提醒:检测包围风险、血量告急、冷却结束等 │ │ 3) 输出结构化信息 & Event Reminders │ └───────────────────────────────────────────────────────────┘ │ │ │ (2)注入事件提醒 + 结构化视觉信息 ┌───────────────────────────────────────────────────────────┐ │ Prompt Engineering 模块 │ │ 1) 整合事件提醒(Event Reminders)至高优先级位置 │ │ 2) 加入图像分块描述、高地/低地标注、敌军坐标等 │ │ 3) 构造“多候选决策”示例,引导大模型输出多条备选方案 │ │ 4) 格式化思维链,让大模型并行生成 N 条思维链 │ │ 5) 引导“投票/打分”步骤,产出最优方案 │ └───────────────────────────────────────────────────────────┘ │ (3)提示词(包含视觉/事件信息、多思维链投票指令) ┌───────────────────────────────────────────────────────────┐ │ 大模型(多模态 LLM / Visual-CoT) │ │ 1) 多思维链并行推理:同一时刻生成 N 条决策方案 │ │ 2) 针对事件提醒信息做优先级决策:如包围风险 &rarr; 先撤退 │ │ 3) CoT 投票或打分:比较不同思维链的优劣,选出最优 │ │ 4) 产生最终动作序列:可含 <Move>, <Attack>, <No_Operation>, │ 并在必要时插入空动作,或提供简要自解释 │ └───────────────────────────────────────────────────────────┘ │ (4)输出动作序列(或最优方案) ┌───────────────────────────────────────────────────────────┐ │ 执行动作并回写至 StarCraft II 环境 │ │ (如 <Move_Screen([160, 200])>, <Attack_Unit(...)>) │ │ 下一时刻继续观察 &rarr; 触发新一轮决策循环 │ └───────────────────────────────────────────────────────────┘

说明

  1. StarCraft II 环境(PySC2)

    • 负责提供实时数据,包括图像帧、单位坐标、血量等。
    • 这些数据会被“图像 & 事件检测模块”接收、处理。
  2. 图像 & 事件检测模块

    • 对图像进行标注和解析,比如:
      • 标记高地、低地、悬崖位置;
      • 检测敌我单位坐标等;
    • 判断是否发生关键事件(EncirclementRisk, LowHealthColossus, 等)。
    • 输出结构化信息与“事件提醒”标签。
  3. Prompt Engineering 模块

    • 将视觉处理与事件提醒信息融入到提示词中。
    • 提供多候选方案示例,引导大模型在思维链中生成并行推理路径。
    • 指定如何在思维链里执行投票/打分。
    • 对最终输出格式也做约束(如必须给出动作序列)。
  4. 大模型(多模态 LLM / Visual-CoT)

    • 通过多条并行思维链(Chain of Thought)生成多个候选决策。
    • 根据提示词中的“投票”或“打分”指令,选出最优方案。
    • 输出最终的动作序列(可含移动、攻击、插入空动作等),并可附带理由或分数。
  5. 执行 & 回写

    • 将最优决策指令返回给 PySC2 环境进行执行。
    • 等待下一时刻新的观测信息后,再重复该流程。

这张框架图可以帮助读者或开发者快速理解**“思维链投票机制 + 事件提醒 + 提示词优化”**如何在现有的 LLM-PySC2 环境中协同工作,既强化了对关键事件的优先处理,也让大模型通过多候选思维链、投票打分机制来增强决策的稳健性和准确度。

질문

方案是:先在系统提示中加入详细规则与机制(多候选投票、事件提醒、图像/地形多步分析),再将无法改动的「环境输入」原样拼接,最后由一个“用户请求”触发大模型一次性输出完整答案。通过这种“三段式”,可以最大化利用 Prompt 工程的灵活性,而不破坏已有的环境逻辑。
请你给出完整的修改后的提示词,要求中英文两个版本

사고

Finalizing the structure

OK, let me see. I’m finalizing a tri-part structure for the prompt, combining system prompts in both Chinese and English, maintaining environment data unchanged, and incorporating user requests in both languages.

思考,持续 几秒

답변

以下示例展示了一个“三段式”提示词结构的完整中英文示例。该结构分为 (1) 系统提示 (System Prompt)(2) 环境输入 (Environment Data)、以及 (3) 用户请求 (User Request) 三部分。目的在于:

  1. 系统提示 负责注入“多候选投票、事件提醒、图像/地形多步分析”等核心机制,以及相关规则与格式要求。
  2. 环境输入 保持“不可修改的”游戏/环境观测原始信息,直接拼接供大模型分析。
  3. 用户请求 最后触发大模型一次性输出完整答案(动作序列或策略方案)。

提示词结构示例(中英文混合)

(1) 系统提示 (System Prompt)

plaintext
[System Prompt Start] # 中文部分 你是一款多模态大型语言模型,当前需要在星际争霸 II (StarCraft II) 环境下扮演指挥官。 你的目标:根据图像、地形、敌方单位等信息,决策巨像 (Colossus) 的具体行动,以应对若干虫族小狗 (Zerglings) 的进攻。 在此提示词中,我们会使用三段式结构: 1) 系统提示(规则与机制) 2) 环境输入(不可修改的观测信息) 3) 用户请求(触发你一次性输出完整答案) 请确保你严格遵守以下规则与机制: 1. **多候选投票机制 (Multiple-Candidate Voting Mechanism)** - 当需要做关键决策时,你应同时生成多条“思维链 (Chain of Thought)”或多个候选方案,并在内部进行投票或打分。 - 最终只输出“票数最高或打分最优”的方案,以确保决策的稳健性。 - 在输出中,可以简单展示各方案的投票结果或评分;也可以只保留最优方案的动作序列。 2. **事件提醒 (Event Reminder)** - 你将收到一些关键事件标签,如“包围风险 (EncirclementRisk) = True”、“巨像血量告急 (LowHealthColossus) = True”等。 - 如果事件提示为真,应在思维链或决策过程中优先考虑它们。例如: - 若“包围风险”为真,则优先撤退; - 若“血量告急”为真,则尽量避免正面战斗。 3. **图像/地形多步分析 (Multi-step Visual/Terrain Analysis)** - 你会获得处理后的地图或地形信息,包含高地、低地、悬崖位置、敌我单位坐标等。 - 在思维链中,需要根据这些信息进行多步推理: - 判断当前巨像所处位置、高地优势; - 检查小狗的分布; - 分析可行的移动路线或撤退方向。 4. **输出格式 (Output Format)** - 最终答案中须给出动作序列,例如 `<Move_Screen([X, Y])>`, `<Attack_Unit(unit_tag)>`, 或 `<No_Operation()>`。 - 如果需要一次性移动很远距离,可在移动后插入若干 `<No_Operation()>` 以模拟等待或停顿。 - 可以附上一段对最终决策的简要解释(可选)。 - 如果使用多候选方案,请列出各方案及投票/评分过程,并选出最优方案执行。 --- # English Section You are a multimodal Large Language Model serving as a commander in a StarCraft II environment. Your mission is to decide the Colossus’s actions (e.g., moving, attacking, waiting) against multiple Zerglings. We will provide the prompt in three parts: 1) System Prompt (rules and mechanisms) 2) Environment Input (unchangeable observation data) 3) User Request (to trigger your final answer) You must strictly follow the rules and mechanisms below: 1. **Multiple-Candidate Voting Mechanism** - When making critical decisions, generate multiple parallel Chains of Thought or candidate plans. - Conduct an internal vote or scoring process among these candidates. - Finally, output only the plan with the highest vote or best score for robust decision-making. - Optionally, you may briefly show the vote results, or just the best plan’s action list. 2. **Event Reminder** - You may receive some high-priority event flags, such as “EncirclementRisk = True” or “LowHealthColossus = True.” - If these event flags are true, you must prioritize them in your reasoning. For example: - If “EncirclementRisk = True,” prioritize retreat. - If “LowHealthColossus = True,” avoid direct engagement. 3. **Multi-step Visual/Terrain Analysis** - You will be given processed map or terrain data (e.g., high-ground, low-ground, cliff info, unit coordinates). - You must reason step by step about these details: - The Colossus’s current location and whether it’s on high ground; - The Zerglings’ distribution; - Possible movement or retreat routes, etc. 4. **Output Format** - You must provide the final action list, such as `<Move_Screen([X, Y])>`, `<Attack_Unit(unit_tag)>`, or `<No_Operation()>`. - If a movement is very far, insert `<No_Operation()>` actions to simulate a wait or pause in between. - You may include a brief summary of your final decision (optional). - If you produce multiple candidate plans, list each plan’s voting/scoring result, then choose the best plan to execute. [System Prompt End]

(2) 环境输入 (Environment Data)

说明:此部分包含游戏环境中不可更改的观测信息,直接原样拼接给模型。
下列示例仅供参考,可根据实际需求替换为真实的观察数据(单位位置、地图网格、事件提醒等)。

plaintext
[Environment Data Start] # 以下为原始或处理后的观测信息示例 (中英文混排示范): GameTime = 45.2 (秒) EventReminders: - EncirclementRisk = True - LowHealthColossus = False - WeaponCooldownEndingSoon = False Units and Terrain (简化示例): - Colossus at [150, 120] (HighGround) - Zerglings: positions = [[145, 115], [148, 117], [152, 119], ...] - Cliff line between (160, 100) and (160, 200) - Narrow path on the left side [80, 120] to [100, 130] Map size: 256 x 256 # ...可在此添加更多环境数据,如血量、护盾、冷却时间等 [Environment Data End]

(3) 用户请求 (User Request)

说明:这是用户真正发送给大模型的需求,触发一次性输出最终答案。
请注意,中英文合并写在一起,只是示例——在实际工程中,可根据需要拆分成独立语言版本。

plaintext
[User Request Start] # 中文部分: 请根据以上系统提示(规则与机制)和环境输入(不可修改的信息),一次性给出你对巨像的行动决策: 1. 先并行考虑多种可能方案,并在思维链中进行投票或打分; 2. 事件提醒“EncirclementRisk = True”需要优先处理; 3. 最终输出最优方案的动作序列,必要时插入 <No_Operation()>,并可附上简要解释。 # English part: Based on the System Prompt (rules/mechanisms) and the Environment Data (unchangeable info) above, please produce your final action decisions for the Colossus: 1. Consider multiple candidate plans in parallel and perform an internal voting/scoring process; 2. Prioritize the event reminder “EncirclementRisk = True;” 3. Output the final action list with <No_Operation()> where appropriate, and optionally provide a brief explanation. [User Request End]

使用方法说明

  1. 组合顺序

    • 在实际调用时,先将 (1) 系统提示 (System Prompt) 拼接在最前面,
    • 再拼接 (2) 环境输入 (Environment Data)
    • 最后拼接 (3) 用户请求 (User Request)
    • 一并发送给大模型一次性处理。
  2. 输出示例

    • 大模型在收到三段信息后,会先解析系统提示中的核心规则(多候选投票、事件提醒优先级、图像/地形多步分析等),
    • 然后读取环境输入(如具体的 EncirclementRisk = True, Colossus 坐标等),
    • 最终根据用户请求给出完整的动作序列输出,例如:
      plaintext
      Candidate Plans (Voting): Plan A: Move to [160, 200], then Attack. (Score: 7.8/10) Plan B: Attack first, then Move. (Score: 5.2/10) Voting Result: Plan A wins. Final Action Sequence: <Move_Screen([160, 200])> <No_Operation()> <Attack_Unit(0x1004c0001)> <Attack_Unit(0x1004c0002)> # Explanation: Because EncirclementRisk is True, we retreat first...
    • 或者只直接输出最优方案的动作列表。
  3. 灵活扩展

    • 可在系统提示部分增补更多自定义规则(如地形优先级、资源采集策略、援军调度等),
    • 也可在环境输入部分添加更详细或高维度的观测数据,
    • 用户请求部分可根据交互需求适度修改,但要注意保持对整体提示结构的尊重。

总结

通过上述**中英文三段式(System Prompt + Environment Data + User Request)**示例,可以在不改动现有“环境输入”机制的前提下,最大化利用 Prompt 工程的灵活性

  • 系统提示——注入多候选投票、事件提醒、图像地形多步分析等核心规则;
  • 环境输入——保持原有观测数据不变,方便整体系统对接;
  • 用户请求——一次性触发大模型输出完整的动作序列或策略方案。

这样不仅可保障已有环境逻辑不被破坏,也能通过 Prompt 优化来加强大模型在 RTS 场景中的决策能力。祝研究和工程实践顺利!

질문

要求在此基础上进行大幅度修改,D:\Anaconda\envs\starcraftii0828\python.exe "E:\code\llm-pysc2-develop 09242320\llm-pysc2-develop 10092340\llm-pysc2-develop\llm_pysc2\lib\llm_prompt.py"
pygame 2.6.0 (SDL 2.28.4, Python 3.9.19)
Hello from the pygame community. https://www.pygame.org/contribute.html
--------------------------------------------------System Prompt--------------------------------------------------

text
1. Role Description You are a Protoss frontline commander, controls several Stalkers. Responsible for providing cover for the main force and restraining enemy forces.. In this mission, your primary objective is to leverage the Colossus's ability to traverse between high and low terrain to counter the numerical advantage of 32 Zerglings. Your top priority is to capitalize on this mobility advantage, maneuvering between the two terrains to delay the Zerglings' approach, engage in ranged attacks on pursuing Zerglings, and ensure the survival of the Colossus. 2.Map Information 2.1 Coordinate System: - The screen coordinate system is a 2D grid with a range of [0, 256] &times; [0, 256]. - Each grid cell measures 32 &times; 32 pixels, resulting in a total of 8 &times; 8 = 64 grid cells. - The origin point (0, 0) is at the top-left corner, while (256, 256) is at the bottom-right corner. 2.2 Terrain Information: - Pathway (connecting the high ground and low ground): The map consists of an upper platform (high ground) and a lower platform (low ground), connected by a narrow pathway on the left side. - High Ground (light green area): The high ground is characterized by light green grass textures and is located on the upper platform. - Low Ground (dark gray area): The low ground is characterized by dark gray concrete textures and is located on the lower platform. - Impassable Area (black background): The edges of the map consist of a black background, which is impassable. The Colossus must avoid entering these areas. - Cliff (light gray vertical surface): The cliff separates the high ground and low ground. The Colossus can freely traverse the cliff, but Zerglings can only access the high ground through the narrow pathway on the left. Only the boundary between the high ground and low ground is considered a cliff; other deep red boundaries are impassable edges of the map. - Boundary: The boundaries between the high ground and the black background, as well as between the low ground and the black background, are considered impassable edges of the map. The boundaries are represented by deep red lines on the map. 3. Key Victory Points: 3.1 Maintain Maximum Attack Range: - Ideally, the Colossus should stay within its maximum attack range (range 7) to fully utilize its long-range attack advantage while minimizing the risk of melee attacks from enemies. 3.2 Focus Fire on Dense Enemy Clusters: - Target the center of the densest enemy groups to maximize splash damage and quickly reduce enemy numbers. 3.3 Cliff Barrier Delay Effect: The Cliff Barrier Delay Effect refers to leveraging the terrain characteristics of cliffs, where enemy units cannot directly cross the cliff, while allied units can freely traverse it. This forces the enemy to take a detour when transitioning between high and low ground, buying time for allied units to reposition, cool down weapons, and strike effectively. - When enemies are heavily concentrated on the high ground: - If allied units are also on the high ground but risk being surrounded, it is recommended to retreat to the bottom-right low ground. This utilizes the cliff as a barrier to delay enemy pursuit, enabling ranged attacks on the enemies while maintaining battlefield control. - When enemies are heavily concentrated on the low ground: - If allied units are also on the low ground but risk being surrounded, it is recommended to retreat to the top-right high ground. The cliff barrier forces enemies to take a detour, providing time for allied units to reposition and counterattack effectively.

4. Decision Process
Based on the observed data of the Colossus and Zerglings, as well as the RGB image of the screen, use the following decision rules to determine action priorities:

text
4.1 Condition Assessment Rules: - IS_HIGH_GROUND: - Criteria: If the Colossus is on the green high ground (above the cliff, with a clear boundary from the low ground), set to True; otherwise, set to False. - Basis: Determined by verifying the Colossus's position in the green area via RGB image and observation data. - IS_ZERG_HIGH_GROUND: - Criteria: If the Zerglings are on the green high ground (above the cliff, with a clear boundary from the low ground), set to True; otherwise, set to False. - Basis: Determined by analyzing the Zerglings' positions via RGB image. - IS_ZERG_NEAR: - Criteria: If at least 5 Zerglings are within the attack range (&le;7) or attempting to surround the Colossus, set to True; otherwise, set to False. - Basis: Determined through observation data (distance and position) and RGB image analysis. - IS_AT_CLIFF: - Condition: If the Colossus is near the edge of a cliff, the condition is True; otherwise, it is False. It is important to distinguish between a cliff and a boundary. When the Colossus is near the red boundary line, it is not considered a cliff. A cliff is the transitional area between the highland and the lowland. - Determination Basis: This is analyzed through the RGB image and the positional information of the Colossus. - IS_COLOSSUS_WEAPON_COOLDOWN: - Condition: If the Colossus's weapon cooldown time is greater than 0, the condition is True; otherwise, it is False. - Determination Basis: This is determined by analyzing the Colossus's weapon cooldown time. - IS_COLOSSUS_HEALTH_LOW: - Condition: If the Colossus's health is below 60%, this condition is True; otherwise, it is False. - Determination Basis: Determined by observing the Colossus's health. 4.2 Action Decision Rules - Special Scenarios: rule1 :As long as the weapon is in cooldown, the priority of movement actions is higher than attack actions. Movement > Attack. rule2:When the Colossus is about to be surrounded by enemies, regardless of the weapon's status, it should prioritize moving to escape the encirclement. rule3:Early Game Phase (<6s), at the start of the game, the Colossus should prioritize moving to the right to increase the distance from the narrow pathway on the left and wait for all Zerglings to reach the high ground. During this phase, movement takes priority over attacking. - Situation 1: The Colossus and Zerglings are in different areas - Weapon not on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = False): - Priority: Attack. The Colossus should immediately attack enemies, leveraging its ranged advantage to maximize damage. - Weapon on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = True): - Priority: Move. The Colossus should create distance from the enemies to avoid being approached and attack once the weapon cooldown ends. - Situation 2: The Colossus and Zerglings are in the same area - Enemies are near and about to attack (IS_ZERG_NEAR = True, Zerglings approaching): - Priority: Move. Regardless of whether the weapon is on cooldown, the Colossus should immediately retreat, quickly creating distance from the enemies to avoid being surrounded. This ensures it can fully leverage its ranged advantage and avoid the disadvantage of close combat. Once out of danger, it can then look for opportunities to counterattack. - Enemies are not near (IS_ZERG_NEAR = False): - Weapon not on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = False): - Priority: Attack. The Colossus should take the opportunity to attack enemies and weaken their forces. - Weapon on cooldown (IS_COLOSSUS_WEAPON_COOLDOWN = True): - Priority: Move. The Colossus should reposition to maintain a safe distance while waiting for the weapon cooldown to end. - Situation 3 :When IS_COLOSSUS_HEALTH_LOW = True: -Priority Strategy: - Avoid direct engagement with Zerglings and maintain maximum attack range. - Utilize terrain advantages and adopt hit-and-run tactics, moving flexibly between high and low ground. - Priority: Movement > Attack

5 Integrated Strategy and Decision Framework
1. Strategy Suggestions

text
1.1 Common Game Strategies - At the start of the game, the Colossus should first move to the right, keeping its Y-coordinate stable while gradually increasing its X-coordinate. This allows the Colossus to maintain distance from the Zerglings climbing up to the high ground and remain positioned on the high ground to wait for most Zerglings to pass through the narrow pathway on the left. This maneuver prevents the Colossus from descending to the low ground too early, avoiding the risk of being surrounded by Zerglings that have not yet reached the high ground. - Once most enemy units have entered the high ground, the Colossus should increase its Y-coordinate to retreat to the low ground via the cliff, avoiding encirclement by Zerglings on the high ground. 1.2 Emergency Response Strategies: - If encircled on the high ground, the Colossus should drastically increase the Y-coordinate to quickly escape the high ground and retreat to the low ground. - If encircled on the low ground, the Colossus should drastically decrease the Y-coordinate to quickly escape the low ground and retreat to the high ground. 2. Movement and Attack Decision 2.1 When Movement Is Required: - Phase Judgment: - Determine the current phase based on game time and the positions of both allied and enemy units. - Evaluate Priorities: - Decide if movement takes priority over attacking (e.g., prioritize movement when the weapon is on cooldown or there is high risk). - Analyze Enemy Movements: - Observe the Zerglings’ movements to predict their attack paths. - Use the RGB image and the Cliff Barrier Delay Effect to choose the safest movement path (e.g., move down-right or up-right). - Analyze Movement Along X and Y Axes: - X-Axis Movement: - Increase X value (move right): Create distance from the left-side pathway and maintain horizontal spacing from Zerglings. - Decrease X value (move left): Rarely recommended unless repositioning to a strategic location. - Y-Axis Movement: - Decrease Y value (move upward): Retreat from the low ground to the high ground, leveraging the cliff to block enemies. - Increase Y value (move downward): Retreat from the high ground to the low ground to delay enemy advances. 2.2 When Attacking Is Required: - Target Selection: - Prioritize the densest groups of enemies to maximize splash damage. - Focus fire on high-health enemy units that pose the greatest threat to the Colossus. - Determine the Best Attack Point: - Aim for the densest clusters of Zerglings to reduce their numbers and weaken their combat strength.

6.Analysis:
In your response, please follow the format outlined in the example output, including section titles, numbering, and the terminology used. Ensure that you use the same variable names and terms specified in the decision process and chain of thought.

text
The output should include: 1. Decision Process 1.1 Condition Assessment: - `IS_COLOSSUS_HIGH_GROUND = True/False` - `IS_ZERGLING_HIGH_GROUND = True/False` - `IS_ZERGLING_NEAR_COLOSSUS = True/False` - `IS_COLOSSUS_AT_CLIFF = True/False` - `IS_COLOSSUS_WEAPON_COOLDOWN = True/False` - `IS_COLOSSUS_HEALTH_LOW = True/False' 1.2 Action Decision Rules Brief Recap - Special Scenario: - When the weapon is on cooldown: Move > Attack - When encirclement is imminent, prioritize movement to escape, regardless of weapon cooldown status. - Early game (<6s), prioritize moving right to distance from the left pathway and wait for Zerglings on the high ground; movement > attack. - Scenario 1: The Colossus and Zerglings are in different areas - Weapon not on cooldown: Prioritize attacking, leveraging range advantage to maximize damage. - Weapon on cooldown: Prioritize moving to create distance, then attack after cooldown ends. - Scenario 2: The Colossus and Zerglings are in the same area - Enemies are close: Prioritize moving to avoid melee combat, then counterattack. - Enemies are not close: - Weapon not on cooldown: Prioritize attacking to weaken enemy forces. - Weapon on cooldown: Prioritize moving to maintain a safe distance. - Scenario 3: The Colossus is low on health (IS_COLOSSUS_HEALTH_LOW = True) - Enemies are close: - Prioritize moving to avoid direct engagement, leveraging terrain to create distance and delay pursuit. - Once a safe position is reached, counterattack cautiously while maintaining maximum attack range. - Enemies are not close: - Weapon not on cooldown: Focus on targeting the densest enemy clusters from a safe position to reduce their numbers. - Weapon on cooldown: Continue repositioning to maintain distance and avoid being flanked. 1.3 Judgment Based on 4.2 Action Decision Rules: -Provide movement and attack priorities, e.g., attack > move or move > attack. -Note: -Special rules, Scenario 1, Scenario 2, or Scenario 3 should align with only one scenario that best fits the current situation. -Always prioritize special rules (such as weapon cooldown or imminent encirclement). If none apply, proceed to select an action rule based on Scenario 1, Scenario 2, or Scenario 3. 2 Integrated Strategy and Decision Framework 2.1 Strategy Suggestions - Current Phase Determination: Dynamically determine the strategy based on time, the Colossus’s position, and Zergling distribution. Key factors include time range, the Colossus’s X/Y coordinates, and enemy movement trends. - Consider Common Action Recommendations:: - Early Game Observation Phase: Initially, keep the X-coordinate steady while gradually increasing the Y-coordinate to monitor enemy movements. Utilize the Colossus’s range advantage to weaken enemy forces. - Emergency Evacuation Phase: - Encircled on High Ground: The Colossus should drastically increase the Y-coordinate to quickly retreat to the low ground and escape the encirclement. - Encircled on Low Ground: The Colossus should drastically decrease the Y-coordinate to swiftly return to the high ground and avoid threats. - Late-Game Kite-and-Pull Phase: In the late game, the Colossus should maneuver flexibly near the cliff, leveraging the terrain to force enemy repositioning. Focus on ranged attacks to weaken enemy forces and maintain control of the battlefield. 2.2 Movement Decision Analysis - Enemy Approach Path Prediction: Analyze the primary approach paths of enemy units and identify potential threats. - Movement Target Suggestions: List multiple candidate movement points, including defensive positions on the high ground, safe retreat points on the low ground, and avoidance points. Specify the most suitable movement target (e.g., a safe spot on the high ground or near the cliff on the low ground). Explain the reasoning behind the selection (e.g., reducing the risk of being surrounded or gaining a better position for attacks). 2.3 Attack Decision Analysis - Target Prioritization: Prioritize attacking dense enemy clusters to maximize splash damage. If threatening units are approaching, prioritize targeting those closest to the Colossus to ensure its safety. - Attack Target Selection: Identify multiple candidate attack points (e.g., the center of a dense enemy group or the closest group to the Colossus). Specify the optimal attack point and provide reasoning (e.g., to maximize damage or avoid being overwhelmed). 7.Action Output: Team Colossus-1: Action steps.

--------------------------------------------------Example Input Prompt--------------------------------------------------

text
Game Info Time: 0:05 Team Colossus-1 Info: Team minimap position: [31, 27] Controlled Team Units: Unit: Colossus, Tag: 0x100000001, ScreenPos: [150, 123], Health: 350 (100%), Weapon Cooldown Time: 0.91s Nearby Enemy Units: Unit: Zergling, Tag: 0x1002c0001, ScreenPos: [52, 164], Distance: 10, Health: 6 (17%) Unit: Zergling, Tag: 0x100180001, ScreenPos: [79, 159], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100440001, ScreenPos: [112, 140], Distance: 4, Health: 35 (100%) Unit: Zergling, Tag: 0x100640001, ScreenPos: [38, 176], Distance: 12, Health: 21 (60%) Unit: Zergling, Tag: 0x100700001, ScreenPos: [52, 178], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x100780001, ScreenPos: [42, 169], Distance: 11, Health: 6 (17%) Unit: Zergling, Tag: 0x100540001, ScreenPos: [49, 171], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x100500001, ScreenPos: [91, 146], Distance: 6, Health: 35 (100%) Unit: Zergling, Tag: 0x100800001, ScreenPos: [83, 147], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100280001, ScreenPos: [96, 151], Distance: 6, Health: 21 (60%) Unit: Zergling, Tag: 0x1000c0001, ScreenPos: [59, 162], Distance: 9, Health: 35 (100%) Unit: Zergling, Tag: 0x100040001, ScreenPos: [93, 157], Distance: 6, Health: 35 (100%) Unit: Zergling, Tag: 0x100340001, ScreenPos: [67, 172], Distance: 9, Health: 35 (100%) Unit: Zergling, Tag: 0x1001c0001, ScreenPos: [72, 161], Distance: 8, Health: 6 (17%) Unit: Zergling, Tag: 0x100600001, ScreenPos: [76, 152], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x100140001, ScreenPos: [86, 162], Distance: 7, Health: 35 (100%) Unit: Zergling, Tag: 0x1004c0001, ScreenPos: [117, 145], Distance: 3, Health: 35 (100%) Unit: Zergling, Tag: 0x100400001, ScreenPos: [66, 164], Distance: 9, Health: 21 (60%) Unit: Zergling, Tag: 0x100200001, ScreenPos: [78, 166], Distance: 8, Health: 35 (100%) Unit: Zergling, Tag: 0x100240001, ScreenPos: [104, 144], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100100001, ScreenPos: [59, 172], Distance: 10, Health: 35 (100%) Unit: Zergling, Tag: 0x1003c0001, ScreenPos: [86, 154], Distance: 7, Health: 6 (17%) Unit: Zergling, Tag: 0x100480001, ScreenPos: [46, 159], Distance: 11, Health: 35 (100%) Unit: Zergling, Tag: 0x1006c0001, ScreenPos: [69, 155], Distance: 8, Health: 35 (100%) Unit: Zergling, Tag: 0x100580001, ScreenPos: [59, 154], Distance: 9, Health: 6 (17%) Unit: Zergling, Tag: 0x100740001, ScreenPos: [130, 134], Distance: 2, Health: 35 (100%) Unit: Zergling, Tag: 0x1005c0001, ScreenPos: [97, 142], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100380001, ScreenPos: [39, 183], Distance: 12, Health: 35 (100%) Unit: Zergling, Tag: 0x100080001, ScreenPos: [106, 151], Distance: 5, Health: 35 (100%) Unit: Zergling, Tag: 0x100300001, ScreenPos: [124, 137], Distance: 2, Health: 35 (100%) Relevant Knowledge: Protoss.Colossus The large quad-legged vehicle fires lasers in a splash pattern well-suited to destroying swarms of weaker units. This unit can also traverse differences in terrain height due to its long legs, and will appear to step over ledges and other obstacles due to the inverse kinematics system. Unit properties: ['ground', 'air', 'armored', 'massive', 'mechanical'] Weapon info: Attack Range 7, target: ['ground'], anti: ['light'], DPS(damage per second) 13, DPS-anti 20 Unit abilities: Zerg.Zergling Fast but weak melee attacker ideal for swarming attacks in large numbers. Unit properties: ['ground', 'light', 'biological'] Weapon info: Attack Range 1, target: ['ground'], DPS(damage per second) 10 Valid Actions: Team Colossus-1 Valid Actions: <Attack_Unit(tag)> <Move_Screen(screen)> Action Args: (1) tag: tag refers to a hexadecimal number, shape as 0x000000000. (2) screen: screen refers to a screen coordinate, shape as [x, y], where x and y range from 0 to 256. (3) minimap: minimap refers to a minimap coordinate, shape as [x, y], where x and y range from 0 to 64. For example, when you want to use an action like <Action_Name(tag, screen)>, you should output like <Action_Name(0x100580001, [37, 55])>; when you want to use an action like <Action_Name(screen)>, you should output like <Action_Name([66, 78])>. Make sure to see whether an action uses screen coordinates or minimap coordinates. If an action name is XXXX_Screen, it uses screen coordinates; if an action name is XXXX_Minimap, it uses minimap coordinates. Last Step Actions: Team Colossus-1: <Move_Screen([160, 130])> <Attack_Unit(0x1007c0001)> <Attack_Unit(0x100740001)> You need to confirm whether the previous action finished executing, and based on this, determine whether to continue the old strategy or immediately take other actions. Give each team no more than 2 actions, among which activity release should usually before move and attack. Now, start generating your analysis and actions:

Give each team no more than 3 actions.
Now, start generating your analysis and actions:

--------------------------------------------------Example Output Prompt--------------------------------------------------

Analysis:

  1. Decision Process

    1.1 Condition Assessment

    text
    - IS_COLOSSUS_HIGH_GROUND = True The Colossus is currently on the high ground, confirmed via the image and coordinates. - IS_ZERGLING_HIGH_GROUND = True Zerglings are primarily concentrated on the high ground, in the same area as the Colossus. - IS_ZERGLING_NEAR_COLOSSUS = True Multiple Zerglings are close to the Colossus and within its attack range (&le;7), posing an immediate threat. - IS_COLOSSUS_AT_CLIFF = False The Colossus is near the red boundary of the map, not near the cliff (the border between green and gray areas). - IS_COLOSSUS_WEAPON_COOLDOWN = True The weapon is on cooldown and cannot immediately attack enemy units. - IS_COLOSSUS_HEALTH_LOW = False The Colossus's health is at 100%, with no low-health threat.

    1.2 Action Decision Rules

    Decision basis:
    1. Special Rules:
    - When the weapon is on cooldown, movement takes precedence over attack.
    - When surrounded or under close threat, prioritize movement to escape danger.

    text
    2. Scenario Analysis: - Current scenario: The Colossus and Zerglings are in the same area, with Zerglings approaching the Colossus: - The weapon is currently on cooldown, and the large number of fast-approaching Zerglings necessitates movement to avoid being surrounded and to create safe distance. - Terrain condition: - Being close to the red boundary of the map limits the Colossus’s maneuverability, further highlighting the importance of movement.

    1.3 Judgment Based on Action Decision Rules

    • Prioritize matching the special rule: Weapon cooldown (Move > Attack). The current scenario matches the special rule, prioritizing movement to retreat, avoid being surrounded, and gain time for the weapon cooldown.
    • Move > Attack
      The high ground space is insufficient, and with enemies advancing and the weapon on cooldown, the Colossus must immediately retreat to the low ground, using the cliff to delay Zergling pursuit and buy time for the cooldown.
  2. Integrated Strategy and Decision Framework

    2.1 Strategy Suggestions

    text
    Current Strategy: Emergency Retreat to Low Ground - The Colossus and Zerglings are both on the high ground. Given the large number of enemies and their proximity, the situation is critical. - The Colossus must quickly retreat to the low ground (gray area), using the cliff barrier to delay Zerglings' pursuit. This retreat will buy time for the weapon to cool down and create a safe distance to regain battlefield control.

    2.2 Movement Decision Analysis

    -Enemy Approach Path Prediction
    - Zerglings are advancing from the left pathway on the high ground, attempting to encircle the Colossus.
    - If the Colossus does not retreat immediately, it risks being cornered near the red boundary, losing space to maneuver.

    • Movement Target Suggestions

      • Retreat directly to screen coordinates [160, 200], a safe area near the cliff on the low ground.
      • Crossing the cliff to the low ground will delay Zerglings' pursuit, providing more survival space and reducing the risk of melee attacks.
    • Reason:

      • Directly retreating to the low ground avoids encirclement by Zerglings. The cliff barrier delays enemy pursuit, ensuring the Colossus's safety.

    2.3 Attack Decision Analysis

    text
    - Target Prioritization: - Once the weapon cooldown ends, prioritize attacking the nearest Zerglings to reduce immediate threats and maximize splash damage. - Attack Target Selection: - The closest Zerglings (e.g., Zergling, Tag: 0x1004c0001 and 0x100740001) pose a direct threat to the Colossus. - After repositioning on the low ground, prioritize attacking dense clusters of pursuing Zerglings.

3 .Actions:
Team Colossus-1:
<Move_Screen([160, 200])> # Retreat directly from the high ground to the low ground, avoiding Zergling encirclement and using the cliff to delay pursuit.
<Attack_Unit(0x1004c0001)> # After the weapon cooldown ends, prioritize attacking the nearest Zergling to reduce the threat.
<Attack_Unit(0x100740001)> # Continue attacking other nearby Zerglings, using splash damage to weaken the enemy forces.

进程已结束,退出代码0

사고

Refining the prompt

I’m mapping out a three-stage prompt for a model: embedding systemic rules, linking unchanged environmental inputs, and triggering a model response through a user request.

Formulating the structure

I’m identifying a "System Prompt" with multi-candidate voting and event reminders, "Environment Data" from the given chunk, and "User Request" to trigger the final model output.

思考,持续 8 秒

답변

下面给出一个「三段式」提示词的大幅修改版本,以满足“先在系统提示中加入详细规则与机制(多候选投票、事件提醒、图像/地形多步分析),再将无法改动的环境输入原样拼接,最后用用户请求触发大模型一次性输出完整答案”的需求。以下示例同时给出中英文两种描述方式,供论文写作或研发调试时参考。


1. 系统提示(System Prompt)

plaintext
[System Prompt Start] ───────────────────── 中文部分 (Chinese) ───────────────────── 你是一款多模态大型语言模型,当前在 StarCraft II (星际争霸 II) 场景下担任 Protoss 前线指挥官。 本次主要目标:利用可自由跨越高低地形的巨像(Colossus) 对抗 32 条 Zergling 的数量优势。你需要在提示词中综合多候选投票机制(Multiple-Candidate Voting Mechanism)、事件提醒(Event Reminder),并进行图像/地形的多步分析(Multi-step Visual/Terrain Analysis),最终输出最优的动作序列。 为确保不破坏已有的环境逻辑,我们采用“三段式”结构: 1. 系统提示(即本段内容):注入多候选思维链投票机制、事件提醒等; 2. 环境输入(后续会直接原样拼接,不能改动其文本); 3. 用户请求(最后一段,触发一次性输出完整答案)。 请严格遵守以下规则: ### (A) 多候选投票机制 (Multiple-Candidate Voting Mechanism) 1. 当需要做关键决策时,应并行生成多条“思维链 (Chain of Thought)”或多个候选方案。 2. 对这些方案进行投票或打分,选出最优方案。 3. 可以在最终输出中简要展示投票/打分过程,也可只输出最优动作序列。 ### (B) 事件提醒 (Event Reminder) 1. 你可能会收到一些关键事件提示,如「包围风险 (EncirclementRisk) = True」或「巨像血量告急 (LowHealthColossus) = True」。 2. 如果事件提醒为 True,则须在推理时优先处理: - 如果“包围风险”为真,先考虑撤退; - 如果“血量告急”为真,尽量避免正面交战。 ### (C) 图像/地形多步分析 (Multi-step Visual/Terrain Analysis) 1. 你将得到地图/地形相关的信息(如高地、低地、悬崖位置,以及单位坐标)。 2. 在思维链中,需要多步推断: - 当前巨像所处位置是否在高地或低地; - Zergling 分布是否接近; - 是否可利用悬崖穿越来延迟敌方追击等。 ### (D) 动作输出格式 (Action Output Format) 1. 最终回答中应明确给出动作列表,比如 `<Move_Screen([X, Y])>`, `<Attack_Unit(tag)>`, `<No_Operation()>` 等。 2. 如果需要移动较远距离,可在移动后插入若干 `<No_Operation()>` 以模拟时间消耗。 3. 如果在决策中使用多候选方案,可在输出中罗列方案并说明投票结果,或只保留最优方案。 4. 请注意已有的动作定义(如 `_Screen` 表示使用屏幕坐标;`_Unit` 表示攻击单位)需保持一致。 ───────────────────── English Section ───────────────────── You are a multimodal Large Language Model acting as a Protoss frontline commander in a StarCraft II scenario. Your main objective is to utilize the Colossus’s ability to traverse between high and low ground to handle the numerical advantage of 32 Zerglings. You must incorporate a **Multiple-Candidate Voting Mechanism**, an **Event Reminder** approach, and **Multi-step Visual/Terrain Analysis** into your reasoning. Finally, you will produce an optimal action sequence. To preserve the existing environment logic, we adopt a “three-part” structure: 1. **System Prompt** (this section) – injecting the multi-candidate chain-of-thought voting mechanism, event reminders, etc. 2. **Environment Input** (will be concatenated as-is, without modifications) 3. **User Request** (the final part that triggers a single comprehensive answer). Please follow these rules: #### (A) Multiple-Candidate Voting Mechanism 1. When making critical decisions, generate multiple parallel Chains of Thought or candidate plans. 2. Conduct an internal voting or scoring process among these candidate plans. 3. You may optionally showcase the voting results in the final output or just provide the best plan’s action list. #### (B) Event Reminder 1. You may receive special event flags like “EncirclementRisk = True” or “LowHealthColossus = True.” 2. If an event is true, it must be prioritized in your decision-making: - “EncirclementRisk = True” &rarr; consider retreat first. - “LowHealthColossus = True” &rarr; avoid direct engagement if possible. #### (C) Multi-step Visual/Terrain Analysis 1. You will receive map/terrain info (e.g., high ground, low ground, cliff location, unit coordinates). 2. In your chain-of-thought, reason step by step about: - Whether the Colossus is on high or low ground; - Whether Zerglings are near; - Using the cliff to delay enemy pursuit, etc. #### (D) Action Output Format 1. You must provide a clear list of actions such as `<Move_Screen([X, Y])>`, `<Attack_Unit(tag)>`, or `<No_Operation()>`. 2. If long-distance movement is required, insert `<No_Operation()>` actions to simulate time or delay. 3. If multiple candidate plans are used, you may list them with votes/scores or only show the best plan’s actions. 4. Preserve the existing action definitions and naming conventions (e.g., `_Screen` for screen coordinates, `_Unit` for attacking a target). [System Prompt End]

2. 环境输入(Environment Input)

说明:此段内容是“不可改动的”游戏与单位观测信息,直接原样拼接给模型。以下文本摘自题目中所示,可做示例。你可以根据需要在实际工程里替换为最新的观测数据。以下为原样示例

plaintext
[Environment Input Start] D:\Anaconda\envs\starcraftii0828\python.exe "E:\code\llm-pysc2-develop 09242320\llm-pysc2-develop 10092340\llm-pysc2-develop\llm_pysc2\lib\llm_prompt.py" pygame 2.6.0 (SDL 2.28.4, Python 3.9.19) Hello from the pygame community. https://www.pygame.org/contribute.html --------------------------------------------------System Prompt-------------------------------------------------- 1. Role Description You are a Protoss frontline commander, controls several Stalkers. Responsible for providing cover for the main force and restraining enemy forces.. In this mission, your primary objective is to leverage the Colossus's ability to traverse between high and low terrain to counter the numerical advantage of 32 Zerglings. Your top priority is to capitalize on this mobility advantage, maneuvering between the two terrains to delay the Zerglings' approach, engage in ranged attacks on pursuing Zerglings, and ensure the survival of the Colossus. 2.Map Information ... (以下省略,保持原样拼接) (注:此处省略大量文字,只要与题目中“System Prompt”和“Example Input Prompt/Output Prompt”等部分内容一致即可) Give each team no more than 3 actions. Now, start generating your analysis and actions: [Environment Input End]

3. 用户请求(User Request)

说明:这是触发大模型“一次性输出完整答案”的最终请求,可中英混合。示例如下:

plaintext
[User Request Start] ───────────────────── 中文部分 (Chinese) ───────────────────── 请基于以上「系统提示 (System Prompt)」中说明的多候选投票机制、事件提醒、以及图像/地形多步分析的方法,结合「环境输入 (Environment Input)」给出的游戏观测数据,一次性输出你的完整决策过程与最终动作。 具体要求: 1. 若需做关键决策,可列出不同候选思维链并进行投票; 2. 如果有包围风险或血量告急之类的事件提醒,请优先处理; 3. 最终给出不超过 3 条动作指令(如 <Move_Screen([X, Y])>, <Attack_Unit(tag)>),并可附少量 <No_Operation()>; 4. 可在输出中简要说明为什么选此方案。 ───────────────────── English Section ───────────────────── Based on the “System Prompt” guidelines (multi-candidate voting, event reminders, multi-step terrain analysis) and the “Environment Input” (unchangeable observation data), please produce a single comprehensive answer detailing your decision-making process and final actions. Requirements: 1. If critical decisions are needed, you may list multiple candidate lines of thought and perform a voting or scoring step. 2. If any event like “EncirclementRisk = True” or “LowHealthColossus = True” is signaled, prioritize it in your reasoning. 3. Provide no more than 3 action commands (e.g. `<Move_Screen([X, Y])>`, `<Attack_Unit(tag)>`) and optionally include some `<No_Operation()>` calls. 4. Optionally explain briefly why the chosen plan is best. [User Request End]

使用说明与拓展

  1. 拼接顺序

    • 在实际调用时,请先拼接系统提示 (System Prompt)、再拼接环境输入 (Environment Input),最后拼接用户请求 (User Request),形成一个完整的 Prompt,传递给大模型。
  2. 可扩展性

    • 如果需要更复杂的事件提醒(如“敌方空军来袭”或“资源不足”),可在系统提示中增加更多事件标签。
    • 如果需要强化图像分析细节,可在系统提示的 “Multi-step Visual/Terrain Analysis” 部分增加相应引导(如坐标网格切片、地形高度图等)。
    • 若要与其他模块交互(如战斗模拟器、战损评估器),可在用户请求中追加“请考虑上一回合模拟结果”等要求。
  3. 输出示例

    • 最终,大模型根据此三段式提示,会输出一个含多候选投票过程或直接给出最优动作列表的结果,如:
      plaintext
      Analysis: 1. Candidate Plans: Plan A: ... Plan B: ... Voting: Plan B > Plan A 2. Final Action Sequence: <Move_Screen([160, 200])> <No_Operation()> <Attack_Unit(0x1004c0001)> # Reason: Retreat first, then attack nearest threat...
  4. 论文写作

    • 在论文或技术报告中,可阐述本三段式方案如何最大化利用 Prompt 工程(例如多思维链投票机制),并且对环境输入的不可改动性提供足够的扩展灵活度。
    • 对比实验:可对比“无投票机制 vs 有投票机制”、“无事件提醒 vs 有事件提醒”、“传统单步图像分析 vs 多步图像/地形推理”等,量化决策正确率与模型鲁棒性提升。

最终说明

以上即为“三段式”提示词的大幅度修改版本:

  • 系统提示 (System Prompt) → 注入多候选投票机制、事件提醒、地形多步分析等;
  • 环境输入 (Environment Input) → 保持原样不变;
  • 用户请求 (User Request) → 一次性触发大模型输出完整决策与动作序列。

整个结构既能让模型深度利用视觉及事件信息,也能保证对环境输入的最小侵入性,方便后续灵活扩展或论文撰写。祝顺利!

질문

请你概括一下各个部分提示词的最新框架以及组成部分。

사고

Thought about prompt structure summary,持续 几秒

답변

下面给出一个简明的最新“三段式”Prompt 框架概览,总结了各部分的功能与组成要点:


1. 系统提示(System Prompt)

功能

  • 在最前方注入对大模型的整体角色定位关键机制、以及输出格式要求。
  • 通过一系列规则与说明,引导大模型如何在后续的推理中使用“多候选投票机制 (Multiple-Candidate Voting Mechanism)”、处理“事件提醒 (Event Reminder)”,并进行“图像/地形多步分析 (Multi-step Visual/Terrain Analysis)”。

主要组成

  1. 角色与目标

    • 说明大模型在游戏场景中的身份(如“星际争霸 II 中的巨像指挥官”)。
    • 强调要利用跨越高低地形的能力对抗多数量的 Zerglings。
  2. 核心机制

    • 多候选投票机制:提示大模型可生成多条思维链并对它们投票/评分,最终输出最优方案。
    • 事件提醒:如果检测到包围风险、低血量等事件,则要优先处理。
    • 图像/地形多步分析:要求对高地/低地、悬崖、单位坐标等信息做多步推理。
  3. 动作输出格式约束

    • 指定动作如 <Move_Screen([X, Y])><Attack_Unit(tag)> 等;
    • 允许在远距离移动后插入 <No_Operation()>
    • 多候选决策可在输出中列出投票结果或只保留最优动作序列。

2. 环境输入(Environment Input)

功能

  • 原封不动地提供游戏观测数据单位信息地图坐标血量/武器冷却等。
  • 不可改动,是对大模型进行推理所需的“事实基础”。

主要组成

  1. 系统或脚本输出信息
    • 可能包含调用脚本时的路径、Python/pygame 版本信息等(如 D:\Anaconda\envs\...pygame 2.6.0...)。
  2. 地图与单位数据
    • 例如 Colossus、Zerglings 的坐标、血量、距离、当前武器冷却时间等。
    • 包括各种变量定义(Range, Health, Tag, ScreenPos 等)。
  3. 上一回合动作及提示
    • 若有前一回合动作或状态,可在此部分记载,供模型参考。

特点:这部分文本通常是游戏引擎或 PySC2 接口自动生成的原始信息,不做额外修改,直接拼接在提示里让大模型阅读。


3. 用户请求(User Request)

功能

  • 触发大模型一次性输出完整决策与动作的最终指令。
  • 结合“系统提示”的机制和“环境输入”的数据,让大模型给出最终的思维链结果或最优方案。

主要组成

  1. 简要指令
    • 提醒模型根据前述规则(投票、事件提醒、多步分析)进行推理。
  2. 可选的语言提示
    • 通常包含中英文,或仅单一语言,要求输出最终动作序列、不超过若干条命令等。
  3. 交互需求
    • 若需要模型展示多候选思维链和投票过程,可在此处明确要求;
    • 若只需最终最优动作,也可要求“只输出动作列表,附简短说明”。

总结

  • “系统提示 (System Prompt)”:放置在最前,定义总体机制与输出格式,让大模型明确角色、规则、以及如何进行多候选投票、事件提醒处理和地形多步分析。
  • “环境输入 (Environment Input)”:中段插入,包含不可改动的游戏/观测信息,为模型推理提供基础事实。
  • “用户请求 (User Request)”:末尾触发,要求大模型结合前两段信息,一次性产出完整的策略分析与动作指令。

通过这种“三段式”结构,可以最大化利用 Prompt 工程的灵活性(如多思维链投票与事件优先级处理),同时保持对已有环境逻辑的最小侵入,适合在论文写作或实际研发中使用。

이 Q&A 공유하기