|
|
|
|
|
|
|
|
This article is a piece of Chad Dreveny's article on bot programming, it has some interesting views on bot weapon control.
Axe
This is a fun weapon for a bot to use. However, it is a little difficult to use. It requires coordination between navigation and weapon control (you have to get close to someone before you can Axe-Murder them)! Aiming is not crucial here, just face the target. The best way to do this is use the shotgun aiming algorithm (quick and reusable).
Shotgun and Double-Barreled Shotgun
These, by far are the simplest weapons to use. The shotgun pellets travel at an infinite speed, hitting their target instantly. Thus, no prediction is needed - just point and shoot. It is simple geometry. Translate the coordinate system so that you are at the origin. Then convert the target's (x,y,z) coordinates to spherical (distance, yaw, tilt) coordinates and fire! Since the shotgun has infinite range as well, the distance is irrelevant and does not need to be calculated.
Nailgun and Super-Nailgun
Quite difficult. These projectiles move at a finite speed which makes hitting a moving target hard. Of course if you don't want to worry about hitting anything that is moving you could always use the shotgun aiming algorithm for everything! But if you actually want to connect with your target, you will need to perform some sort of prediction.
For second order prediction, the equations are a bit complex. For a moving target with a known acceleration, a, velocity, v, and initial position, p0, the position with respect to time is given by
p = (1/2) a t2 + vp
t + p0
where p, v, and a, are vectors containing the x, y, and z components. Then, knowing that the nails travel at a constant velocity, we have for the nail
n = vn t + n0
Now, in order to do some damage, we want both the target and the nail to have the same position at the same time. Thus, we have two equations and two unknowns. Easy, eh? Well, not exactly. We do not know the x, y, and z velocity components of the nail. However, with some experimentation you can find out the speed of the projectile (speed is different than velocity, remember?). So you do know that
s = |vn|
where |vn| is the Euclidean norm of the nail's velocity. Now, it can be solved. However, that doesn't mean you will want to solve it. When trying to solve this, it turns out to be a 5th order equation in t. There does exist a general formula for the solution of a 5th order equation, but let me assure you, by the time you would calculate the solutions to all 5 roots, your target would be long gone!
To simplify things a lot, you can assume the acceleration of the target is zero. This then becomes a quadratic equation and can easily be solved. You should look out for negative solutions for t. You cannot shoot someone backwards through time.
There is another way of indirectly solving these equations. You can calculate the target's future position using small increments in time. Then for each predicted position, determine if the nail can hit that spot at that time. For targets that are far away, this could involve many iterations, and again, the target may move before the targeting calculation can be done.
Grenade Launcher
By far, this is the most difficult weapon to use. It should be a weapon of last resort for the bot to use. The same equations as the nail gun can be used, except the grenade does not travel with a constant velocity - it has acceleration too. This results in a 6th order equation in t to solve. Fun, fun. Also, there is an offset added to the firing angle of the grenade launcher which has to be found using experimentation. The only way to reduce the equations to something manageable, is to assume a stationary target. This will result in a quadratic equation, but will also result in no prediction. I am still trying to find a 'good' way for Itchy to use this weapon.
Rocket Launcher
For aiming of this weapon see the discussion given on the Nailgun and Super-Nailgun. The rocket launcher is exactly the same (even the rocket speed matches the nail speed). However, it is different in the fact that firing too close to a target, can result in injury to the bot. So, check your distance before firing!
Lightning Gun
The basic aiming of the lightning gun is the same as for the shotgun. However, it does have a limited range. Also, you must avoid discharging into water (unless you are invulnerable :) ).
I guess I should mention something about line-of-sight. In Quake, the client receives updates for every entity within his current node's visibility list (see BSP tree). It does not guarantee that the entity actually visible, the target may be partially, or fully blocked by some terrain feature. So before firing, the BSP tree should be traversed in order to determine if there exists a line-of-sight between the target and the bot. This will avoid wasting ammunition as well as possible damage to the bot (firing a rocket into a nearby wall is never a good thing).
One thing that annoys me most about QuakeBots is the fact that they are too accurate (especially when using the shotgun). When trying to have a good game with some real players, I get real mad when a bot is running around pecking away at you with a shotgun. The purpose of designing a bot is to have a good opponent but not an annoying opponent. This also goes for random abuse that some bot spout out. The best bot is the most human bot.
Copyright © 1997 Chad Dreveny
|
|
|
 |
Early June |
2/6/1997 Threewave Capture the Flag v4.00
| 3/6/1997 Zeusbot v2.05
| 7/6/1997 QCBot
| 2/6/1998 CTFBot+ v1.0
| 8/6/1999 FrikBot v0.05
| 6/6/2001 Frogbot Rocket Arena 0.89SE
|
|
|
|