Archived

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

Pong AI

This topic is 6162 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
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