Artificial intelligence applied to the videogame world may seem of secondary importance, however I decided to talk about it in this post, because the video game market is of extreme interest also for business instead.
We are talking about a continuous growth market with an average annual CAGR (Compounded Average Growth Rate) expected in the range of 8.3% give or take.
It is also a pervasive market involving the use of various kinds of devices, from desktop PCs to smartphones, to optimized gaming console.
How can we use machine learning for gaming applications?
The applications are several, however to summarize we mention here below just two of extreme interest:
- Use machine learning techniques to implement artificial intelligence solutions capable to emulate players with or against whom to play (teammates or opponents).
- Make the game more dynamic and interactive.
There are also some potential pitfalls in the adoption of AI for video games: one of the greatest is probably the risk of emulating intelligences too “distant” from human behavior. The risk is to bore the players or – even worse – put them in front of too perfect artificial opponents against whom it is almost impossible to win.
Remember that video games are generally designed to stimulate players by presenting reasonable and above all gradual levels of difficulty.
As far as Machine Learning techniques are concerned, the typology we can consider whenever we would like to emulate a video game behavior is likely the reinforcement learning.
Unlike supervised or unsupervised learning, reinforcement learning acts without knowing the outputs (therefore there is no the training phase typical of supervised algorithms), instead it uses state machines (mostly based on Markov processes) thus to associate the transition from one state to another based on rewards or penalties.
I recommend taking a look at the article by Mauro Comi, data scientist who has deployed a nice example of a game where a snake grows in size as it eats food, but must be careful to not “eat himself “!
The code uses reinforcement learning algorithms to take decisions, that is to establish the snake’s next move according to its status.
What I found extremely interesting is that the state machine is not defined simply deployed with a classic table matrix, but by using a “Deep Q-Learning” algorithm or a series of nodes of a neural network built with Keras:
model = Sequential()
model.add(Dense(output_dim=self.first_layer, activation='relu', input_dim=11))
model.add(Dense(output_dim=self.second_layer, activation='relu'))
model.add(Dense(output_dim=self.third_layer, activation='relu'))
model.add(Dense(output_dim=3, activation='softmax'))
opt = Adam(self.learning_rate)
model.compile(loss='mse', optimizer=opt)
There are three fully connected deep learning levels in addition to an output level to define the snake’s actions in the video game. Usual non-linear activation functions like relu and the softmax for the output are also used.
More information on the source code is available here.
Seeing is believing!
Interested in learning more about Machine Learning and AI application?
Here you can find a book about it:
https://www.amazon.com/dp/B08GFL6NVM