I'm making a pong game for my software development class, and I should probably state that this is homework, hence my limited understanding. and I'm having some problems creating the AI for my NPC paddle. I'm using Kivy and Python.
Currently I can create impossible to beat AI by doing this:
self.player2.center_y = self.ball.y
"Every x seconds, the paddle will move x pixels in the y axis."
def serve_ball(self, vel=(10,0)):
self.ball.center = self.center
self.ball.velocity = vel
game = PongGame()
self.AI_Speed = self.ball.velocity - 10
Since this is such a big question, I haven't tested this out or anything, but it seems like you want to have some sort of function that moves the AI (I'll call it self.player2.move()). If you call this function in game.update(), then you should be able to move the AI paddle incrementally closer to where it needs to be to hit the ball.
Some basic pseudocode for self.player2.move():
figure out if ball is above or below paddle move self.AI_Speed units in the direction of the ball
You might need to adjust the AI speed more to make this work, but I think it should be the right general idea. If you think about it, the unbeatable AI is basically just infinitely fast.
Does that help get you unstuck?