Advertisement

Tetris AI

Started by November 27, 2003 07:05 AM
5 comments, last by DirectXXX 21 years, 2 months ago
can some one give me an idea how to make ai for solving tetris. I have a console game which has a computer player, which plays very nice.
3D Side-Scroller game demo Project-X2 "playable"Lashkar: A 3D Game & Simulation Project demo @ lashkar.berlios.de
I can give you an idea, but I''m not sure how good of one it is.

Create a big state table for dealing with many different situations. There can only be so many after all, since the longest tetris piece is 4 blocks. Therefore, you need to generate table to deal with EVERY possibility within a WIDTH*4 block section.

This shouldn''t be too hard. If you want to be experimental you could use a genetic algorithm to find these solutions.

Hope this helps somehow.

Will

------------------http://www.nentari.com
Advertisement
Here is how I would go about doing it...

When the peice arrives on sceen, the computer calculates where it will put it (obviously). Here is how it does that:

Start at the colom to the far left. Calculate what the scene would look like if we (when I say ''we'' in AI I basicly mean the AI) were to put the block there, then use some kind of evaluation function to get a value for the scene, call it v. Then move one colom to the right, and repeat the process, each time giving the colom a v (store in an array or something of the sort). When that has been done for every color, rotate the peice (not literally on screen) and then redo the evaluation for each color. Do this until every possible move has been assigned a v. Then, simply chose the move with the lowest v (by ''move'' I mean a color and a rotation).

The evaluation function is obviously the difficult part. I recommend getting the v based upon how many blocks we will get horrizontally minus how many gaps we will create with blocks sitting above them. The easiest way is probably to evaluate the whole grid.

Anyhow, that is how I might go about it...
http://www.colinfahey.com/2003jan_tetris/2003jan_tetris.htm
thats good info to start out. thanx
3D Side-Scroller game demo Project-X2 "playable"Lashkar: A 3D Game & Simulation Project demo @ lashkar.berlios.de
We''ve got an AI lecturer at uni that made an AI for tetris, but it wasn''t an AI that played tetris, it was an AI that fed you blocks.

To play the game you had to get hooked up to all sorts of sensors, and then as you played the game would measure when you got excited. The AI got positive reinforcement for making you excited, and negative reinforcement for making you bored.

I know this isn''t really what your looking for, but i thought it was a really cool idea. Its a shame i never got to see his version of tetris in action.
Advertisement
I agree, check out Colin Fahey''s site. He has tons of info. It''s not too hard to do tetris AI if you put a little thought into it. Mine did a simple search with an evaulation function and was able to play into the 100s of thousands of lines completed a game.

I think Colin''s latest can do 20 million lines or so.

This topic is closed to new replies.

Advertisement