.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   RACC (http://forums.bots-united.com/forumdisplay.php?f=11)
-   -   BotAim 2 announced. Best aiming ever. (http://forums.bots-united.com/showthread.php?t=3330)

Pierre-Marie Baty 04-01-2005 00:39

BotAim 2 announced. Best aiming ever.
 
I have worked out a new aiming algorithm, and I wouldn't be surprised if it was of the same level, or even better, than the official CZ bot. I based it on the same algorithm we use in electronics for commanding motion control devices (such as satellite orientation). It assimilates the player's hand to a spring with certain mechanical constraints, such as stiffness and damper.

Does that mean that it'll be included in RACC ? Hell yeah.

Does that mean that there'll also be chances that a new BotAim plugin be released soon ? VERY likely.

In the meantime, I invite you to toy with this little app I quickly wrote in LabVIEW (this thing is great for signal processing). The diagram is included, with the algorithm 8)

http://filebase.bots-united.com/inde...on=file&id=246

Har Har Har. It won't be said that all the fun is happening without me :D

stefanhendriks 04-01-2005 09:28

Re: BotAim 2 announced. Best aiming ever.
 
i checked it out, looks very nice :)

@$3.1415rin 04-01-2005 12:10

Re: BotAim 2 announced. Best aiming ever.
 
you know what the motivation of the aiming system initially used in parabot was ? exactly the same :P just that damping and spring stiffness are related via stiffness + damping = 1. I think the main problem there was, that the damping was based on a fixed coordinate system, therefore this correction I added some days ago.

Cpl. Shrike 04-01-2005 12:13

Re: BotAim 2 announced. Best aiming ever.
 
Very nice.
If im getting it correctly the aim will dead on target after the delay.

Is it possible to always keep aiming slightly off
Or keep sinusing around the 0 line (at variable amplitude) ?

Pierre-Marie Baty 04-01-2005 16:02

Re: BotAim 2 announced. Best aiming ever.
 
Yes, it is possible to keep it off, there are several means. One is to prevent the combined angle speed to go below a certain absolute value, the other is to introduce a vector offset that changes from time to time.

You can also do other interesting things, like for example induce a different spring stiffness for the horizontal movement and for the vertical one (since it is easier for a human to move the mouse horizontally than vertically). You can also have the damper evolve over time, according to the acceleration for example. And finally, you can also make the X movement influenced by the Y movement and vice versa, like what I did with BotAim, but you have much more control over it than what was possible before.

@Joe: this algorithm is not quite identical as yours in fact ; not only the maths are MUCH simpler (no exponential nor logarithmics), but in yours the acceleration gradually increases then decreases ; here as soon as a new ideal angle is set, the mouse is "pushed" towards it and then slowed down, it is not "accelerated". This provides the bot with very quick reaction times.

@$3.1415rin 04-01-2005 16:10

Re: BotAim 2 announced. Best aiming ever.
 
that exp log stuff ( or pow, whatever you like ) was just for the framerate compensation, since in my calculation the last results were taken into the calculation the next frame, thus not allowing me to take a simple division. but as I said, I cannot proove that, I can just justify it a bit.

just wanted to say that the idea is the same. dunno about your implementation and formulas, I think you havnt posted anything yet.
the mechanic analogon to my algorithm would look like m x'' + k ( x' - v0 ) + d ( x - x0) = 0 where v0 is wanted velocity and x0 wanted position. then one gets that k^2=4dm for the ideal configuration ( no oscilations ). but to keep things simple in old joebot, i just copied tobias code and made it better/worse whatever.

Pierre-Marie Baty 04-01-2005 21:48

Re: BotAim 2 announced. Best aiming ever.
 
Quote:

Originally Posted by Aspirin
just wanted to say that the idea is the same. dunno about your implementation and formulas, I think you havnt posted anything yet.
the mechanic analogon to my algorithm would look like m x'' + k ( x' - v0 ) + d ( x - x0) = 0 where v0 is wanted velocity and x0 wanted position.

Did you see the png file that I included with the zip ? the implementation is there, actually that's all there is :)

@$3.1415rin 04-01-2005 22:04

Re: BotAim 2 announced. Best aiming ever.
 
ah right, not only fancy icons, but also some text :)

with that implementation you'll still have that problem with the moving target, that problem that i fixed last week in my algorithm. therefore I wrote ( x' -v0 ) in the DEq above :) that k^2 = 4 d m is right for both differential equations, since the oscillating part is part of the solution of the homogeneous equation.

