#### Archived

This topic is now archived and is closed to further replies.

This topic is 5530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is there any way to calculate the angle for a certain range?? This is my first time using C++ so I have no idea how to output the stuff req''d to find it (ie distance of enemy + experimental angle -> how far off)...I''ve been using a nested if structure (which works kinda okay except when it blows my bot up).. I understand that I am the enemy, but for the sake of helpfulness?? hehe? -------

##### Share on other sites
I made a polynomial to approximate it.. basically I tested the range at a variety of angles, and made a cubic best fit line in Excel... this was the result:

0.0002f*x^3 - 0.0622f*x^2 + 3.6339f*x + 49.691f

Note that sometimes the grenades bounce. this is only an estimate of the range. (x is the launch angle)

EDIT: obviously this gives the range for a given launch angle... you would need to inverse it, this is probably not good to do as it needs a cube/square root. You could obviously get a taylor expansion of the result.. or of course make a similar function for the inverse.

To output numerical info, I do this...

std::ostringstream output;
output<<(info to output here, to be converted to text);
Taunt(output.c_str());

So in your case, simply output the range of any grenade in view and it will appear in your bots speech output. To find out how you do this bit, read the readme. If you can't get it working.. then you probably need to work a bit more on your C++ skills before entering.

[edited by - dmounty on October 22, 2003 2:29:06 PM]

##### Share on other sites
Ahh... so that''s how it works...

Thanks for the equation, dmounty.. I''ll plug that in for my final version happily...

Best of luck finishing your bot! Looks impressive, and should rip if you code it all!!

-------

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013294
×