最终幻想战术类游戏的人工智能

发布于 2024-09-07 12:04:25 字数 688 浏览 1 评论 0原文

我正在按照《最终幻想》战术实施基于小型网格、回合制的策略。

您对我如何进行目标选择、动作和技能选择过程有什么想法吗?

我正在考虑将这些决策分开,但这三个决策在很大程度上都是耦合的。 (例如,我无法决定向哪里移动,除非我知道我要攻击谁,以及我将使用的技能的范围,反之亦然,我无法决定攻击谁,除非我知道它有多少回合将带我达到每个目标)

我想转向一个统一的系统,但是尝试以《杀戮地带 1》人工智能中的方式使用潜在领域研究中的东西,让我陷入了局部最大值。

=== 更新 1

我目前正在尝试使用潜在场/影响图来生成我做出决策的数据。

我不知道如何处理拥有许多技能,以及不会造成伤害但会增强/减益或改变世界的技能。

其他人建议使用目前在围棋游戏中使用的蒙特卡洛树搜索。

我相信我的演员将使用的空间并不适合它,因为游戏中的许多动作不会导致你可以攻击和影响世界的位置(我处于一个比最终幻想战术更大的世界)

在《最终幻想战术》中,它可能会成功应用,尽管分支因子比 9x9 Go 的分支因子大得多(据我所知)

===

提前致谢,Xtapodi。

ps.1 - 一个问题是,要准确地知道敌人距离我有多远,我需要找到他的路径,因为虽然敌人很近,但我们可能会被一个无法逾越的悬崖隔开,这需要 4 个回合才能绕一圈。或者更糟糕的是,一个单位挡住了道路,比如说一座桥,所以实际上没有办法到达他。

I am implementing a small grid based, turn based strategy in the lines of Final Fantasy tactics.

Do you have any ideas on how i can approach the target selection, movement and skill selection process?

I am considering having the decisions disconnected, but all these 3 decisions are largely coupled.
(eg. i can't decide where to move unless i know who i am going to attack, and what range the skill i will use has, and vice versa, i can't decide who to attack unless i know how many turns it will take me to reach each target)

I want to move towards a unified system, but trying out things from Potential field research used in a manner like in the Killzone 1 AI has me getting stuck on local maximums.

=== Update 1

I am currently trying to use potential fields / influence maps to generate the data i take decisions upon.

I have no idea how to handle having many skills, and skills that don't do damage but rather buff/debuff or alter the world.

Someone elsewhere suggested using Monte Carlo Tree Search, used currently in Go games.

I believe the space my actors will be using is not good for it, as many many moves in the game don't result in a position from which you can attack and affect the world (i am in a world bigger than final fantasy tactics)

In final fantasy tactics it might be applied successfully, although the branching factor is much bigger than that of 9x9 Go (from what i understand)

===

Thanks in advance, Xtapodi.

ps.1 - A problem is that to know accurately how far an enemy is i would need to pathfind to him, because although the enemy is near, an impassable cliff might be separating us which takes 4 turns to go around. Or worse, a unit is blocking the way on lets say a bridge so there is actually no way to reach him.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

筑梦 2024-09-14 12:04:25

我使用的一种方法是采用两遍系统。

首先,找出你的单位可以去哪里。使用 A* 或其他标记地形来查看单位本回合可以移动多远。

一旦你知道了这一点,就可以逐步了解你的可用策略(近战攻击、治疗友方单位等等),并为该策略的所有可用用途分配一个适应度函数。如果您经过标记的地形,您可以非常快速地确定您可能采取的战术空间。

这为您提供了可用策略及其每个动作的健身功能的列表。选择最好的一个或从顶部随机排列。如果没有任何可用的战术,请重复该过程,标记地形以进行两次移动,依此类推。

我所说的适应度函数是指决定在特定单位或位置上执行策略的“价值”。例如,您的“治愈友方单位”战术决策阶段可能会遍历所有友方单位。如果友方单位在范围内(即,可以从你的单位可以到达的位置到达),请将其添加到可能的战术列表中,并为其指定一个等于 100 *(1.0 - 单位生命值)的健康等级,其中单位生命值范围从 0 到 1。因此,将一个角色的生命值治疗到只剩下 10% 则价值 90 点,而一个单位仅下降 5% 则只值 5 点,并且该单位甚至不会考虑治疗未受损的角色单元。特殊单位(即保留胜利条件所需的“保护boss”场景单位)可以给予更高的基数,以便它们受到友方单位更多的关注。

同样,你的“近战攻击”决策阶段将逐步遍历所有可到达的敌方单位,计算可能的伤害,并将其与单位的生命值进行比较。给每个单位一个“攻击意愿”,并将其乘以你可能会做的剩余生命值的百分比,你就得到了一个非常详细的适应度函数,它有利于在可能的情况下消除单位,但仍然追求高价值目标。

使用这样的过程,你会得到一个选项列表,例如“移动到位置 A 并治疗友方单位 B:50 点”、“移动到位置 C 并攻击敌方单位 D:15 点”等。突然之间,很容易选择战术。

可以通过将策略的适用性乘以实施该策略所必须采取的路径的适用性来添加更多细节。例如,如果你必须移动到的地方才能治愈友方单位,这会让你处于严重危险之中(即站在熔岩空间或其他地方),你可以通过将该策略的适用性乘以.2 左右,以便单位仍然可以考虑它,但前提是它确实很重要。所有这一切都需要编写一个算法来评估给定位置的适合度,并且可以像预先计算的“地形需求”数字一样简单,也可以像维护敌方单位的“威胁地图”一样复杂。

当然,困难的部分是找到正确的措施使发动机变得智能。但这是系统中值得调整的有趣部分。

One approach I've used is to do a two-pass system.