but with that equations there in your png file, it's still "accelerated", like in my implementation, I still don't see a difference. anyway, it's a good idea to think about such stuff from scratch ( from scratch is somehow often a good idea :D ), currently I dont understand that exp log stuff myself.

Pierre-Marie Baty 04-01-2005 23:51

Re: BotAim 2 announced. Best aiming ever.
 
here's the difference, if ASCII art allows me to explain it:

Code:

Yours:
 
ideal -------                .-°-..-----
                                        /
                                        |
current ----- ____../
 
 
Mine:
 
ideal -------        .-°-..-----
                                /
                                |
current ----- ____|


@$3.1415rin 05-01-2005 22:54

Re: BotAim 2 announced. Best aiming ever.
 
it's not that black and white, since the spring doesnt allow you to bring all speed on the 'cursor' instantly, unless you have a infinite high spring constant.

anyway ...

I couldnt stop me from working also on this, so here a little info on the little I did ( works really nice btw 8) )

Idea ( that's almost the standard spring with damping differential equation ) : m x'' + k ( x' - v0 ) + d ( x - x0 ) = 0 o_O
where we have
  • x : the position of the mass ( in our case, the cursor ) or better, a function depending of time for the position.
  • v0 : the velocity of the target to follow
  • x0 : the position of the target to follow
  • ... I hope you know what the ' are meaning. if not, that are the derivatives of x. x' is the change of position over time, i.e. the speed. x'' is accordingly the acceleration.
