back

by emptybits·9y ago·view on hn ↗
I was a programmer on several baseball games on Playstation (1) & Windows. Among my duties was AI. That meant consuming, encoding, and deploying a lot of historic stats. They'd be sliced and grouped and accessible across interesting combinations of team, opposing team, player at bat, player pitching, players fielding, stadium, inning, absolute score, score difference, time of day, and really just a fascinating set of inputs. We'd license the historic stats.

Baseball is a game of obsessively recorded stats anyways, and we'd use that to our advantage to model pitches, plays, games, seasons, etc. into something that 1) reflected what truly (historically) would/could/should happen in a given scenario, and 2) was fun and kept the player coming back for more. (Or else we'd hear about it in reviews!)

Well, turns out #2 is really, really important. Playing to statistical misunderstandings had to be part of the consideration. "That pitch/play/decision/outcome would never happen as often as it does! Fix it!" a producer with more baseball knowledge than I would claim. "It's happening exactly as frequently as it does/has historically," I would counter. Doesn't matter. Games need to be enjoyable and that means playing to common (mis)perceptions even if they're statistically wrong. But not too wrong. (Or else we'd hear about it in reviews!) :-)

3 comments
As a sibling comment mentioned, if you ever long-formed this I'd love to read it (and I'm not even a huge baseball fan!).
Is there in general a formula for fudging statistics in the direction of bias? I.e., 90% becomes 99% as 10% becomes 1%? Was there a general algorithm you used. I'd be interested in hearing the technical details.
What you describe (non-linear) would probably have been superior but in my youth and inexperience over 15 years ago (and pressed with time and code-size constraints) I am sure I did nothing more than a scalar, maybe clamped with a C macro MAX() or MIN(). Sorry to disappoint; sometimes game AI and sim work just needs to be "good enough" and ... most importantly, needs to ship on time (on shelves, yes shelves, X weeks before opening day of baseball season) with zero bugs (no online patches in those days). So there is a certain satisfaction in that. :-)
Thanks for the reply.

I came up with:

f(x) = (sin((pi * x) - (pi / 2)) + 1) / 2 where x is between 0 and 1

I'm a collector of randomness functions for games. Weighted, gaussian, linear, etc. This sinusoidal randomness will be handy! Thanks for the inspiration.

As a baseball fan I'd love to hear a little more about this if you have the time.