# Tank wars sorta game

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

## Recommended Posts

Hello everyone, I am finally throwing in the towel and asking for some direction on how to write the AI for my tank wars /scorthed earth sorta clone. I know I need to simulate how the computer sees the map to determine the best angle / power to fire with but I cannot seem to figure out the best way to do this. I was thinking of drawing a sort of porabola for the computer and checking if it collides with the terrain and than adding fuzzy logic but this seems like it would be extremely slow.

Can someone point me in the direction of not an implementation but maybe a further explanation of how this has been done.

Here is a screen shot of my game;

I have the AI determining which target is the closest and facing that way, its just the step of figuring out the power / angle without colliding with terrain that I need some direction.
Thanks.

##### Share on other sites
You have to look at projectile physics. Pick an angle first. If you know or can guess how long it will be in the air, then you can figure out something like:

tank_x + airTime*(x) = tank_x_2;

Find x. Then you can find your power needed to make it come out with that speed along the x direction.

Or just guess. Take a fixed angle such as 45 degrees. Guess that the power should be something based on the distance to the other tank. Power = distance*(constant)
Shoot it,see if it lands in front of or behind the other tank. Adjust power +/- from there.

##### Share on other sites
Thanks for the reply.....I like your first reply...it was along the lines I was thinking but I was thinking of it too visually where as your description is more of mock approach and should be much faster than actually drawing a texture and checking pixel collision.

Thank you I will try that out.

1. 1
2. 2
3. 3
Rutin
25
4. 4
5. 5
khawk
14

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

• Total Topics
633649
• Total Posts
3013117
×