Games and AI

Why Are Algorithms so Good at Playing Games?

About one and a half year ago, one of the greatest chess players of our time lost his winning streak after 125 games. That’s a new series record. His human opponent could barely believe his luck. But wait…luck in chess? Is there such a thing? It’s pure strategy, skill and drawing patterns. Isn’t it?

Well I’m not a chess expert, to be honest, I’m quite bad at it. But what this headline triggered in me was a quite simple thought: Might this strategical principle be the reason why computations already beat the world’s best chess players over two centuries ago?

  1. It’s a deeply anchored game in our western history, culture and tradition. People have been playing it for centuries and follow the same rules ever since.
  2. The game is mainly based on the strategical behavior of the two opponent parties.

These two characteristics made it easier for machines to learn how to play these games with perfection several years ago. There was a single goal, dedicated to being reached by the algorithm: winning within this set of rules. These games are mainly input-output based and there is no such thing as randomly picking a card out of a deck, rolling dices, or rule adaptions during the game. It was a “simple” baseline to compete in these nevertheless complex games. The next decision was made round by round and as a response to the decision of the human opponent. It would be even predictable how the player would react based on the last position of figures. I mean, that’s what we all try to do when playing chess, right? Think ahead. Try to read our opponent’s mind to find out what the next decision could look like.

Talking about decisions: That’s mainly what we use the whole realm of algorithms for in our business and scientific life right now. Everybody is talking about making better choices based on data, models, predictions, KPIs, and preferably with some sort of AI sprinkled over it. What the whole effort should lead to, is mainly optimized behavior of the company. But the rules of a globalized economy are much more complex than the possibilities a chess figure offers regarding their movement.

What comes much closer to our real world are: video games. The developments of the last years are phenomenal. From turtles walking five steps from one side of the screen to another to complex, individually and fast-moving targets in almost every modern game design. And their decisions and behavior are always based on the outcome of an algorithm.

Types of Gaming Algorithms

There are three main types of algorithms creating the behavior of every object on the screen, even applicable for a chess simulator on Windows 95:

Steering Algorithms

Steering algorithms: Gives the direction a computer-controlled character moves towards until it reaches its goal. This might be the finish line of an F1 race or the next cover of the player’s attack. What the steering algorithm does is, it constantly changes the priorities between seeking a reward (e.g., items, chasing the player), flee from danger and avoiding obstacles. Especially avoidance is deeply connected with the next algorithm type.

Pathfinding Algorithm

Ever wondered why this bot is running against a wall repeatedly? Well, that’s when pathfinding was not in the game yet. Pathfinding can tell the bot where it finds some free space to go to. That’s mainly based on a negative map of the game environment. “Negative” means that walkways are highlighted against gaps where no character can move through. The task of the algorithm now is to find the fastest way to the current goal and keep cover at the same time, for example.

Goal-Oriented Action Planning Algorithm

As I said before, always think ahead and optimize every action in regard to your goals: set your opponent check mate. We already clarified how the computer-controlled character navigates the game’s terrain, but all this has one simple reason: the action that follows. It might be the plan to overtake the player and keep that position until the end of the race for example. But that action must be specified, and all the other algorithms must follow this single plan.

Conclusion: AI and Algorithms love gaming

All in all, algorithms are mainly good at games, because they are designed to be. They have a dedicated and specialized duty and are optimized to fulfill this duty. But what really makes them an eager opponent is that they can brilliantly work together, if needed and orchestrated. That way, they can change tactics and prioritize their way of giving the players a hard time. But it is still a game with logic, rules, walls and fields, accessible and not accessible areas. Everything in this environment is set up to work in a specific way. That’s why algorithms are so good at games, games did not discover how to simulate “chaos”. But if they do, I guess we humans have quite an advantage. Because we are adapting to the changing circumstances of our environment daily. By rescheduling meetings, navigating politics, organizing events, adapting to new requirements at work or deciding spontaneously to go out for dinner because our fridge is empty. Let’s keep that up and win the upcoming games!

Photo by Pixabay on Pexels

Back to top