Getting Started with Google Football
Football (or Soccer) is the most popular sport on earth with over 3.572 billion people tuning in for the last world cup finals. It also is a unique AI problem due its continuous, multi-agent nature and a wide array of actions possible in every moment. Google Brain, a deep learning / artificial intelligence research team at Google, implemented a Football Environment for developers and researchers to experiment various Reinforcement learning models.
Apart from a regular 11 vs 11 match, Google Football provides various specific scenarios as shown in the below table. These are called Football Academy scenarios. We can train to model to master these particular scenarios. Furthermore it is possible to create custom scenarios which can be used to test algorithms and train various methodologies before implementing it in full game.
Creating a custom scenario
Let us now go through the custom scenario code in Kaggle Notebook provided by GFootball. In the below code, we are creating a custom game scenario where we are setting the game duration as 300 steps with offside rule disabled. Next up we are assigning players to both the team, with the both the team having goalkeepers and one team having an attacking player, while the other having a defender.
%%writefile football/gfootball/scenarios/academy_custom.py
from . import *
def build_scenario(builder):
builder.config().game_duration = 300
builder.config().deterministic = False
builder.config().offsides = False
builder.config().end_episode_on_score = True
builder.config().end_episode_on_out_of_play = True
builder.config().end_episode_on_possession_change = True
builder.SetBallPosition(0.3, -0.05)
builder.SetTeam(Team.e_Left)
builder.AddPlayer(-1.0, 0.0, e_PlayerRole_GK)
builder.AddPlayer(0.1, -0.1, e_PlayerRole_CF)
builder.SetTeam(Team.e_Right)
builder.AddPlayer(-1.0, 0.0, e_PlayerRole_GK)
builder.AddPlayer(-0.7, 0.05, e_PlayerRole_CB)
Next, we can train the model for the given scenario or use the default logic associated with each player present in the game. We can generate the video for the given scenario that we tested. In the below video we can see the output of corner scenario.