As always with differential equations, we search a function x which fits in that equation above, where that relation is true. This is usually done by searching the solution of the homogenous DEq, in our case that's m x'' + k x' + d x = 0. You can solve this with an exponential approach, i.e. you set x = exp( l * t ), put it into the hom DEq and divide by exp ( l * t ). This way we get a quadratic expression for l : m l^2 + k l + d = 0 which can be easily solved : l = -k/2m +- Sqrt( k^2 - 4 d m )/2m
Here the oscillations come into play : We know that exp ( i x ) = i sin ( x ) + cos( x ) and that exp(a) exp(b) = exp (a + b). Thus, if we get a l which contains i ( i = Sqrt(-1), called imaginary number ( dunno the english term )), we'd get oscillations. Since we don't wanna get them, we have to chose d and k accordingly. when we have k^2 = 4 d m, this is called the aperiodic limit, which means that if this is the case, this is the fastest way to get to 0 ( in our hom DEq ). if k^2 > 4 d m we'd still have no oscillations, but approaching will be slower. ( for aiming in the bot a little bit of oscillations might be acceptable since we have bullet spread, the punchangle stuff etc. )
the solution of the inhomogenous part of the DEq isnt of interest here since it's constant if v0 and x0 are constant. x0 isnt of course constant, since v0 is normally nonzero, but solving the DEq with x0 and v0 = x0' only gives nasty stuff ( at least that's what mathematica tells me :D ) which looks pretty nonoscillating, and the main interest here were the oscillations.

OK, enough ! I know how you like math, but I hope this is understandable, at least I tried 8D
Code:

float m = 1,
k = -1,
d = k*k / 4.f / m;
if(abs(m_VIdealAngles.y - m_VCurrentAngles.y) > 180){
if(m_VIdealAngles.y > 0){
m_VIdealAngles.y -= 360.0f;
}
else{
m_VIdealAngles.y += 360.0f;
}
}
m_VAnglesSpeed.y += (k/m * (m_VAnglesSpeed.y - m_VAngLookSpeed.y) + d/m * (m_VIdealAngles.y - m_VCurrentAngles.y))*m_fmsecCount / 1000.f;
m_VCurrentAngles.y += m_fmsecCount / 1000.f * m_VAnglesSpeed.y;
m_VAnglesSpeed.x += (k/m * (m_VAnglesSpeed.x - m_VAngLookSpeed.x) + d/m * (m_VIdealAngles.x - m_VCurrentAngles.x)) * m_fmsecCount / 1000.f;
m_VCurrentAngles.x += m_fmsecCount / 1000.f * m_VAnglesSpeed.x;
//---------------------------
if(abs(m_VIdealVAngle.y - m_VCurrentVAngle.y) > 180){
if(m_VIdealVAngle.y > 0){
m_VIdealVAngle.y -= 360.0f;
}
else{
m_VIdealVAngle.y += 360.0f;
}
}
m_VVAngleSpeed.y += (k/m * (m_VVAngleSpeed.y - m_VAngLookSpeed.y) + d/m * (m_VIdealVAngle.y - m_VCurrentVAngle.y))*m_fmsecCount / 1000.f;
m_VCurrentVAngle.y += m_fmsecCount / 1000.f * m_VVAngleSpeed.y;
m_VVAngleSpeed.x += (k/m * (m_VVAngleSpeed.x - m_VAngLookSpeed.x) + d/m * (m_VIdealVAngle.x - m_VCurrentVAngle.x))*m_fmsecCount / 1000.f;
m_VCurrentVAngle.x += m_fmsecCount / 1000.f * m_VVAngleSpeed.x;
m_VOutVAngle = m_VCurrentVAngle;
m_VOutAngles = m_VCurrentAngles;

( I thought tobias algorithm was based on this one, but if it is, it's a very rough approximation I think. anyway, that code is also used in other circumstances, e.g. in learning algorithms for neural networks etc. )

Pierre-Marie Baty 06-01-2005 03:25

Re: BotAim 2 announced. Best aiming ever.
 
mommy

KWo 06-01-2005 09:44

Re: BotAim 2 announced. Best aiming ever.
 
Quote:

Originally Posted by @$3.1415rin
As always with differential equations, we search a function x which fits in that equation above, where that relation is true. This is usually done by searching the solution of the homogenous DEq, in our case that's m x'' + k x' + d x = 0. You can solve this with an exponential approach, i.e. you set x = exp( l * t ), put it into the hom DEq and divide by exp ( l * t ). This way we get a quadratic expression for l : m l^2 + k l + d = 0 which can be easily solved : l = -k/2m +- Sqrt( k^2 - 4 d m )/2m

I guess it may get confused Pierre a bit, so I'll try to explain it a bit more. :)
1. (f(g(t)))'=(f'(g(t)))*g'(t)
2. (exp(t))'=exp(t)
3. (l*t)'=l(t)'=l

Well, when we know this we can try find x'' and x' from Aspirin's equation (I mean this m x'' + k x' + d x = 0)


x'=(exp(l*t))'=(exp(l*t))*(l*t)'=(exp(l*t))*l=l*ex p(l*t)
x''=(x')'=(l*(exp(l*t))'=l*(exp(l*t))'=l*x'=l*l*(e xp(l*t))=(l^2)*exp(l*t)

so
m*x''=m*(l^2)*exp(l*t)
k*x'=k*l*exp(l*t)
d*x=d*exp(l*t)
and
m*(l^2)*exp(l*t)+k*l*exp(l*t)+d*exp(l*t)=0
then divide all equation by exp(l*t)

finally
m*(l^2)+k*l+d=0


I hope now it will be more clear for Pierre. 8)

[EDIT]
Cleared a bit more - according to Aspirin's suggestion
[/EDIT]


stefanhendriks 06-01-2005 10:10

Re: BotAim 2 announced. Best aiming ever.
 
noooo, too much math... brain explodes. Don't you ever do that again when i am just awake and want to relax and read some post asp! :D

*eek*

;)

@$3.1415rin 07-01-2005 22:31

Re: BotAim 2 announced. Best aiming ever.
 
:| didnt want to intimidate anyone ...

MarD 08-01-2005 01:15

Re: BotAim 2 announced. Best aiming ever.
 
Heyyo,

Hmm, very interesting PMB, I tested it out too, and yeah, it's very interesting. The ability to change the spring and damping and adjust it to the framerate will make this definately very good for a bot. Lol, it makes me think of the Q3A bot on 'Bring It On' difficulty where its view would spaz like crazy once it locked onto an enemy. May not look realistic yes, but at least it wasn't cpu-intensive eh? :P

Pierre-Marie Baty 08-01-2005 06:08

Re: BotAim 2 announced. Best aiming ever.
 
actually I'm starting to understand your math stuff, guys... just that I didn't know that one could solve diff eqs using exp stuff ; for us in electronics, when we have to solve a DEq of some sort, we turn it into the Laplace transform, or else the Z transform depending of its nature... solving DEqs with the Laplace transform is so fuckin'easy, I wonder why you math nerds feel the need to go the complicated way all the time... :|

@$3.1415rin 08-01-2005 09:19

Re: BotAim 2 announced. Best aiming ever.
 
I think solving those equations using laplace, fourier, whatever transformations wouldn't be simpler to explain here, since there is quite some more theory behind it. and I thought that exp approach would be the std way to go with such simple DEqs :)

Rifleman 08-01-2005 11:08

Re: BotAim 2 announced. Best aiming ever.
 
math ... yeah , I still how I fail me math test :D

KWo 08-01-2005 13:39

Re: BotAim 2 announced. Best aiming ever.
 
Yeah - this exp is a standard way tosolve this type of DEq equations. There are some kiknds of equations and for them You should use some standard solution (You need to remembere them or look into some math manual). The same like for Integrators from some more complicated functions - there are some standard ways to solve them, too.
About Laplace - yeah - You can see the same equation, something like:

m+ k/s +d/(s^2)=0 => m*s^2+k*s+d=0

with the same result like with this Aspirin's way, but Yeah - it needs much more theory to show and explain here. ;)

@$3.1415rin 12-01-2005 19:57

Re: BotAim 2 announced. Best aiming ever.
 
having m < 1 or k > 1 results often in 'going' crazy, because just using the DEq iteratively you'd get too big changes. maybe one'd need to solve the DEq, and get the coefficients from the current 'initial conditions' to calculate the next few frames. then we'd be save from oscillations, although it won't be that easy, especially with that special solution. the general wouldnt be a problem, but that one ...

Pierre-Marie Baty 12-01-2005 21:22

Re: BotAim 2 announced. Best aiming ever.
 
the thing is that we WANT a little bit of oscillation. Just enough to get on the target faster, but not so much as to bounce left and right of it. The oscillation I want is directly function of the size of the target :)

stefanhendriks 12-01-2005 21:59

Re: BotAim 2 announced. Best aiming ever.
 
i thought off this later:

does the aiming also effect the 'size' of the target? Like, when a target is further away its smaller and thus harder to 'hit' (easier to mis, move your mouse wronly, etc).

But, what if a target is BIG and its far away... ok, i know, this will not really happen in CS. But still....

@$3.1415rin 12-01-2005 22:04

Re: BotAim 2 announced. Best aiming ever.
 
well, then you can chose d accordingly, k^2 < 4 d m and you'll get oscillations. 2 Pi i/Sqrt[k^2-4 d m] should be the frequency of your oscillation while e^(-k/2m) describes the damping curve. -> Thus you can calculate the maxima of your oscillations and see if they fit your object, or in this case better the other way around.

@$3.1415rin 16-01-2005 22:50

Re: BotAim 2 announced. Best aiming ever.
 
just written some lines for given d. since we aint got no latex in this forum, a picture here. it's rather an approximation, but it works. this is only based on the homogenous part of the DEq, but that should be sufficient here, since the inhom part is basically some other sort of damping.
One could also specify how long it should take until a given deviation from the target is reached, it's here 3/4 T, but it shouldnt be a problem for other times, just insert it there and get the stuff for k. The q is here (wanted max deviation after one oscillation) / (difference we have when starting aiming) and that's the tricky part I guess, it might not always be a good idea just to update that q when starting to aim. the situation might change and that type of stuff ... but that shouldnt be our problem here

http://joebot.bots-united.com/joebotxp/botaim.png

V or 'Tex 09-02-2005 23:00

Re: BotAim 2 announced. Best aiming ever.
 
Since there are probably standard library functions for complex number manipulation, could you use complex numbers to represent x and y axis rotation. Such that ax+by is a complex number of the form a+bi. I don't know if this would be more or less efficient but you may have more luck manipulating them that way. You should keep in mind people percieve aiming to be a grid on a sphere where everything is a rotation, whereas plotting a+bi would be done on a plane. Might have to use some unusual arithmatic to warp the plane but it should be sufficient.

Or maybe you should just come up with your own class to represent spherical mapping?

@$3.1415rin 09-02-2005 23:40

Re: BotAim 2 announced. Best aiming ever.
 
according to the superposition principle I think that regarding pitch and yaw here as independant angles is ok. I don't see what complex numbers might improve here ( we already used them for deriving the formulas ). For describing points on a sphere you could use SU(2) or SO(3) matrices, but I dont see the advantage, yet, beside irritating more ppl.

hey pierre, what about your progress here ? just hyping stuff or also some "hard facts" ? *g*

Pierre-Marie Baty 10-02-2005 11:56

Re: BotAim 2 announced. Best aiming ever.
 
Yes, I've been editing the wiki a lot these days instead of doing real stuff. I should get back to this plugin and finish it, and I bet you're impatient to compare my implementation with yours, ain't I right? :D

Pierre-Marie Baty 11-02-2005 21:31

Re: BotAim 2 announced. Best aiming ever.
 
it's FINISHED! :D

I'm writing the readme right now. It has an impressive number of CVARs...

Code:

cvar_t botaim_enable = {"botaim_enable", "1", FCVAR_EXTDLL};
cvar_t botaim_spring_stiffness_x = {"botaim_spring_stiffness_x", "13.0", FCVAR_EXTDLL};
cvar_t botaim_spring_stiffness_y = {"botaim_spring_stiffness_y", "13.0", FCVAR_EXTDLL};
cvar_t botaim_damper_coefficient_x = {"botaim_damper_coefficient_x", "2.0", FCVAR_EXTDLL};
cvar_t botaim_damper_coefficient_y = {"botaim_damper_coefficient_y", "2.0", FCVAR_EXTDLL};
cvar_t botaim_deviation_x = {"botaim_deviation_x", "20.0", FCVAR_EXTDLL};
cvar_t botaim_deviation_y = {"botaim_deviation_y", "90.0", FCVAR_EXTDLL};
cvar_t botaim_influence_x_on_y = {"botaim_influence_x_on_y", "0.25", FCVAR_EXTDLL};
cvar_t botaim_influence_y_on_x = {"botaim_influence_y_on_x", "0.17", FCVAR_EXTDLL};
cvar_t botaim_offset_delay = {"botaim_offset_delay", "1.2", FCVAR_EXTDLL};
cvar_t botaim_notarget_slowdown_ratio = {"botaim_notarget_slowdown_ratio", "0.3", FCVAR_EXTDLL};
cvar_t botaim_target_anticipation_ratio = {"botaim_target_anticipation_ratio", "0.8", FCVAR_EXTDLL};
cvar_t botaim_fix = {"botaim_fix", "1", FCVAR_EXTDLL};


The Storm 11-02-2005 22:22

Re: BotAim 2 announced. Best aiming ever.
 
When you finish your readme file please give a link because I have a big interest :).