First, find out where your unit can go. Use A* or whatever to flag out the terrain to see how far the unit can move this turn.

Once you know that, step through your available tactics (melee attack, heal friendly unit, whatever), and assign a fitness function for all available uses of the tactic. If you pass in the flagged terrain, you can very quickly determine what your space of possible tactics are.

This gives you a list of available tactics and their fitness functions for each move. Select the best one or randomize from the top. If there aren't any tactics available, repeat the process with flagging the terrain for two moves, and so on.

What I mean by fitness function is to decide on the "value" of performing the tactic on a certain unit or location. For instance, your "heal a friendly unit" tactical decision phase might step through all friendly units. If a friendly unit is within range (i.e., is reachable from a location your unit can reach), add it to the list of possible tactics and give it a fitness rating equal to, say, 100 * (1.0 - unit health), where unit health ranges from 0 to 1. Thus, healing a character down to only 10% health remaining would be worth 90 points, while a unit only down 5% would only be worth 5, and the unit wouldn't even consider healing an undamaged unit. Special units (i.e., "protect the boss" scenario units required to retain victory conditions) could be given a higher base number, so that they are given more attention by friendly units.

Similarly, your "melee attack" decision phase would step through all reachable enemy units, compute the likely damage, and compare that to the unit's health. Give each unit a "desirability" to attack, and multiply it by the percentage of remaining health you'd likely do, and you've got a pretty detailed fitness function that favors eliminating units when you can, but still goes after high-value targets.

Using a process like this, you'll get a list of options like "Move to location A and heal friendly unit B : 50 points", "Move to location C and attack hostile unit D : 15 points", etc. Suddenly, it's really easy to choose a tactic.

Further detail may be added by multiplying the fitness of the tactic by a fitness for the path you'd have to take to implement it. For instance, if the place you'd have to move to in order to heal a friendly unit puts you in severe danger (i.e., standing on a lava space or something), you might factor that in by multiplying the fitness of that tactic by .2 or so, so that the unit may still consider it, but only if it's really important. All this takes is writing an algorithm to assess the fitness of a given location, and could be as simple as a pre-computed "terrain desirability" number or as complex as maintaining "threat maps" of enemy units.

The hard part, of course, is finding the right measures to make the engine smart. But that's the fun part of your system to tweak.

生死何惧 2024-09-14 12:04:25

如果战斗发生的地形是预先确定的,或者不是太宽,那里 是一篇关于 FPS 中地形推理的文章,可以用作回合制游戏的基础。

简而言之,您为地图的每个单元格预先计算一组值,例如在给定方向上射击的适宜性、保护、可见性......等等。然后人工智能可以使用这些值来选择正确的操作。例如,战斗机会尽可能快地走向敌人,并在可能的情况下使用保护,而盗贼会选择敌人方向能见度尽可能低的路径,目标是从侧翼或后方攻击。

然而,如果地形是随机的和/或太宽,则预计算可能会太长而无用。

问候
纪尧姆

If the terrain where the battle occurs are pre-determined, or not too wide, there is an article on terrain reasonning in FPS that can be used as a basis for a turn-based game.

In short, you pre-calculate for each cell of the map a set of values, such as suitability for shooting in a given direction, protection, visibility... and so on. the AI can then use these values to choose a correct action. For exemple, fighter will walk as quickly as possible toward ennemy, using protection if available, while thief will take a path where visibility from ennemy direction as low as possible, with the goal of attacking from flank or rear.

if the terrain is randomized and/or too wide, the pre-calcul can be to long to be useful, however.

regards
Guillaume

似最初 2024-09-14 12:04:25

一个好问题,答案可能无处不在。就我个人而言,我在这方面没有太多经验,但我会围绕概念而不是距离制定策略。

您将为每个 NPC 创建一个状态机。它将通过某些设置来预测要攻击的角色。

例如,NPC 将被标记为攻击最弱、攻击最强或攻击受伤最严重。然后我会尝试将它们定位,以便它们可以损坏所需的目标。

如果你也有治疗者,你可以对治疗者目标做相反的事情。

目标改变也将是该系统的重要组成部分。所以你会想考虑一下。一个简单的版本是重新评估给定百分比的转弯的变化目标。

最后,我会在系统中添加随机机会。例如,可以将角色设置为“

Attack Weakest 0.25”
攻击最强.50
攻击受伤最严重的人 .25

改变目标 .1

攻击时。您生成一个 0-1 之间的随机数。如果它位于您的更改目标之下,您可以通过生成另一个随机数来攻击目标来更改目标。

您可以通过增加攻击模式百分比来开始将距离因素纳入系统。
例如,如果需要 3 回合来攻击受伤最严重的人。通过将该值除以 3 并将差值分配给其他两种可能性来降低其成为目标的百分比。

A good question the answers can be all over the place. Personally, I don't have a lot of experience with this but I would set a strategy around concept not distance.

You are going to create a state machine for each NPC. It will be predicting a character to attack via some settings.

For example a NPC would be flagged as Attack weakest or Attack Strongest or Attack Most Injured. Then I would attempt to position them such that they can damage there desired target.

If you also have healers you can do the same thing in reverse for the healer target.

Target changing will be an important part of this system too. So you will want to think about that. A simple version is to reevaluate changing target a given percentage of the turns.

And finally, I would add random chance into the system. For example a character could be set as follows

Attack Weakest .25
Attack Strongest .50
Attack Most Injured .25

Change target .1

When it's time to attack. You generate a random number from 0-1. If it's under you Change targets you change target by generating another random number of what target to attack.

You can begin to factor distance into your system by augmenting the attack mode percentages.
For example if it would take 3 turns to attack the most injured. Decrease it's percentage of being targeted by dividing that value by 3 and distributing the difference to the other two possibilities.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文