.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   Bot Aiming (http://forums.bots-united.com/showthread.php?t=3179)

Whistler 26-12-2004 03:29

Re: Bot Aiming
 
1 Attachment(s)
this is something in Michael Booth's docs about the official CZero bot, it seems to be different from the above algorithm, also I don't quite understand it

(the greek characters just messed up if I post it as text so I have to post it as picture)

@$3.1415rin 26-12-2004 12:21

Re: Bot Aiming
 
ok, he looks at the speed, which isnt a bad idea neither. It's pretty similar to my code, but in my code k and d are a directly related ( k = 1-d ). looks a bit scary though since dw is normally used when having differentials, which he does not ... anyway, might be a simpler way to go, avoiding this time expensive log / exp stuff when calculating time independant angels instead of their derivatives. gotta put that to my win32 aiming test application :)

Pierre-Marie Baty 26-12-2004 15:29

Re: Bot Aiming
 
Quote:

time independant angels
Feeling metaphysical, aspirin ? :)

@$3.1415rin 30-12-2004 23:16

Re: Bot Aiming
 
didnt knew my own code that well ... my code actually is the same, just that I think there is the need for framerate dep d and k

@$3.1415rin 31-12-2004 11:17

Re: Bot Aiming
 
if you run around a bot using this aiming algorithm with a constant angular velocity, you won't be hit ( if momentum, speed are not at instant aiming and the bullet spread isnt that big :D ).

some more info : http://johannes.lampel.net/joebotxp/botaim/index.html

the difference between the current angle will stay at a constant value, see diagram 1. This difference is related to the speed as (1-c)*currentSpeed. Thus the last diagram is the corrected one, which should allow a bot to kill you when you are running around a bot :D. so just a bit of correction is needed, and of course a local storage of the current state of the algorithm, before correcting :)

Code:

float a=.95,  // momemtum
 idealSpeed,
 c=.02,  // overall_speed
 aNow,  // recalculated momentum based on framerate
 fADiff;
float fmsecCount50 = m_fmsecCount / 50.0f;
float fAngleChange;
fADiff = abs(m_VIdealAngles.y - m_VCurrentAngles.y);
if(fADiff>180.0f){if(m_VIdealAngles.y > 0){m_VIdealAngles.y -= 360.0f;}
 else{m_VIdealAngles.y += 360.0f;}}
// compute the ideal angle speed (i.e, the amount of turning we WOULD want to do)
idealSpeed = (m_VIdealAngles.y - m_VCurrentAngles.y);
idealSpeed = idealSpeed*c;
// compute the new momentum given the previous one
aNow = exp(log(a) * fmsecCount50);
// compute the angle speed (i.e, the amount of turning we will actually achieve this frame)
m_fAngleSpeedYaw = m_fAngleSpeedYaw*aNow + idealSpeed*(1.f-aNow);
// calculate how big the actual angel change is
fAngleChange = m_fAngleSpeedYaw * (fmsecCount50);
m_VCurrentAngles.y += fAngleChange;
// ((1.f - c) * fAngleChange) to compensate 'shooting behind enemy'
m_pEntity.getEntity()->v.angles.y = m_VCurrentAngles.y + (1.f - c) * fAngleChange;

at least it's better than before, but I gotta test it in more different situations ... testing aiming inside the game isnt funny :)

@$3.1415rin 04-01-2005 17:20

Re: Bot Aiming
 
the more i think about this exp log stuff, the less sense it makes ....


All times are GMT +2. The time now is 12:38.

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