@$3.1415rin 24-02-2005 10:27

Re: BotAim 2 announced. Best aiming ever.
 
just remembered that our tutor in exphysI had a nice paper about DEq ... so for all of those who are not familiar with it, this might be a short overview : http://www.thphys.uni-heidelberg.de/...ov/diffeqs.pdf

[BBB]sluggo 24-02-2005 21:42

Re: BotAim 2 announced. Best aiming ever.
 
Aspirin.... are you totaly (in)sane??? :-)

I love that people are good at different things so that I don't have to learn that level of math. ;-)

ghost of evilspy 02-12-2005 10:53

Re: BotAim 2 announced. Best aiming ever.
 
bad forums, no delete post

@$3.1415rin 02-12-2005 17:13

Re: BotAim 2 announced. Best aiming ever.
 
there are reasons that deleting posts isnt permitted, it's not a problem of this forum.

currently hearing a lecture on numerical solving of differential equations ( http://numerik.uni-hd.de/~lehre/notes/num1/numerik1.pdf ), maybe I should apply some of that stuff to the botaim code :)

ghost of evilspy 04-12-2005 02:05

Re: BotAim 2 announced. Best aiming ever.
 
IMHO easier way to make more human aim is to make bot predict position of player by using old stored data of enemy's position and velocity. That way if enemy suddently changes direction of movement and/or speed it takes some time for bot to follow this change (instead of noticing instantly). I think this happens with humans too.. you don't see world instantly since processing data (brain) from your imaging device(s) (eyes) takes time and this slight time different is fixed by prediction.

Following example code uses linked list for storing timestamped position data (origin and velocity). Position data is stored every 33ms and GetPredictedPlayerPosition picks two data slots near time value passed to it and makes simple prediction of player's position. Works good on my bot/server 9_9

http://evilspy.1g.fi/botpredv1.txt

Pierre-Marie Baty 05-12-2005 06:04

Re: BotAim 2 announced. Best aiming ever.
 
This is also a good method, although the one used in botaim2 isn't flawed because of that ; that latency time it takes a bot to notice a change in direction is affected by the aiming momentum. With your method the setting values will be different, but the result will be the same.

ghost of evilspy 05-12-2005 11:20

Re: BotAim 2 announced. Best aiming ever.
 
Is it ok, if I use botaim_mm code for my bot?

@$3.1415rin 05-12-2005 21:21

Re: BotAim 2 announced. Best aiming ever.
 
some illustrations about the aiming algorithm, currently working a bit on it to improve my practical differential equation skills ;)

