# Trying to model pinball physics for game AI

I'm working on an AI for a pinball-related video game. The ultimate goal for the system is that the AI will be able to fire a flipper at the appropriate time to aim a pinball at a particular point on the table. We are using an engine that will handle the underlying physics interactions when the ball is hit (Unreal). I'm trying to quasi-realistically model the physics for the AI's "thinking".

I have a reasonable understanding of Newtonian physics but I'm going to need some help making sure I'm correct about everything I may need to account for. For the purposes of simplification, I'm considering the table to be vertical on an XY axis with gravity just being a small fraction of actual gravity accelerating down on the Y axis (yes, this means I'm ignoring friction between the ball and table, for now).

By my understanding, I've got the work with the following when a ball is rolling along a flipper.

• The ball will have velocity along both X and Y axes as it rolls to the flipper.
• The flipper will have a range of motion (minimum and maximum angles) and a Torque value.
• When the flipper fires, it will apply force to the ball based on the flipper's Torque, the distance the ball is from the flipper's rotation point, and the length of the arc the contacted point on the flipper needs travel.
• The applied force will accelerate the ball back up the table following a new trajectory.

My question(s) are: Am I overlooking an important interactions in this system? Or am I misinterpreting anything? Does it seem like this is a reasonable modeling for video game? Et cetera?

Thanks!

-

When the ball is hit with the flipper, two velocity components should be considered: parallel to the flipper $v_{\parallel}$ and perpendicular to it $v_{\perp}$.

$v_{\parallel}$ will change if the ball is spinning - as Luboš said, this definitely should be included in your model. You can start with a crude approximation $\Delta v_{\parallel}\propto \omega$ for $\omega<\omega_0$ and $\Delta v_{\parallel}=const$ otherwise. $\omega_0$ would be the ball angular speed at which it starts to slip.

$v_{\perp}$ changes its sign (elastic collision) and gets additional kick from the flipper: $v_{\perp}=-{\gamma}v_{\perp}+v_{flip}$, where $\gamma$ is elasticity coefficient close to 1 and $v_{flip}=\omega_{flip}r$, $r$ is the distance from the flipper axis to the point where the ball hits it.

-

I would need to see - and understand - your code but it is not clear from the text whether you also remember and take care of the rotation of the ball - its angular frequency (and the internal angular momentum, which is proportional). I am convinced that this is totally necessary to get some realistic dynamics and it's where most of the pinball fun is all about.

In typical situations, the ball is rolling on the table without any "creeping" but this condition still allows the spin around the axis transverse to the table. This ball obtains this spin when it's hit (or when it collides) from the side, and when it hits another object while it's (the ball is) spinning, it will reflect in a direction that is influenced by the spin. Tennis players etc. are using the spin to confuse the opponent all the time.

Moreover, I am not sure whether the flipper gives the ball a fixed torque - as opposed to a fixed "power" in the normal direction (transverse to the flipper's tangent near the contact point with the ball) or some other function or a fixed "velocity" in the normal direction (doesn't it just achieve that the ball's normal velocity away from the flipper ends up being equal to the flipper's high velocity?)

At any rate, I think that the degrees of freedom in your approximation are really simple. If the ball moves along the plane and never jumps, then there are 2 components of the velocity and 3 components of the angular momentum. Two components of the angular momentum are, however, determined by the condition that the ball is rolling not creeping. The y velocity is accelerating as you said and the spin is conserved unless the ball is in the contact in which case you have to calculate the right force and torque.

-