1

I'm currently trying to come up with a way to "resolve" a player's position with high accuracy.

The position would be the point where a missile will be sent to. The missile would have a speed/delay/width and range. The player has a speed as well and will most likely attempt to walk out of the missile, that's what I'm trying to "predict". I could filter all the spots where sending the missile to would be impossible (because the player can not move to there, or would be blocked to moving there by another object), but I'm still left with the problem of the player trying to walk out of the missile.

A simple

const float missile_speed = 2000;
const float missile_width = 100;
const float missile_delay = 0.250f;

const float target_speed = 350;

float time_to_land = (player->position.distance_to(sender->position) / missile_speed) + missile_delay;

D3DXVECTOR3 position = player->position + player->direction *  time_to_land);

would not do the trick, because the player can change his direction the moment the missile goes off, effectively making it miss. That's where the I could use the player's path and split it, then analyze it to find the spot best I can cast to, but the juking problem still persists if the player suddenly changes direction. The missile will sure hit sometimes, but it will be far from hitting consistently.

I have no idea how to handle this. I've searched for quite some time and most of the "solutions" are the ones I had in my example.

How should I handle this properly? I'm considering neural network but I have no idea where to start with it nor couldn't I find any resources that bring my problem detail using AI. Keep in mind I'm doing this in C++.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
ctx
  • 11
  • 1
  • 4
    Unless you want to "cheat" there really isn't anything you can do. If there is flight time them the user can move out of the way. You have to have to missile track the user to combat that. – NathanOliver Nov 19 '19 at 16:59
  • 2
    I’ve retagged the question because both [tag:future] and [tag:prediction] refer to specific concepts that are unrelated to your question. Please pay attention to the tag description of the tags you’re using. – Konrad Rudolph Nov 19 '19 at 17:00
  • If you first have to decide where to fire and then the player can decide whether to change course, basic game theory tells you that you can't win. You can pick one position that the player is most likely to be if careless, or where they will most likely attempt to dodge to, but it should be clear that you can't guarantee success against an adversary that can make choices. – Max Langhof Nov 19 '19 at 17:08
  • @NathanOliver- Reinstate Monica that is partially true, the user *can* move out of the way, in the end it's still a human and they make mistakes. I'm not trying to achieve 100% hit rate in the end, I'd be satisfied with ~80%. – ctx Nov 19 '19 at 17:13
  • @ctx To do that you need tracking. Tracking doesn't have to be 100% perfect. You can have the logic for changing direction only run a percentage of the time so that way it sluggishly tracks the user. This makes it harder to avoid, but still makes it possible. The amount of sluggishness determines the ease. – NathanOliver Nov 19 '19 at 17:17
  • @NathanOliver-ReinstateMonica so my best bet would be to track the object's paths in the last X seconds and somehow find a pattern? – ctx Nov 19 '19 at 17:31
  • No pattern matching is needed. Lets say it takes 2 seconds to reach the user. Every .2 second, see where the user is, the direction they are traveling, and adjust the missiles course to hit that new prediction. If that is too accurate, then increase the time step. If it is not accurate enough, the decrease the time step. – NathanOliver Nov 19 '19 at 17:35

1 Answers1

0

I couldn't see the constraints on missile after launch. If this missile can be guided/re-directed during flight, then some solution like triggering the recalculation of the position of player after every 1/10th of time_to_land would do the trick. You can increase precision by triggering more often. On the other hand, If the position of the player needs to be determined before launch, then it is different beast.

  • The position has to be determined before the launch indeed, and the missile cannot be guided/redirected. The precision could indeed be increased heavily if it was triggered more often, but it generally has a down-time (e.g 6 seconds). – ctx Nov 19 '19 at 17:28
  • As others have already suggested, u need to have missile tracker for this. One thing u can try is to keep track of the direction to which player runs when he tries to dodge a missile. As you have more data, u may have better chance of prediction. – Vinayaka Belavadi Nov 20 '19 at 17:21