优化视频游戏AI用于协调投掷

发布于 2025-01-26 21:19:31 字数 419 浏览 4 评论 0原文

我目前正在为基于瓷砖的视频游戏实施AI。有多个敌人,每个敌人每回合都可以移动一个瓷砖。这些敌人还可以在直线内互相扔球,但是只有在有敌人准备捕获物体的情况下,投掷才起作用。鉴于这些条件,我们如何找到一个敌人A将球扔向另一个敌人b的最短序列的行动呢?

从本质上讲,我们想移动敌人A和敌人B,以使它们彼此直线最终。

我的第一个也是粗略的想法是使用基本的BFS,并一次从敌人A处散开,一次瓷砖。然后,在BFS的每个步骤中,我们都会记下所有可以从当前点p扔到的瓷砖(基本上只是直线p向外扇出向外扇出扇形。我也可以首先计算它们并将其保存在称为Throwable的表中用于记忆)。我们记录了从敌人B到那些可投掷瓷砖的距离。然后,在BFS的末尾,我们提到的是(距离敌人a到点p的距离) +(距离敌人b到可投掷的距离[p])被最小化。

但是,这似乎是一种非常效率和蛮力的方法。是否有一些更有效的算法?

I'm currently working on implementing the AI for a tile-based video game. There are multiple enemies, which can each move a single tile per turn. These enemies can also throw balls to each other any distance within a straight line, but the throwing only works when there is an enemy ready to catch the object. Given these conditions, how can we find the shortest sequence of coordinated moves for one enemy A to throw a ball to another enemy B?

Essentially, we want to move enemy A and enemy B so that they end up within a straight line of each other.

My first and very rough idea is to use a basic BFS and spread outwards from enemy A, one tile at a time. At each step of the BFS, we then note down all the tiles which can be thrown to from the current point P (basically just fanning outwards from point P in straight lines. I could also first calculate these and save them in a table called Throwable for memoization). We record the distance from enemy B to those throwable tiles. At the end of the BFS, we then take the point such that (distance from enemy A to point P) + (distance from enemy B to Throwable[P]) is minimized.

However, this seems like a very inefficient and brute-force approach. Is there some more efficient algorithm for this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文