...

/

Creating and Running the Tetris Game

Creating and Running the Tetris Game

Learn how to create a tetris agent and then use that to run the tetris game.

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:

Press + to interact
defmodule Tetris do
@behaviour Problem
alias Types.Chromosome
@impl true
def genotype, do: # ...
@impl true
def fitness_function(chromosome), do: # ...
@impl true
def 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 ...

Access this course and 1400+ top-rated courses and projects.