0
\$\begingroup\$

I'm doing what this thread is doing except that it's not very satisfactory. What this does is finding the "closest" attacking position. But typically you want the attacker to attack from as furthest as possible to utilize his long range weapon. attacker with ranged weapon

To solve this I'm trying to modify the cost calculation of A*. When considering a tile that is close enough to the target (aka within weapon range), if the line of fire is blocked, then multiply the cost by a factor like 2.114514...

However this is very intuitive that it simply makes the attacker try to avoid to walk a path containing tiles where line of fire is blocked. There is no strict mathematical or logical proof whether this finds the furthest attacking position.

\$\endgroup\$
4
  • \$\begingroup\$ An admissible heuristic cannot over estimate the actual cost. So multiplying by a factor is likely to invalidate your search; you might get a solution but it's no longer guaranteed to be an optimal solution. \$\endgroup\$
    – Pikalek
    Commented Dec 30, 2023 at 0:05
  • \$\begingroup\$ @Pikalek Making a tile higher cost for a specific agent doesn't negate optimality. There are already tile with cost=∞, aka obstacle, on the map. If you define "optimal" as shortest path then indeed there is no guarantee it's the shortest path anymore. But still it's the "easiest" path for the given agent. \$\endgroup\$
    – Weikai Wu
    Commented Jan 2 at 7:36
  • \$\begingroup\$ What do you mean by "easiest path"? Your post mentions the furthest possible point of engagement. Are you trying to find the shortest path to that location? How should they interact i.e. if you're already in range, but there's a further away point of engagement, should you move? \$\endgroup\$
    – Pikalek
    Commented Jan 2 at 16:13
  • \$\begingroup\$ @Pikalek About validation: "Easiest path" means path with lowest total cost for a specific agent. A* always finds the lowest cost path no matter how you alternate the cost of any tile. It's not necessary to be the shortest path in the physical 3d game space. Back to my problem: currently the agent has a pathfinding module and a behavior module. The pathfinding module should point me the furthest possible attack position. Only after that the behavior module can decide what to do with the path. It can pick either way, move to furthest point, or just fire. \$\endgroup\$
    – Weikai Wu
    Commented Jan 3 at 17:21

0

You must log in to answer this question.

Browse other questions tagged .