yes the game is first made in python, and then there is an AI module built on top of that. And its much more complicated than if statements :) Classes, method calls, loops etc
there would be no way to "hook" the AI into that program, because its nan executable. I suppose if i had the source I could re-implement the AI in there. but I wouldnt want to do that :)
I would imagine that only the current state of the board is taken into account for the next move, there is no need to take past moves in to account it's not really relevant when playing tetris...
man do you consider past plays? or just evaluate the actual state of the board and the next 2 moves to make? and how exactly do you determine the heuristic from the current board? i am truly impressed! =D
thats the score of the move it just made. And it gets better all the time progressively because it uses an algorithm that determines better ways of playing throughout
no. I have a function that can evaluate a board, and returns "goodness" of that board as a floating point number... so I just loop all possible places to drop this block in, and then run that on all states, and take the max. So it is greedy I suppose. This implementation is not too sophisticated but as you can see it can do quite well. Since then I have developed much more sophisticated techniques, but yes they are all greedy. I think its a suitable approach to the problem.
This is not a complex problem for a computer... the environement is easly specified, the actions are so limited, and the evaluation function is "the less it is heigh the best it is"
hahaha oh man you are so wrong :) That's more like what I thought when I first started the project... little did I know... I urge you to try implement that heuristic you conceived of there. Hilarity will ensue, I guarantee it :p
ok well i've been programming since i was about 6... so about 15 years now. I don't know how hard it is to pick it up from scratch. I would imagine trying Python would be easiest. And maybe getting an actual book for this kind of thing because it provides a clear linear way of making something, and takes you through necessary concepts one by one
Watch out my Tetris playing AI (TetrisAnalyzer), just click on the link "tengstrand". In "Normal mode" showing the next piece and no deep search (Next=On, Level=2), this algorith has made 100,000,000 lines in four days without filling the board more than 55% any time (100 dots on a 10x20 grid). When only knowing the falling piece (Next=Off, Level=1) it makes 1,800,000 lines in average and sometimes > 10,000,000 lines in a speed of over 6000 pieces per second! (on a 2,8 Ghz Pentium).
It's freaky that you can program a computer to play tetris. Is that anything similar to what is happening when you watch a game demo or is a demo just the recording of a human player? Dude you are bringing us closer to judgment day... lets hope this computer doesn't become self aware.
lol! no, you dont have to worry about that. The computer here is just blindly following a set of simple rules that I define for it. Its not really making any type of decisions on its own, its just crunching numbers. There is no danger... yet :)
what did you base the placement and orientation of the piece on? e.g. solving 1 line; solving a few lines; probability of best line completion depending on current state? Also did u ever get into any bad habits with finger tricks on the cube that you got out of?
lol no, i was being serious. i know nothing about programming :) how does the program determine where to put the pieces? i haven't been cubing long enough to make puns! once i get to sub. 30 i'll start making them :p
well we give it simple set of rules it should follow, loop all possible places it could put it in, and run our "evaluation function" of the board on that and try to evaluate how good a board is, and then pick the best and do the corresponding move that leads to it. For example, having holes is bad. Having many blocks is bad. Having places where not too many patterns after this one could fit in is bad. That kind of stuff.
actually, that's false. The program wasn't taught anything. it follows blindly a mathematical formula that I give it. There is much more involved in intelligence. Let me just assure you that unless a huge groundbreaking discovery is made, computers aren't taking over for at least the next 100 years :)
decently long, but not too long. i wrote it long time ago. if i had to guess, just below 1000 or somewhere there. most of it is visual stuff and interface of course
How does this perform on a standard board? I made a Tetris AI but just experimented with different weights. I got tired after completing 40,000 lines, but I'll leave it on overnight and see what happens. I also programmed in Python, and tried many ways to optimize it for speed, so it eliminates 100 lines every 5-6 seconds.
well i'm in a university doing a computer science major, but this program has nothing to do with the kind of stuff we do normally... this is AI & Genetic Algorithms... so in that area i'm completely self-taught
?? what do you mean? i used genetic programing, and the implementation is in python. More or less a guess&check thing, and just pick out the vector of weights that gives best results after a few generations of induced mutations
I am currently in the middle of trying to create the world's best Tetris playing agent for an academic project - at the moment it is already routinely getting over 5 million lines.
Care to try and beat that?
If you are feeling brave the highest 'lines made' by an AI that I can find in a published academic paper is 480 million - they only let that algorithm run once as it took so long to finish!
The AI seems to push blocks on top of covered empty spots, which is bad if the straight doesn't come for a long time (I've died many times in tetris with a full screen and only needing a line). I'd suggest a negative score on dropping on a covered empty.
I think the program simply analyzes the positions and the form of the actual stone and calculates, where it fits best.. that'd be the easiest way in my opinion.
I can do this too, but at last it will go to stage 9 or 10, the blocks will move too fast for anybody to do it. If it always stays at stage '0' like this one, it will never finish either.
that stage thing is arbitrary. It is unlike in real Tetris. That stage is defined in my program for number of times a block drops. But since the AI decides where to drop the block instantly, it has no time to drop... I guess my answer to that is just that that Stage you see there does not really reflect the Stage you would have in a regular tetris. Its not the same thing. Same goes to the Points.
on gameboy advanced tetris you can keep pressing the spin piece button and it never lands then tap left or right and it will rotate over other pieces. using this method level 9 and 1o become much eaiser.
on that particular version it was around 13000. Since i posted this video though i reworked the points system to simply count the number of blocks dropped and reworked the AI kernel altogether, so i am currently in the process of fine-tuning that version. You can expect a video (in the worst case) in around next month... I have tests coming up :)
if this works for tetris battle on facebook...
jackknife0001 3 weeks ago
The song is called TETRISED TO DEATH. LOL
psyaddicted79 11 months ago
the |numbers| go down as the number tetris blocks go down
debit256 11 months ago
welll... it's easy to say that it's much much better than me
timonix2 1 year ago
I want this bot!
Yo're a great man!
FloDBlend 1 year ago
What's the song please ?
Ckrooss 1 year ago
@Ckrooss - I think it's "Road to Zion" from the Matrix soundtrack.
cyborgtroy 1 year ago
" but at this pace, it will start hunting John Connor very soon. "
and then it will become the govenor of california?
nice work, all we need is to have it advance in the levels
kionay 2 years ago 7
I haven't analysed the entire vid, just noticed that at 1:30 it puts that bright green L the other way around...
jakubkrcma 2 years ago
Even though this AI is old, playing against him would be almost like LTris.
nastyguard007 2 years ago
wow awsome
Complexxx123 2 years ago
What's the name of the song?
youkadouka 2 years ago
It's from The Matrix - Clubbed to Death
0176511761 2 years ago
Thx
youkadouka 2 years ago
It was on the matrix, but it's from the artist "Rob D" or Rob Dougan - Clubbed to Death.
jojodi 2 years ago
song?
ceddimo 2 years ago
This has been flagged as spam show
It's from The Matrix - Clubbed to Death
0176511761 2 years ago
That was awesome. Good soundtrack too.
mustangGT33 2 years ago
Comment removed
0176511761 2 years ago
did you have to make the game tetris in python?? and also is this abunch of if then and else lines of programming or is it more complicated
buggyiscool 2 years ago
yes the game is first made in python, and then there is an AI module built on top of that. And its much more complicated than if statements :) Classes, method calls, loops etc
badmephisto 2 years ago
omg sorry for being so interested but how are you running this? did you turn it into a exe gui?? and how did you do tht lol thanks
buggyiscool 2 years ago
HAHHAHAHA funny comment at the end of discription
buggyiscool 2 years ago
I sense future screensaver
Squqdala 2 years ago
Lol, that's cool. 5/5 *
omwashere 3 years ago
What language did you write this in? or whatever..i wanna learn to program stuff like this
justaviewer009 3 years ago 2
from the scrolling side bars it looks like C
generalcircle 2 years ago
Well, the name at the top of the window is "PyTtris". Py being the common prefix for things written in Python.
greyed 2 years ago
LOL, that was cool.
hydrolisk1792 3 years ago
Wow. This really got off topic...
On topic: Is this the speed it really plays at? Looks pretty sick :)
MarkTheWin 3 years ago 4
you should make it able to hook into browser based games, if thats even possible. im sure it is, it would be like cheat engine or mhs
yourtiy 3 years ago
hahaha no...
badmephisto 3 years ago
yeah it would defiantly be possible...
yourtiy 3 years ago
Hey man, I know this game, bastet. It is named after the 2 words, Bastard Tetris.
It calculates what would be the worst block to play with, instead of dropping blocks in random order.
I wonder who would win the game. His ai or yours ;)
If you want to, I could send you a link, it might be interesting!
Daniel
l0ll1ge 3 years ago 2
i know it. i played it. its mean :D
there would be no way to "hook" the AI into that program, because its nan executable. I suppose if i had the source I could re-implement the AI in there. but I wouldnt want to do that :)
badmephisto 3 years ago
I would imagine that only the current state of the board is taken into account for the next move, there is no need to take past moves in to account it's not really relevant when playing tetris...
Dogmeatstew 3 years ago
Is there a place I can download this?
RoboSquc 3 years ago
John Connor has no chance
METALIST1989 3 years ago
man do you consider past plays? or just evaluate the actual state of the board and the next 2 moves to make? and how exactly do you determine the heuristic from the current board? i am truly impressed! =D
Cris7ian86 3 years ago
YAY TSCC...call it the Arab instead of the Turk
plusbonquetoi 3 years ago
test
pcmcg 3 years ago
Oh and one more thing :).. what are the values flowing up on the left?
BociPuki 3 years ago
thats the score of the move it just made. And it gets better all the time progressively because it uses an algorithm that determines better ways of playing throughout
badmephisto 3 years ago
Ah, i get it thx...
BociPuki 3 years ago
wow, I'm really impressed ;).
BTW is this a self improving AI or some sort of pre-made algorythm?
BociPuki 3 years ago
awesome vid... but I spotted some flaws, for example putting the T piece where it would create a gap, other than that, nice job!
lolwutrawr 3 years ago
What programming language did you make this in? Pretty impressing I must say :)
Virtual1ty 3 years ago
wow, insane
lykezomfg11 3 years ago
actually its pretty crappy :). This is an old video, and I've improved it considerably since then. I may upload the new version someday.
badmephisto 3 years ago
cool vid... consider putting the code online to share? uploading onto google code will be great!
cfopbld 3 years ago
:)
loved the description.
Made me laugh :D
mandrewtrow 3 years ago
hi badmephisto, may I inquire as to what search strategy you adopted for this? is it greedy? A* star?
aJack77 3 years ago
no. I have a function that can evaluate a board, and returns "goodness" of that board as a floating point number... so I just loop all possible places to drop this block in, and then run that on all states, and take the max. So it is greedy I suppose. This implementation is not too sophisticated but as you can see it can do quite well. Since then I have developed much more sophisticated techniques, but yes they are all greedy. I think its a suitable approach to the problem.
badmephisto 3 years ago
because it's totally impossible to hear one song too many times...
stapledtodeath 3 years ago
This is not a complex problem for a computer... the environement is easly specified, the actions are so limited, and the evaluation function is "the less it is heigh the best it is"
elbombardi 3 years ago
hahaha oh man you are so wrong :) That's more like what I thought when I first started the project... little did I know... I urge you to try implement that heuristic you conceived of there. Hilarity will ensue, I guarantee it :p
badmephisto 3 years ago
have you got the source code for this? fancy distributing it? google code is nice ;)
cubist6 3 years ago
:O Nice, <3 AI
Personaboutspeed 3 years ago
i've always wondered..is it possible to beat tetris.. like deplete all the blocks.. and boom! you become champion of the world!
qibs 3 years ago
well... no. And you cant even beat tetris. There exists a sequence of blocks which I can give you to guarantee that you loose.
badmephisto 3 years ago
What is it??
Paroxymic 3 years ago
sure you can beat tetris, at least a version ive seen.
when you win mario and his friends come on the screen lawl
kohlner 3 years ago
Chuck Norris did it, he bet tetris...^^
Drache198 3 years ago
hehe.. hunting down John Conner. That'd be sweet
hosweetim89 3 years ago
...one block at a time :)
badmephisto 3 years ago
His days are numbered. >=)
hosweetim89 3 years ago
I want to learn to do this,is it hard?what should I study?
Fenrirgear 3 years ago
well depends on your age and programming experience. I use python to do my programming usually. Pygame is the library used to do the actual graphics
badmephisto 3 years ago
XD sorry I have no experience,im 17 and about to go to college,but I want to learn,any tips?
Fenrirgear 3 years ago
ok well i've been programming since i was about 6... so about 15 years now. I don't know how hard it is to pick it up from scratch. I would imagine trying Python would be easiest. And maybe getting an actual book for this kind of thing because it provides a clear linear way of making something, and takes you through necessary concepts one by one
badmephisto 3 years ago
alright I´ll save for a laptop,and when im ready may I ask where to dowload or buy this programm?really,thanks.I need to begin working hard
Fenrirgear 3 years ago
Can it lose?
Swamy456 3 years ago
Song is from Matrix :p
Nice program, looks great !
Shuya0212 3 years ago
Song is familiar but I can't remember what it's from.
Bandaid327 3 years ago
Nissan Maxima commercial
khoavuong 3 years ago
Watch out my Tetris playing AI (TetrisAnalyzer), just click on the link "tengstrand". In "Normal mode" showing the next piece and no deep search (Next=On, Level=2), this algorith has made 100,000,000 lines in four days without filling the board more than 55% any time (100 dots on a 10x20 grid). When only knowing the falling piece (Next=Off, Level=1) it makes 1,800,000 lines in average and sometimes > 10,000,000 lines in a speed of over 6000 pieces per second! (on a 2,8 Ghz Pentium).
tengstrand 3 years ago
Testing...
tengstrand 3 years ago
At 0:42 you can clearly see that the AI is "waiting" for a yellow block to maximize points... freaky :)
Elviejodragon 3 years ago
It's freaky that you can program a computer to play tetris. Is that anything similar to what is happening when you watch a game demo or is a demo just the recording of a human player? Dude you are bringing us closer to judgment day... lets hope this computer doesn't become self aware.
rwc82 3 years ago
lol! no, you dont have to worry about that. The computer here is just blindly following a set of simple rules that I define for it. Its not really making any type of decisions on its own, its just crunching numbers. There is no danger... yet :)
badmephisto 3 years ago
Looked like some sort of TAS, nice.
flygonbreloom 3 years ago
what did you base the placement and orientation of the piece on? e.g. solving 1 line; solving a few lines; probability of best line completion depending on current state? Also did u ever get into any bad habits with finger tricks on the cube that you got out of?
edga69 3 years ago
lol is that a series of terrible puns?
badmephisto 3 years ago
lol no, i was being serious. i know nothing about programming :) how does the program determine where to put the pieces? i haven't been cubing long enough to make puns! once i get to sub. 30 i'll start making them :p
edga69 3 years ago
well we give it simple set of rules it should follow, loop all possible places it could put it in, and run our "evaluation function" of the board on that and try to evaluate how good a board is, and then pick the best and do the corresponding move that leads to it. For example, having holes is bad. Having many blocks is bad. Having places where not too many patterns after this one could fit in is bad. That kind of stuff.
badmephisto 3 years ago
OMG i thought i was a good programmer s*t man this is good
simkinggold101 3 years ago
cool :D and python is great language :S but i have must use c# and php for my job:S :P
tuuvana 3 years ago
C(dammit, apple keyboard, no hash)? **throws up**
drdude12472 3 years ago
you can just press alt-3 to get #
stoggeh 3 years ago
Me <3 python
m0nkeysensei 3 years ago
What language is it written in? and is there any way you would put up parts of the source for me to look over dumbfounded? :p
m0nkeysensei 3 years ago
its python, and no :) the code is a mess :p
badmephisto 3 years ago
dude, if you teach a computer to play tetris then it's only a matter of time before the machines take over!
chorkybrenner 3 years ago
actually, that's false. The program wasn't taught anything. it follows blindly a mathematical formula that I give it. There is much more involved in intelligence. Let me just assure you that unless a huge groundbreaking discovery is made, computers aren't taking over for at least the next 100 years :)
badmephisto 3 years ago
buzzzz killer
JoeJoeBobJoe 3 years ago
cool. How long is the program?
kg6abb 3 years ago
decently long, but not too long. i wrote it long time ago. if i had to guess, just below 1000 or somewhere there. most of it is visual stuff and interface of course
badmephisto 3 years ago
nice idea. i would like to know how that algorithm works.
xxfoobarxx 4 years ago
Very good job!
ontological7 4 years ago
so the computer THINKS in which to put the piece in a postition on it's own?
ryancyrus1 4 years ago
ummm... i suppose so? it's got a genetic algorithm to help it figure out where to put a piece yes
badmephisto 4 years ago
i wonder what would the programming code would do if the blocks got to the top and it lost?
tjhynson 4 years ago
well... that's pretty easy to asnwer: the game would restart... lol?
badmephisto 4 years ago
The tetris AI apocalypse is coming soon thanks to gentlemen like you. X)
Madnam 4 years ago
Amazing idea!
barrym87 4 years ago
nice one!!! :)
hyssp 4 years ago
cool
plurple73 4 years ago
But it doesn't look half as pretty as yours =(
faenix 4 years ago
How does this perform on a standard board? I made a Tetris AI but just experimented with different weights. I got tired after completing 40,000 lines, but I'll leave it on overnight and see what happens. I also programmed in Python, and tried many ways to optimize it for speed, so it eliminates 100 lines every 5-6 seconds.
faenix 4 years ago
where did you learn how to do that??
Motorbreath23 4 years ago
well i'm in a university doing a computer science major, but this program has nothing to do with the kind of stuff we do normally... this is AI & Genetic Algorithms... so in that area i'm completely self-taught
badmephisto 4 years ago
Very cool video, 5 stars and a comment from me.
stompy243243 4 years ago
That looks pretty good!
jnoort 4 years ago
hi joel, thanks! Please get your site back up I need it, kthx :)
badmephisto 4 years ago
very good job... Which AI tool did you use for solving it?
jcrada82 4 years ago
?? what do you mean? i used genetic programing, and the implementation is in python. More or less a guess&check thing, and just pick out the vector of weights that gives best results after a few generations of induced mutations
badmephisto 4 years ago
Good job...keep working ;)
theredd3vil 4 years ago
great job
majdijr 4 years ago
Not a bad start.
I am currently in the middle of trying to create the world's best Tetris playing agent for an academic project - at the moment it is already routinely getting over 5 million lines.
Care to try and beat that?
If you are feeling brave the highest 'lines made' by an AI that I can find in a published academic paper is 480 million - they only let that algorithm run once as it took so long to finish!
Ikkath 4 years ago
The AI seems to push blocks on top of covered empty spots, which is bad if the straight doesn't come for a long time (I've died many times in tetris with a full screen and only needing a line). I'd suggest a negative score on dropping on a covered empty.
sabriath 4 years ago
what's the name of the song?
baiwldrnner 4 years ago
clubbed to death, its from matrix
badmephisto 4 years ago
did you train it by inputing the moves of a human player?
zamazalotta 4 years ago
I think the program simply analyzes the positions and the form of the actual stone and calculates, where it fits best.. that'd be the easiest way in my opinion.
MrKohlenstoff 4 years ago
I can do this too, but at last it will go to stage 9 or 10, the blocks will move too fast for anybody to do it. If it always stays at stage '0' like this one, it will never finish either.
uytfvbnmkoiuy 5 years ago
that stage thing is arbitrary. It is unlike in real Tetris. That stage is defined in my program for number of times a block drops. But since the AI decides where to drop the block instantly, it has no time to drop... I guess my answer to that is just that that Stage you see there does not really reflect the Stage you would have in a regular tetris. Its not the same thing. Same goes to the Points.
badmephisto 5 years ago
on gameboy advanced tetris you can keep pressing the spin piece button and it never lands then tap left or right and it will rotate over other pieces. using this method level 9 and 1o become much eaiser.
pipsalot 4 years ago
What is the record??
TheRealKuif 5 years ago
on that particular version it was around 13000. Since i posted this video though i reworked the points system to simply count the number of blocks dropped and reworked the AI kernel altogether, so i am currently in the process of fine-tuning that version. You can expect a video (in the worst case) in around next month... I have tests coming up :)
badmephisto 5 years ago
hmm intresting... quite complex isn't it?
TheRealKuif 5 years ago