Creating and Running the Tetris Game
Learn how to create a tetris agent and then use that to run the tetris game.
We'll cover the following...
Creating a tetris agent
Before we can get started evolving Tetris agents, we need to download a copy of an Atari 2600 Tetris ROM. Fortunately, the ALE repo offers the official Tetris ROM. Atari 2600 ROMs are also available from a number of websites. If the contents of a ROM are of concern, the checksums of supported ROMs are accessible here.
Note: This has already been done for you in this course.
Once tetris.bin
is downloaded, create a new folder named priv
and place tetris.bin
into it. Next, in tetris.exs
, create a new problem:
defmodule Tetris do@behaviour Problemalias Types.Chromosome@impl truedef genotype, do: # ...@impl truedef fitness_function(chromosome), do: # ...@impl truedef terminate?(population, generation), do: # ...end
Now let’s get started encoding the problem.
TheTetris AI will need to perform a series of actions that change the game state. Recall that Tetris is a game where tiles fall into the playing field until they stack on another tile or hit the bottom. If the tiles are stacked such that they create a horizontal line filling the entire playing field, all of the blocks on the horizontal line disappear, and the player is awarded points.
In Tetris, the player can choose to move left or right or ...