1
\$\begingroup\$

In grid turn-based roguelike game, how can I detect the following scenarios:

  • other actor is following observing actor
  • other actor is intentionally moving to block its path

Path blocking can happen if for example player intentionally stops right in front of actor and then when actor moves to avoid player, player moves in front and that keeps repeating as long as player does it. I managed to detect that situation in hackish way and I would like to know if there is a better method for solving things like this.

\$\endgroup\$
  • \$\begingroup\$ "I managed to detect that situation in hackish" what did your detection approach look like in this case? \$\endgroup\$ – DMGregory Dec 2 '18 at 16:03
  • \$\begingroup\$ I track number of previous position and if count of unique points in list of last positions is 2 I know it is repeating. \$\endgroup\$ – Supreme Shrimp Dec 2 '18 at 18:26
1
\$\begingroup\$

I'd recommend thinking of this as hypothesis testing. Form a hypothesis about the agent's goal, then check whether observations are consistent with that hypothesis.

For example, if we hypothesize that a character is trying to block our movement, then the next time we plan a route around them we suppose that within a given time horizon they'll try to move into our planned path. If they do, that's a point for this hypothesis. If they don't, that's a strike against it.

If we hypothesize that a character is following us, then we can model a pursuit behaviour (either a naive follow or an intercept course) and score how closely the character's subsequent moves follow this predicted behaviour.

After several iterations, the hypothesis may reach a sufficient threshold of confidence that we accept as fact, and change our behaviour accordingly.

We can reduce false positives by also scoring alternative hypotheses: maybe the character isn't following me, but pathing toward some attractive feature near me, for example.

If you want to get really crafty, this lets us conduct an experiment: deliberately change our movement to deviate from the path toward that attractive feature: does the character continue pathing toward the feature, or do they change course along a pursuit path to our new trajectory? This gives strong evidence to break a tie between the chasing and null hypotheses. ;)

\$\endgroup\$
  • \$\begingroup\$ Thats exactly what I was looking for. \$\endgroup\$ – Supreme Shrimp Dec 3 '18 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.