http://joebot.bots-united.com/images...aiming-pgz.png

you see that the ideal position in blue always tries to approach the ideal value. but the interesting part might be the time after 5 seconds. you see that the position value is not able to follow the slope. only when providing the accurate ideal speed, aiming works perfectly.

this image has been produced using quite conservative parameters, therefore no oscillations and slow approaches, but this way the important part is easier to recognize :)

btw, even with some more oscillations and a "framerate" of 10fps, you see only very little difference between the method currently used and a higher order approximation :
http://joebot.bots-united.com/images...iming-rk4d.png

but if you take parameters closer to reality, you might get oscillations when having a low framerate. if you take a higher order approximation, you will have less oscillations like you see now :

http://joebot.bots-united.com/images...ming-rk4dr.png

ghost of evilspy's idea for storing a kind of vector field for each map representing the main movement directions and speeds sounds nice too, but you mostly aim at targets you already see, therefore you can get the speed information without being accused to have cheated directly :D

ghost of evilspy 05-12-2005 23:02

Re: BotAim 2 announced. Best aiming ever.
 
Quote:

Originally Posted by @$3.1415rin
ghost of evilspy's idea for storing a kind of vector field for each map representing the main movement directions and speeds sounds nice too, but you mostly aim at targets you already see, therefore you can get the speed information without being accused to have cheated directly :D

