I'm now finished with a first brand new version of Tetris Analyzer 2.0.01 written in Scala. It is almost as fast as the C++ version (you need to hide next piece with 'n' and press 'm' for max speed). You can download it from here: tetrisanalyzer.tengstrand.nu.
I have now released the C++ source code at sourceforge, project tetrisai (the URL wasn't accepted by Youtube). The algorithm that evaluates a board position is performed by method evaluate() in class BrainJote20. Im working with a conversion to Scala and is blogging about it here tengstrand.blogspot.com. You may need to translate it if you are not familiar with Swedish!
At time 4:47, pice number 999330 (T followed by S), the AI ranks move 21 (two rotations, x-position=1) as the best and move 16 as the second best (only +0.063 difference). It plays on level 2 and the AI does not take the next unknown piece after T and S into account. I don't think this is a big mistake, but if playing at level 3 it may prefer 16 as this move will leave more alternatives open for the piece after S (it calculates the average of the seven possible pieces on level 3).
Ive seen some inefficient moves here like that green T on 4:47 when your AI was waiting for S or CRAZINESS on 5:01 ;D ;p but GJ :D what kind of AI is it ? hand written or based on genetic programming or something else ? How many knowledge have your AI about the future sequence of tetris shapes(tetrominoes), does it knows only the shape of the next ? Heve you tried to write AI that : - Maximizing the number of simultaneous clearing of four rows ?
@plmqas At 5.01, piece number 999362 (J followed by S) knows he can slide the S under J. I have thought about this and a possible solution would be to only allow the AI to slide one step, not two or more as in this example. BR, Joakim T
I can release it on SourceForge (an open source community) where I also have other projects. This can take a couple of weeks, I'm on vacation right now, I will announce it here when it's done! This version is written in C++ and compiled in an old version of Microsoft Visual C++. I'm glad you like it, It's the strongest Tetris AI on the planet! :-)
If the Tetris engine don't know that the random generator will pick the worst possible piece all the time then the current version will put the pices quite well, but not optimal. I would need to change the algorithm to take this into account. I don't know how well TettisAnalyzer will do if making this change. If the generator only generates for example 'S' pieces, then there is no way to survive.
@tengstrand but let's say the pieces aren't random at all, and it would always give you the worst possible piece at all times. aka the game working against you. How would that change the placement of the pieces you actually do get?
Very well done I'm impressed! So what is your algorithm like? Do you have some kind of genetic algorithm? Or is it just a heuristic search? Do you have some function of 'goodness' for a particular board that you use? Lastly, what programming language is that? very nice
Hi! Glad to hear you like my little program! It was developed 2001-2002, and some improvements 2003-2004. It is written in C++ (the first version was in Java). It evaluates every possible possition and choose the one with the lowest value. It measures three properties: gaps, regions with "walls" on both sides, and the height of the outline. The "evaluate" function is only 115 rows (comments and empty lines included). The different "evaluate" parameters has been tuned by a program written by me.
I'm now finished with a first brand new version of Tetris Analyzer 2.0.01 written in Scala. It is almost as fast as the C++ version (you need to hide next piece with 'n' and press 'm' for max speed). You can download it from here: tetrisanalyzer.tengstrand.nu.
tengstrand 6 months ago
I have now released the C++ source code at sourceforge, project tetrisai (the URL wasn't accepted by Youtube). The algorithm that evaluates a board position is performed by method evaluate() in class BrainJote20. Im working with a conversion to Scala and is blogging about it here tengstrand.blogspot.com. You may need to translate it if you are not familiar with Swedish!
tengstrand 1 year ago
Hi!
At time 4:47, pice number 999330 (T followed by S), the AI ranks move 21 (two rotations, x-position=1) as the best and move 16 as the second best (only +0.063 difference). It plays on level 2 and the AI does not take the next unknown piece after T and S into account. I don't think this is a big mistake, but if playing at level 3 it may prefer 16 as this move will leave more alternatives open for the piece after S (it calculates the average of the seven possible pieces on level 3).
tengstrand 1 year ago
or minimizing the height of the highest filled grid square over the course of the sequence ?
plmqas 1 year ago
Ive seen some inefficient moves here like that green T on 4:47 when your AI was waiting for S or CRAZINESS on 5:01 ;D ;p but GJ :D what kind of AI is it ? hand written or based on genetic programming or something else ? How many knowledge have your AI about the future sequence of tetris shapes(tetrominoes), does it knows only the shape of the next ? Heve you tried to write AI that : - Maximizing the number of simultaneous clearing of four rows ?
plmqas 1 year ago
@plmqas At 5.01, piece number 999362 (J followed by S) knows he can slide the S under J. I have thought about this and a possible solution would be to only allow the AI to slide one step, not two or more as in this example. BR, Joakim T
tengstrand 1 year ago
Did you release the source code?
Nitrooo84 1 year ago
@Nitrooo84 No its not released on SF yet. I will let you know when it is! Im quite busy right now. BR, Tengstrand
tengstrand 1 year ago
@tengstrand
Thanks in advance =)
Nitrooo84 1 year ago
I know SourceForge, it would be really great :)
have a nice time on vacation :D
greetings
ichschreibemeinen 1 year ago
@ichschreibemeinen No it's not released on SF yet. I will let you know when it is!
tengstrand 1 year ago
I can release it on SourceForge (an open source community) where I also have other projects. This can take a couple of weeks, I'm on vacation right now, I will announce it here when it's done! This version is written in C++ and compiled in an old version of Microsoft Visual C++. I'm glad you like it, It's the strongest Tetris AI on the planet! :-)
tengstrand 1 year ago
I was wondering if you would like to share this awesome piece of software ;)
Only if you still have it, of course.
just mail me,
greetings
ichschreibemeinen 1 year ago
Sorry, you can survive if you get only S pieces, but not if you get only S and Z pieces.
tengstrand 1 year ago
If the Tetris engine don't know that the random generator will pick the worst possible piece all the time then the current version will put the pices quite well, but not optimal. I would need to change the algorithm to take this into account. I don't know how well TettisAnalyzer will do if making this change. If the generator only generates for example 'S' pieces, then there is no way to survive.
tengstrand 1 year ago
@tengstrand but let's say the pieces aren't random at all, and it would always give you the worst possible piece at all times. aka the game working against you. How would that change the placement of the pieces you actually do get?
timonix2 1 year ago
Very well done I'm impressed! So what is your algorithm like? Do you have some kind of genetic algorithm? Or is it just a heuristic search? Do you have some function of 'goodness' for a particular board that you use? Lastly, what programming language is that? very nice
badmephisto 3 years ago
Hi! Glad to hear you like my little program! It was developed 2001-2002, and some improvements 2003-2004. It is written in C++ (the first version was in Java). It evaluates every possible possition and choose the one with the lowest value. It measures three properties: gaps, regions with "walls" on both sides, and the height of the outline. The "evaluate" function is only 115 rows (comments and empty lines included). The different "evaluate" parameters has been tuned by a program written by me.
tengstrand 3 years ago
The list of possible moves starts with 'vx'. v = number of rotations, x = x-possition of the piece (left side).
tengstrand 3 years ago