Archived

This topic is now archived and is closed to further replies.

Tetris AI

This topic is 5132 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites