[This is Part Two of a two part article, discussing the AI and other aspects of development of EA Air Hockey. Part One, discussing one-button design, can be found here.]
One-button AI
Early in development, the AI was quite a simplistic affair. It would pleasantly take shots back at you, without any real strategy or tactical analysis on its part. In fact, this played just fine, but it was decided that we needed to up the AI intelligence level so that those non-casual gamers could be presented with more of a challenge. It would have been easy enough to cheat and give the AI abilities that the human player does not have (in terms of positioning for shots, etc). However, I decided to "take the high road" and make the AI follow the same rules as the player (more or less). What I did was to make the positioning of the AI player's mallet 100% identical to the player. So, the AI mallet would do the oscillating arc movement, etc. This left just one problem to solve, "when should the AI take a shot?". What I did was to periodically calculate the result of an AI shot. The frequency of this evaluation was proportional to the smartness of the AI, and is one of the main factors between the three difficulty levels offered by the game. During the AI shot evaluation, various statistics are collected, obvious ones such as whether the shot is a scoring shot (or a home goal!), but also additional stats such as how many bounces the puck will take, whether the puck hits the other player's "goal line" and so on. These are then fed into the AI logic, and filtered using the current "mindset" of the AI, which changes according to a table of "moods" defined for each difficulty level. As an example, some AI moods dictate that only direct scoring shots will be considered, others that only indirect scoring shots will be considered, and yet others that appraise a shot positively if it merely hits the player's goal line. By stepping through AI moods, and using different tables of moods for different difficulty settings I was able to implement a scalable and challenging AI.
Referring to the AI moods - these are named "banker", "acer" etc in the source code as there was some initial thought to surfacing the AI opponents with characterizations, as has been done with other tables sports games (pool, etc). In the end, we did not go down that road, but it would make a nice addition if there's ever an Air Hockey 2.
One-button Gamesmanship
Gamesmanship is the act of "gaming the game". In other words, it is the use of tactics that exploit a weakness in a particular game's design to the advantage of the player. In this case, there was one such issue which pervaded the testing process - "button-mashing". It was discovered during the testing process that by "mashing" the button (ie, repeatedly pressing the button as fast as possible) it was possible to effectively block the AI. This did not give the player an unfair scoring advantage directly, but since the AI would not retaliate in this fashion (one possible solution was to make the AI button-mash in response, but that did not seem very satisfying), the AI was prevented from scoring and the random goals scored by the player while doing this resulted in player wins. It's an interesting problem, and it's something that would not happen in real life - if you were to employ this tactic against a human opponent, your opponent would simply slap you upside the head. This is generally borne out in EA Air Hockey's 2-player mode - not (that I've witnessed) the head-slapping, but the fact that humans tend not to try to game each other in the same way as they would with a computer opponent. With regard to the button-mashing, part of me felt that if a player wanted to game the game in this way (futile as it would be to do so) then so be it. But the another part of me felt challenged to address this. In any case, after a while the folks in QA were complaining so loudly about this "flaw" that something just had to be done. I ended up trying many different solutions, but QA proved very adept at poking holes in any anti-mashing defenses, so I just had to keep trying different things. In the end, the solution turned out to be in-keeping with the design of the game. What I needed to do was step back, and think a little about the "real" Air Hockey, and some of the physical realities of playing the game. What I realized is that when, in the real game, a player goes to make a shot from the center line, they will physically have their playing arm at full stretch. Accordingly, shots played from the center line (that is, shots that originate when the player's mallet is at or near the center line) will of necessity be lower-powered. This was simple to model, and fed nicely into the "shot strength" dynamic described above. The result is that button-mashing will still cause the player's mallet to hover around the middle of the table, and this will still potentially "block" the AI, but the resulting blocked shot will be very weak, leaving the AI plenty of time to counter, and get a shot past the player.
One Button Per Player, Two Players Per Game?

Two-player mode switches to a top-down perspective
where players controls one button.
When I started work designing EA Air Hockey, I'd been given a mandate by Zack Norman that the game must feature a two player mode. Initially, thoughts were along the lines of doing a split screen, with each player having his own "perspective" view of the the action. Ultimately, I implemented a top down view, which was more satisfying for a number of reasons. With the top-down view, I was able to orient the table sideways, so that two players could hold the phone between them. Then, to play the game, player 1 (at the right hand side of the screen) would use the ‘6′ button, and player 2 (at the left) would use the ‘4′ button. Each player has the exact same controls and in effect the phone is treated like a miniature arcade table.