ID:2216839
 
I'm working on a Pong game the old atari(arcade) style that everyone "Should" know

i got the ball and the AI to move the Ai right now moves by following the ball if the ball goes up the AI goes up etc etc


Problem description:

1. How would i go about making it so the AI doesn't just follow the ball but has random movements but still in way will follow the ball this way YOU can win because right now since the AI follows the ball it hits the ball every single time.


2. right now there is 1 set speed for the ball i would like there to be more like if a player hits the ball smashing it corner wise into the corner of the wall it adds speed to the ball but the more times it hits a wall the less speed.



Show us your code for making the paddle follow the ball and I can provide more relatable help, but in pseudo-code.

var/seeking = rand(-2,10)/10
var/height_dif = paddle.y - ball.y
step(paddle,NORTH,height_dif*seeking)


That'll mean that 2/13ths of the time the paddle moves the wrong way, 1/13th of the time it won't move, and the rest of the time it'll pursue the ball.

Personally I'd implement a "max speed" and ensure height_dif*seeking was limited to it, and I'd then make the AI a little smarter by taking the velocity (speed & angle) of the ball and work out where it's headed, and move towards that point rather than where the ball is now.


For question 2, play with step_size :)