Most games these days have some kind of AI — Artificial Intelligence — for human players to fight against. But just how strong should your game’s AI be? Make it too strong and you discourage players; make it too weak and the game will be boringly easy to win.
A popular solution is to put up an easy/medium/hard/insane switch at the start of the game so the players can choose for themselves. But that means burdening the player with a choice they may not be prepared to make. How on Earth am I supposed to know if the “easy” is not too easy for me? Or if the “hard” is even worth trying at my level of skill?
Truth is, people don’t want a uniformly smart or uniformly silly opponent. Instead, what they want is an opponent who is engaging. An ideal opponent should match your individual skill: sensing how good you are, it should be playing more or less at your level. Sometimes it would deliberately yield (but never own up, of course!) and sometimes it would challenge you, but overall it would let you progress: not too fast and not too slow — at just the right pace.
In a word, the perfect AI is as smart as needed to keep you interested in the game… for arbitrary values of “you”
That’s the approach we’re taking with our new shuffleboard-like game, BATTLE OF THE PUCKS. The goal of the game is to shove one of your pieces so as to drive the enemy’s pieces off the board without losing any of yours. And for this kind of game, the AI can be pretty straightforward: it simply runs simulations of a number of randomized shots and chooses the shot that scores best. Already at a few dozens simulations per move, the computer player is virtually unassailable for humans.
However, In BotP, the game’s AI spends more of its spare cycles on measuring the optimality of your moves than on calculating its own. Again, the way it does this is by running multiple simulations of the human opponent’s every move and its randomized variations:
If the human didn’t score, just how inapt their move was — how far was it from the nearest move that would score? Beginner players’ moves tend to be farther off the mark than those by seasoned players.
If the human did score, how difficult it was — how many of the move’s randomizations would have resulted in the same or similar score? If you make a move that scores a ton, but any slight deviation from it would have lost badly, then it might be that you were just lucky — but a more reasonable conclusion is that you play this game very well.
Taking a weighted average of several of your last moves, BotP constantly adjusts its depth of foresight and precision of strikes to match the level you play at. As you master the game, your AI opponent becomes stronger too — never too easy but never too formidable.
It also matters how to weaken a too-strong AI. Perfect unfailing precision is boring, but so is perfect randomness. If you simply add a random fuzz to every AI move, it won’t be very engaging: that might feel mechanically stupid, not humanly stupid. Instead, we’re giving our game’s AI a character of its own that regular players will soon learn and relate to: a variable-but-remembered preference for certain openings, certain directions, certain ways to hit. We humans like entities that we can relate to: entities with their own faces, their own quirks, their own weaknesses that we can learn — and exploit!
Finally, even with the best adaptive AI, it is important to avoid monotony. Having determined the optimal level of smartness, sometimes the program would make a move well above or well below that level. Surprises make the life worth living! Sure, that sudden superstrong move of your opponent — erasing half of your army with a single hit — was a bummer… but, hey, wasn’t it beautiful! And soon after that, the AI’s amazingly inapt misstrike when you least expected it, just when you were prepared to lose the game… but went on to win… ooh.
Yes, I want to Play Again!
Wanna try? BATTLE OF THE PUCKS is now available for pre-release testing! Please comment or PM us if interested.