1

我正在寻找一个算法名称或实现,它可以从我可以攻击给定目标的有效移动列表中为我提供有效位置。

我有一个 2D 瓷砖地图和一个可以移动一定数量的动作并在一定范围内攻击敌人的英雄。由于地图上的障碍物,英雄的移动区域会有所不同,并且可能会出现漏洞:

在此处输入图像描述

在这个问题中我学到了了如何将这个移动区域与攻击区域结合起来,以获得我的英雄在游戏板上施加的总“威胁”范围。在这种情况下,有 2 个敌人在威胁范围内并且可以被攻击:

在此处输入图像描述

我正在寻找一个通用算法的名称或信息,它将采用:

  • 威胁区域(黄色)
  • 有效动作(橙色)
  • 目标位置(绿色)

返回橙色区域内的所有单元格,我可以从中攻击给定目标。因为敌人会施加他们自己的威胁区域,所以我不一定需要最近的方格 - 我会检查可能的移动并选择对我的英雄威胁最小的移动进行攻击。

4

2 回答 2

1

Your HERO's set of reachable tiles is known. Around each of these tiles is a THREAT AREA, which is like a (convex?) polygon (a diamond?) An enemy's position could then be thought of as another convex polygon (a square in this case). In the general case, you'd like to test whether these polygons intersect, yes?

Unfortunately it seems that this general problem is more difficult than one might hope.

We might have better luck if we can find that your problem has some special properties. If your HERO's threat area is always convex, then you can perform an inside/outside test using the boundary of the diamond (something akin to CGAL's bounded_side_2 test)

If you find that the approach is NOT good enough, then here's what you can do: pre-generate the set of "attackable positions" for the board; each cell knows the set of other cells the HERO could attack. This is a time-space tradeoff, and if you don't have big memory constraints or moving obstacles, then it should work very well.

于 2013-12-17T16:35:56.053 回答
0

以下是我认为可以解决问题的方法:

1)找出英雄的威胁(移动+攻击方格)

对于威胁区域内的每个目标,请执行以下操作:

2) 对于有效移动中的每个方格,计算到特定目标的曼哈顿距离

3)如果(距离<=攻击范围)AND方格在有效移动范围内,Hero可以从该方格攻击目标

在我的特殊情况下,我允许近战英雄攻击他们周围的所有 8 个方格(连接 8),所以他们会表现得像国际象棋中的国王,而不是曼哈顿距离将计算Chebushev 距离

算法找到要攻击目标的细胞

于 2013-12-17T18:28:40.263 回答