I have recently designed and programmed a pong game in lua (codea); where you can play in multiplayer and in singleplayer where you play against the CPU.
My problem is, I can have the CPU to play perfectly bat_cpu = ball_y
but that would not make the game a lot of fun.
Therefore I made a simple inaccuracy system to calculate where the ball will hit the CPU's bat:
bat_cpu = ball_y + inaccuracy
Where inaccuracy is defined earlier as:
inaccuracy = math.random(-40,40)
But the bat still follows the ball_y exactly and I want it to make mistakes, and not be so fast.
Does anyone know how to simulate the CPU bat so it makes some mistakes (on high speed, accuracy, etc.)