In http://youtu.be/-j9AG2I0f3Y I showcased a Tetris AI using a mixed tetromino+pentomino set. THIS video only contains tetrominos. All of the rest of the comments of that video also apply here:
In April 2011, I published the source code to a piece puzzle game here at YouTube. You can see it here: http://youtu.be/V65mtR08fH0
In addition to being playable, the game also had a built-in AI using a state-of-art real-time algorithm by Pierre Dellacherie, extended by me for multi-piece look-ahead. But the video showcased the AI for really quite a short time.
This is a special version in which I showcase tetrominoes only (requested by labobo). Go and watch http://youtu.be/-j9AG2I0f3Y instead.
Background music:
-- Harp song, composed by Bisqwit.
Source code and resources: http://bisqwit.iki.fi/jutut/kuvat/programming_examples/tetre/
The whole video series:
-- http://youtu.be/JDnypVoQcPw -- Creating a rudimentary TETRIS clone in GW-BASIC
-- http://youtu.be/V65mtR08fH0 -- Improving the game by rewriting from scratch C++, added AI
-- http://youtu.be/-j9AG2I0f3Y -- Illustrating the AI's power with tetrominos and pentominos
-- http://youtu.be/ukXDCBewnsg -- Illustrating the AI's power with only tetrominos
-- http://youtu.be/zQZLK8r1NFs -- Illustrating the AI's power with tetrominos, pentominos and hexominos
-- http://youtu.be/7kHnnkVlBKI -- Testing the AI at tackling octominos. Not good.
-- http://youtu.be/Yw02EkQE3Cw -- Illustrating the AI's power with tetrominos on a half-width field.
Wow, that AI sure knows how to play Tetris! I'll look at the code when I get a chance, but I have a question in the meantime:
For me, the best game AI is not always the most efficient. Is the difficulty level of this AI scalable for actual gameplay? It seems that a human player would have a rather tough time prevailing against this. :-)
jwcsh 1 month ago
@jwcsh Yes. The "ply" affects the difficulty level. 1-ply only considers the optimal placement for the current piece, disregarding completely what might come after. 2-ply also considers the next piece, and so on. The algorithm can also be tweaked by adjusting the score coefficients; from what I understand, pretty much any tweaking to the coefficients (the "enum" penalties in AI_Run()) may worsen the AI performance, by making it disproportionally focus on particular traits in the block placement.
Bisqwit 1 month ago
With the AI constantly looking to clear lines, that sort of made sense with the pentaminos. With tetraminos, they should be looking for 4 line scores.
oEQjet 1 month ago
@oEQjet The AI aims for long-term survival. A 1-ply version in non-deathmatch mode casually survives about 650000 lines by average. (This version is 3-ply; I have not profiled how long it survives by average because it's much slower.) Aiming for 4-line scores might max out the score faster, but it also reduces chances of survival, because the pieces are after all granted randomly. Line pieece~!
Bisqwit 1 month ago
@Bisqwit In heads up mode against another AI, 4 line scores help eliminate the opponent! Then again I guess it's all down to your objectives. It sure does survive!
What's the score for clearing 5 lines? That would be absurdly hard to do.
oEQjet 1 month ago
@oEQjet My pentomino set does not include the 5-block line piece that would be required for 5-line clear. Neither is there a score defined for 5-line clears. It should however be 1100 or 1200, times level plus bonuses. (Values for 1,2,3,4 line clears are 100, 300, 500 and 800 respectively.) You are right about eliminating the opponent. However, when playing against an equal opponent, it would make bad demo if both players died before 30 lines.
Bisqwit 1 month ago