🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

what AI for a tetris-like game?

Started by
5 comments, last by nicho_tedja 21 years, 8 months ago
What part of AI study is good for a tetris-like game? My compiler generates one error message: "does not compile."
My compiler generates one error message: "does not compile."
Advertisement
dont take my word as im just some random noob, but i dont think an AI is needed in tetris? just drop some random piece at some random location at the top of the window and drop them at a constant speed, then the user move the piece around?
"The bible is probably the most genocidal book ever written!" Noam Chomsky
I think nicho_tedja is talking about a computer player.

All it really needs is for the computer to look at the piece, determine the best fit (maybe one that clears a line asap, or sets up for multiple lines). Then depending on difficulty, put some random errors in it''s "keypresses" to simulate pressing the wrong button and dropping the piece in the wrong spot.

Not too difficult, but then again, I haven''t got to making my ''tris game yet.

£§
£§

I actually implemented a computer player, with succes.

It evaluates every possible position and orientation of a piece, and applies the following rules:

- give one point for every border of the piece that fits.
- add one point if it makes a line
- deduct one point if it makes an error (blank space under piece)
- deduct points if it tries to build higher than middle of tetris-field.

Pick the piece with the highest value. That''s it.

My app usually gets around 20.000 lines before dying. However it is capable of reaching 50.000 lines. An interesting fact is that, because this algorithm is so simple, it makes quite a few ''errors''. These errors aren''t bad though, because they stimulate making more than one line at the time whenever the error is cleared up!
This algorithm usually builds pieces like an ''U'' (lots of pieces at the side).

Hope this helps,

Edo
Edo
Interesting. I''ll have to keep this in mind when I work on my ''tris. Does it tend to develop other patterns? It reminds me of Conway''s The Game of Life, how simple rules can turn into ''intelligent'' behavior.

£§
£§
Actually, you can''t call it ''tris'', or any variant name that includes the syllable ''tris''... copyright infringement already tested in case law a couple of years ago!

An alternative approach to your computer player would be to implement some basic pattern recognition. Or, do a brute force search using a bit representation of the game board.

If you want some idea for ''Conway'' style rules... how about:

1) Try to place the piece as low down the board as possible;
2) Try to lay the piece as flat as possible;

If needs be, add in a third rule:

3) Try to avoid making holes below the piece.

I suspect though that the first two might be enough to create a basic tetris agent.

Cheers,

Timkin
Yea, I knew about the ''tris copyright thing.

Those Conway style rules sound basic enough. I''ll have to try them out when I get to that project.

£§
£§

This topic is closed to new replies.

Advertisement