Advertisement

NOT hitting the Target

Started by July 03, 2001 02:32 PM
7 comments, last by Lars W. 23 years, 4 months ago
Hi I am working on my algorithms for targeting a ship with a turret, but i have the problem that my turret always hits the Target when using Beam Weapons which travel in zero-time. This has some disadvantages because you do not wan''t to play against something that allways hits you. Does anybody know any solutions to simulate bad reflexes, and slow eye-hand-coordination. Maybe something that reacts more like a human, not randomly hitting, or hitting not. Lars
--------> http://www.larswolter.de <---------
This doesn''t *really* answer your question, but it''s something you may want to consider... Beam weapons are not an unrealistic possibility for warfare in outer space. The idea that humans would be controlling them directly however...is. So perhaps you might be better off thinking about how this would be dealt with by the target? Perhaps lots of little drones that would "distract" the beam weapon''s targetting system? Well, like I said, just something to think about

If that doesn''t spur any creative genius in you, here''s a more direct answer to your question... Pick two numbers. One is the maximum deviation for the beam, and the other is the gradient for the function which detemrines how far off the ideal the beam is. Now every time the beam fires, pick two random numbers. One is the direction (as seen from the beam''s perspective) that it is skewed from the ideal, and the other determines how far off it is (based on the gradient and maximum error chosen above).
If a man is talking in the forest, and there is no woman there to hear him, is he still wrong?
Advertisement
The realism isn''t the most import for me, cause like i said somethin that always hits isn''t fun. You can see it in StarTrek, they have nearly zero Time Beam Weapons with super high LEvel computers, but the evil guys never hit the good ships if they fly around much.

I think of an targeting algorithm that trys to hit the target all the time, but misses it because it makes to much turns, or is to small. i don''t wan''t a turret that sometimes hit an unmoving target and sometimes hit it. (maybe i wan''t that, if the other way isn''t fun enough, or still to tough)


Lars
--------> http://www.larswolter.de <---------
You said that the weapons are controlled from a turret...

A pretty simple way to make the weapons slower is to make the turret only move at a certain pace, like 45 degrees a second, or something like that. Then the player can move out of the way before the turret can even fire.

You could also try a percentage system. Say the targeting computer in the turret has an 80% chance or so of hitting the target. Pick a random number 0-1.
If number < .8 it''s a hit.
If .8 <= number < .9 miss to the right.
If .9 <= number < 1.0 miss to the left.
You could have pretty much any percent you want that reflects the turret accuracy. It could even increase as the difficulty of your game increases.

Hope this helped.
-Hyren



"Back to the code mines... ka-chink... ka-chink..."
vidgamez.iwarp.com
"Back to the code mines... ka-chink... ka-chink..."Tachyon Digital - Down for the summer, be back in the fall.
That sounds interesting...

Here''s one off the top of my head...
How about a random delay (from 200-400ms or something, you figure out a good time according to the size of the ship and stuff), for the turret to fire from when its supposed to, but a perfect calculation of where it''s target should be (200+400)/2 ms later? That way, a stopped ship will get hit (becuase it''s velocity is 0, using the formula Rate*Time=Distance, 0*(rand(200)+200))=0, but it would have a harder time hitting a moving ship.

I''ve never tried this before... In fact, I''ve never tried any of these kind of algorithms... But I don''t see why it won''t work.

Good luck!
Hi

Those are some interesting ideas (i have an turret that is moving slow, i have an Question for changing its direction in the Physiks/Math Area )

I will try them out.

Thanks a lot

Lars
--------> http://www.larswolter.de <---------
Advertisement
quote: Original post by Anonymous Poster
That sounds interesting...

Here''s one off the top of my head...
How about a random delay (from 200-400ms or something, you figure out a good time according to the size of the ship and stuff), for the turret to fire from when its supposed to, but a perfect calculation of where it''s target should be (200+400)/2 ms later? That way, a stopped ship will get hit (becuase it''s velocity is 0, using the formula Rate*Time=Distance, 0*(rand(200)+200))=0, but it would have a harder time hitting a moving ship.

I''ve never tried this before... In fact, I''ve never tried any of these kind of algorithms... But I don''t see why it won''t work.


This is the most physically realistic system, plus it scales to turrets of different speeds (you should always keep your turrets less than blindingly fats, though...)

The only other thing you might want to try is "prediction tracking", where the turret samples the target position a (random?) number of times and then estimates a future position that it can attain just before the target, to compensate for its firing delay (to make the turret gunman more intelligent). You''ll need to give the targets some warning of this such as a glow indicating the weapon is charging and about to fire. Hmmm... algorithm time!

The object (turret) could sample at regular intervals, but discharge at a random multiple - or fraction - of the interval to make it less predictable. I need to work on the sampling and prediction logic, but the suggestions above should keep you busy (and happy) for a while.
quote: Original post by Oluseyi
The only other thing you might want to try is "prediction tracking", [snip] Hmmm... algorithm time!


This sort of inference can be performed exceptionally quickly and as a set of matrix computations. The basic (optimal) linear filter for this sort of problem is a Kalman filter. If you're not very familiar with linear algebra you may struggle to implement such a model. Thankfully, there is almost an endless supply of code for implementing Kalman filters. Do a quick web search and see what you come up with. Try keywords like: Kalman filter, linear filter, target tracking.

Cheers,

Tim



Edited by - Timkin on July 3, 2001 11:27:03 PM
If you want variance in your aiming as well as realism so you don''t get stupid stuff like missing non-moving targets, make the variance a function of the target''s state. ie the turret is more likely to miss if the target is moving fast relative to the turret, if it is far away, small, turning quickly etc. For instance you could say the distance the beam misses the target''s centre by is sqrt(target''s speed). That way if the target is not moving, or moving slowly, it''s more likely to get hit, and the faster it goes the less likely it is to get hit.

Don''t make it too deterministic of course, have some random elements, and make it dependent on more than just speed.

This topic is closed to new replies.

Advertisement