Skip to content
Slothsoft edited this page Feb 27, 2019 · 7 revisions

The Tetris challenge project is exactly what it says on the tin - a couple of classes to create a simple Tetris GUI which allows for anyone to create their own AI (artificial intelligence). Well, maybe not anyone, you need at least a basic understanding on how to program.

There's a FAQ on how to use the API.

Table of Contents

Getting Started

  1. Prepare an IDE of your choosing (I'm using Eclipse, but honestly I can't blame you if you use something that works); if you need help, look here
  2. Create your own clone of the Git repository: and import the project; if you need help, look here
  3. Create a new class that implements StonePositioner and put it into the folder de.slothsoft.tetris.contrib
package de.slothsoft.tetris.contrib;

import de.slothsoft.tetris.*;

public class MyStonePositioner extends AbstractStonePositioner implements StonePositioner {

	public String getDisplayName() {
		return "My Stone Positioner";

	public void position(Context context) {
		// TODO: use context to move stone

Your AI is now ready to be used!

Starting Points

Now that you have an AI of questionable usability, let's take a look at which class to start. There are three so far:

  • Tetris - starts a GUI for you to see how your AI performs (you can either change the used StonePositioner in the application or programmatically by setting Tetris.POSITIONER)
  • TetrisBatch - starts thousand games of Tetris to see how the AI performs in the long run
  • TetrisHighscore - starts thousand games of Tetris for all the AIs to see how your AI performs compared to others



These are the fundamental classes I used to create the application:

The Board is the place where everything happens. Stones are similar to it in that they are made from Blocks, too. But in contrary to the Board they get dropped into the well. Both the Board and the current Stone are made public in the StonePositioner.Context, so that you can use it.

I'll add JavaDoc later as needed, and the FAQ shows concrete code examples.


The scoring can be found in the EventHandler class and is as follows:

  • 1 line removed: 40 points
  • 2 lines removed: 100 points
  • 3 lines removed: 300 points
  • 4 lines removed: 1200 points

The Challenge

Create your own AI that performs better than the ExampleStonePositioner!

You are not allowed any kind of changes outside your StonePositioner implementation (if you want to have multiple classes, you can create your own package, like de.slothsoft.tetris.contrib.nifty for the NiftyStonePositioner).

Of course anyone is allowed to fix bugs in the core framework.

If you're feeling adventurous, you might even feel up to this challenge:

Create your own AI that works with funky stones!

If you have a good AI, push it back into this Git repository (don't forget some identifying JavaDoc or something), because then there might be the next challenge:

Create your own AI that performs better than any other StonePositioner!

Clone this wiki locally
You can’t perform that action at this time.