Archived

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

a pong AI question

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

If the paddles are on the left and right sides of the screen, the ball moves up and down. That should be all that the computer cares about.
There are a number of ways to do this:
1) If the ball is above, the AI paddle should move up. Same for below.
2)If the ball moves up, the AI should move up as well. Disadvantage: if the paddle is already above where the ball will go, it will not seem too intelligent.
3)The AI should determine where the ball is going to intersect with the paddle''s area. Then the paddle should move in the direction needed, either up or down, until it hits that point. Now, the problem is setting the speed so that it is possible to beat the AI, but that shouldn''t be too hard to implement. Also for this type of AI, you would also need the left right movement of the ball.

Hope this helps!

Share this post


Link to post
Share on other sites
The easiest way to make a simple ai for a pong game is to have the computer head in whatever direction the ball is. By this I mean, if the x-coordinate of the ball is less than the computer, it moves left, if it is greater, it moves right. The problem is that if the computer''s speed is too fast, it will be impossible to beat it, and if it goes too slow, it will almost never win. Another way of doing it is calculating where in the computer''s ''end zone'' the ball will end up when it gets that far, and have the computer go there. The latter method gives you a better playing computer, while the first one is easier. I''m sure there are others, but those are the easiest.

Share this post


Link to post
Share on other sites