Jump to content
  • Advertisement

Archived

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

CTRL_ALT_DELETE

Pong AI

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have created a small pong clone. The way I have the AI working now is that when the ball is heading towards the computer''s paddle, the paddle follows the ball (just 3 if statements comparing the balls position to the paddle position). THis causes the computer to usually hit the ball. It works fine, but I was just wondering how the pros would do it. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
The speed with which the paddle moves can be dictated by the difficulty setting. I have never seen it done any other way, so I''d say it was fine to do it the way you''re doing it.

Share this post


Link to post
Share on other sites
If your pong is like most, then the ball moves in straight lines and bounces in a "perfect" fashion. This should enable the computer opponent to precalculate where the ball will end up quite accurately (trigonometry) and position the paddle there. It can update as the ball approaches and goto the follow the ball mode when the ball gets close enough to the paddle. On the way away from the computer, the paddle might return to center or follow the ball or something else.

Share this post


Link to post
Share on other sites
Or if you want to be evil you can make the AI try an hit the ball at the very edge of its paddle for that evil angle high speed shots of doom lol.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!