🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

a pong AI question

Started by
1 comment, last by toxicity 22 years, 5 months ago
I''m trying to make a simple pong game in vbasic/dx7... how do I make the computer follow the ball so he can hit it back towards me? I know this is AI, but I''m not sure how to do it.
Advertisement
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!

-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
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.

This topic is closed to new replies.

Advertisement