Well, that isn't what I meant.. but your idea would be great for wall gaussing bots 8o

Pierre-Marie Baty 07-12-2005 11:40

Re: BotAim 2 announced. Best aiming ever.
 
Ah but I understand better why Joe wanted to know the spring and damper coefficients that I use ! :D

Anyway these graphs are very interesting.

[NvT]_KaszpiR_ 08-12-2005 20:49

Re: BotAim 2 announced. Best aiming ever.
 
interesting topic :)

anyway notice that you are using the non discrete math in the explicly discrete task

i believe it is okay, but i assume there are some extra things that can be used to speed up the aim approximation - because of discrete math you can use easier or faster calculation algorithms.

Of course the first step is to implement the theoy into practice, but 'practically' you will end with more simple algorithms.


One more thing. Looking a the graphs and the program that shows the bot aiming (bot aim 2) i predict RACC will have bots with characters, where you can define such things like damping, spring etc, or the probability of the occurence of the time, that bot would prefer to eat pizza now nd steer with one hand :D


one more thing. i wonder how the aiming will be implemented - like, does the bot will treat every frame as a point of aiming or will get updates of enemy positions every XX mseconds (like player that gets the initial change of the player position few moments after the enemy moves (due to lage between wwhat we see, what our brain decides to do and the time the nerve impulses react to move the hand).

and another thing, i believe this can be hard to implement. Notice player does not have 'infinite' hand as bots (the limitations of the glidin furface like mouspad, or cable - man gotta toss mouse overn move it back, lay it down and move it again to continue aiming, especially the ones with low sens).
Also there is an issue of sudden movements (like inhuman turns). People got it sometimes too i bet you happened to kill enemy instantly because of the instinct reaction, especially when surprized )

anyway, the current algorithm is very satisfactory :D


All times are GMT +2. The time now is 18:27.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.