Need Pong AI help

BlitzPlus Forums/BlitzPlus Beginners Area/Need Pong AI help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm having 2 troubles with the following code. First the AI bat will move faster than the speed I have specified. And second it always hits the ball.
Function MoveCpuOpponent(player2.player,ball.ball)

hit_chance = Rnd(1,4)
 
	If ball\y > player2\y And player2\y < 525 Then 
		player2\y = player2\y + 4
			If ball\y = player2\y And hit_chance = 1 Then
				player2\y = ball\y
			Else player2\y = player2\y + 4
			EndIf 
	EndIf 
	
	If ball\y < player2\y And player2\y > 55  Then 
		player2\y = player2\y - 4
			If player2\y = ball\y And hit_chance = 1 Then
				player2\y = ball\y
			Else
				player2\y = player2\y - 4
			EndIf 
	EndIf 
                                                             
	
End Function


If I created a timer to slow down the executuion of the code would that help or am I totally off the mark here?

I have Seedrnd Millisecs() at the beginning with the graphics command,etc..

Thanks