Friday 17 December 2010

An unexploited (out)field

Since the beginning of video gaming, baseball has always received some attention. The sport itself is basically the most suitable to implement an enjoyable experience for users. You pitch, some one swings and if the time is right, he hits the ball and run the bases.
Without bothering about baserunning or other more complex aspects of the game, baseball was amongst the first sports to be brought to the arcades in the 70s.

The beginning of the baseball videogaming era was made of pixels, unexisting fielding and it was still entertaining
But, how do baseball simulations deal with the always growing demand for accurate physics in games nowadays? And what about actual baseball aspects like outfield assists or pick-offs?
The best baseball game so far is MVP Baseball 05 from EA Sports, dated back to 2005. It featured the MLB license, a graphically poor interface and menus but an amazing difficulty level calibration and it came up with unique amusement for baseball maniacs, who still play the game.
The thing I have always loved about that game is that it embodies at perfection the real entertainment about baseball: hitting the ball. Depending only on the timing, you could end up with a Home Run or with a blooper, or with a groundball or with a line drive. This shattered randomness in a sporting simulation, and considering that often baseball is about great players struggling with unexplicable slumps, or viceversa, it made the game feel real, maybe for the very first time.

A Dodger missing the ball. He swung early, and you can say it by looking at the position of the bat compared with the green/yellow contact zone.
The overall experience with MVP Baseball 05 was addictive. To take your franchise to the World Series you really to work out every count, to adjust your batting order, to know all the rival pitchers. On the other side of the ball, even if the depth wasn't comparable with the one required to hit, the pitching worked well, by letting you select the pitch type you wanted to use, the location and employing the usual accuracy/power bar which had to be filled to a certain measure twice.

The pitching gauge used in MVP 05. Since the hitter is a National, I don't think he'll get it!
But, was the physics model accurate in the EA Sports game? No, it wasn't.
What was the difference between chasing an high fastball and a low changeup? None. Basically because you don't decide the height of your swing. Even if the game actually interpret every swing as something different according to the timing, you'll end up realizing what are the pitches that are most suitable to you, recognizing them and blast only them over the fences. I used to love changeballs, someone used to maybe keen on curveballs, someone else maybe on sliders. Tha fact is that, regardles of who your hitter is, you don't change your tastes. I made Ichiro look like a .100 guy, whereas I broke any record about triples with Juan Pierre, simply because the japanes has a specific and uncommon swing animation.
MVP needed to diversify a bit the hitting mechanics to be aligible for best sport simulation ever, on every system.

But, let's take a step back and think about how a pitch is thrown and how a ball is hit.
The baseball, like the one we see above, is thrown from a certain position (release point expressed in terms of a vector x-y-z) according to pitcher's pitch dynamics and features. Cliff Lee has a different release point than Roy Halladay or Felix Hernandez.
It has an initial speed, which is the one revealed by measuring instruments on the field, which varies, at MLB level, from 50 or 60 to 107 mph. This speed needs to be divided into a velocity vector (x-y-z) which is calculated according to the release point.
Then, it also has a backspin (top spin) or/and a sidespin, given by the pitcher, who is unlikely to throw the ball perfectly still (unless he is Tim Wakefield or one of those knuckleballers).
So, we got 8 variables coming in: vertical angle, horizontal angle, speed, backspin, sidespin and the coordinates of the release point, which usually doesn't get any lower than 80 % of the pitcher height and not lateral to the mound.
In time = 0 we can then have the velocity vector, let's call it V0.
The ball is, in air, trapped between two different air flows, one above it and one underneath. These are regulated by the spin set by the pitch. To calculate the trajectory of a baseball for each time frame, we need to calculate the velocity vectors V1, V2, Vx and then the positions, call them P1, P2, Px.
To do so, we need to have the acceleration vector (in x-y-z) for drag force (gravity), growing when the ball loses speed, and for  lift force, the Magnus effect injected by the ball spins, which carry the ball towards a certain spot.
In this big pan with all our variables and forces coming in, we need to put temperature, the ball circumference, the air density (Coors Field anyone?).
What all games have done so far is to let the player select the type of pitch to throw, integrate its trajectory with the release point and the target he set, and calculate the positions. Now, MVP Baseball 05 looks a bit lazy...

I spent the last couple of weeks (let's say ten days) studying a spreadsheet by Prof. Alan Nathan of the University of Illinois, and trying to make a physics engine out of it. Would you believe that the results I got were more brilliant and much more realistic than the one EA had with the MVP engine? I was able to replicate fastballs, curveballs, sinkers, sliders, and test what happens if you allow incredibly huge amounts of spin to be applied to the ball (alienballs).


Is it really in the game?
So, we spotted another of an infinite list of fakes with which companies fill their games, but there is something more. What about batting? We left that speech about having a timed contact but not a technical one...
Well, if you know where the ball is going to be when the bat is hitting it, and you know the actual velocity vector associated to it, you can just flip the velocity component for the acis normal to the strike zone and obtain a rebound which does not alterate the trajectory.
Let's say we want to add the feature that the batter user can choose an height for his swing. It is enough to trap the bat into a bounding box and rotate it along its axis in the direction of the ball, to achieve a realistic collision detection, and then recalculate the trajectory finding the impulse applied to the ball by the batter. Now I'm getting confusing, but the principle is easy to understand, and to implement.
Nonetheless, we would end up with a fine realistic game, where all the measures are calculated in high fidelty and reflect their actual counterparts.

A ball perfectly hit. That's what happens all the time in MVP baseball, far from reality.
There is still one question to be answered. Why companies keep on delivering poor baseball games, so that we have to stick with MVP? I'm not so vain to say that I'm better than them or that I have a better understanding of baseball than their consultants. So, there must be another reason.
The answer is quite simple. Do you remember the first picture I shown in this post? That is the answer. People wants to hit the ball, to run the bases, to slide to save a triple, to assist from the outfield, to strike you out. They only think they want a precise simulation, but they don't. They just want to get back to the backyard with their father and throw the ball or receive with the glove.
At EA they wanted to deliver an entertaining game, fake it was realistic and make some cash. The last thing was not achieved, but the first two were a success. I will never be grateful enough to them for this, but I also would like to analyze the impact of a real simulation on the amusement mechanics. There will be time for this, I hope.