Archived

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

CTRL_ALT_DELETE

Pong AI

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
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