Videos

Tetris Artificial intelligence (AI)



badmephisto

A program I made with a friend on mine – The computer plays Tetris all by itself! It is by no means a finished project, but at this pace, it will start hunting John Connor very soon.

Source

Similar Posts

50 thoughts on “Tetris Artificial intelligence (AI)
  1. 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

  2. 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…

  3. i know it. i played it. its mean 😀
    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 🙂

  4. 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

  5. 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

  6. " 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

  7. @lieafterlie3 The calculations are NOT simple. PROPER Tetris AI is EASILY just as complex and computing intensive as chess – if not MORE, due to the unknown aspect. With ~24 years of mild Tetris experience, I know the rules. I also understand what's going on in the video. I am just saying that at 1:30, I would not put the "J" where the program put it, creating an unnecessary locked out gap. This AI preferred to clear the bottom line, despite having a better next piece (L) for that.

  8. @lieafterlie3 The AI needs to QUICKLY position the current piece while considering a) the layout of the already placed pieces, b) the shown next piece, and c) the unknown pieces after the next piece. It is EXTRA difficult and essentially, with an ever increasing gameplay speed, the AI has to lose, sooner or later. It will just lose much later than any human ever could – because of the reaction/implementation time losses caused by the human body (even with a perfect mind).

  9. @lieafterlie3 Definitely. There are SO many things an OPTIMUM AI would have to do. For example, not just the optimum position of a piece, but also the actual route there (things can get twisty). Etc. It is EXTREMELY demanding, especially when you consider the time constraints. Chess, on the contrary, is much more straightforward. It has a completely fixed set of choices. There are no unknown future pieces, all pieces are the same fully symmetrical shape (from the chessboard standpoint), etc.

  10. @lieafterlie3 No, the sum of all the factors in chess is not more complicated than the sum of all aspects in Tetris AT ALL. The APPARENT simplicity of Tetris is compensated by other aspects. In chess, the game space cannot get overcrowded, you don't have to get the OPTIMUM result in a fraction of a second, etc. And Tetris and chess are mutually MUCH more different and both highly complex, unlike checkers vs tic tac toe (both simple, tic tac toe much simpler).

  11. @lieafterlie3 It is basically just about what aspects of the games you want the AI to consider. For BASIC gameplay, Tetris IS simpler. For OPTIMUM gameplay, considering all the information available (known + unknown), they're just as complex or Tetris is tougher. And it would still be even if there were just 4 different pieces. Of course that in Tetris, you have to consider the consequences of everything just as well as in chess. It is just a completely different set of problems, but not simple.

  12. @lieafterlie3 Optimum as in highest probability of success. In Tetris, the goal would be the lowest possible overall crowding of the game space + highest readiness of the layout for future known and unknown pieces (in order to keep or increase the emptiness). In chess, the goal would be losing as few pieces as possible (according to general and session-specific piece value), while taking as many pieces of the opponent, preferably the king. As I say, Tetris just looks simpler.

  13. @lieafterlie3 Let me give you this example: It is DEFINITELY easier to run a 100-metre sprint than it is to run a marathon. BUT when aiming for the WORLD RECORD, they're both EXTREMELY difficult and VERY probably, the 100-metre sprint is MORE DIFFICULT.

  14. @lieafterlie3 No, it only STARTS simpler, when the field is empty. Gradually, especially with SUB-OPTIMUM AI which creates unnecessary gaps etc. (such as in this video), you get to a situation, where it gets IMPOSSIBLY difficult. Of course, in chess, there are ALSO situations that are impossible to solve.

  15. @lieafterlie3 The two games have a completely different set of challenges, but the total sum of them is HUGE, in both cases. In any case, the AI will produce the optimum (but certainly NOT ideal) solution in a period of time that is as long as possible. The fact that Tetris makes it necessary to have a solution MANY (e.g. 1,000) times sooner than in chess is a massive obstacle with the same hardware (the same HW being a condition for proper judging of the AI quality/efficiency).

  16. @lieafterlie3 The game space of Tetris is e.g. 11 columns x 18 lines. The AI has to carefully consider all the elements of the current layout of full squares and gaps against the position and legal movement of all the pieces (the current one, the next one, and the future unknown ones, as many pieces ahead as possible). This task requires nearly infinite processing power to make stuff work in real time, not in a slide show. Choice quality has to be sacrificed in order to make the choice on time.

  17. @lieafterlie3 We are talking about a situation, where the AI plays an actual game of Tetris (against a computer) and an actual game of chess (against an advanced human or a high quality AI). Tetris takes place in real time, chess has a much longer time limit (or can be even unlimited, but that would make chess AI a simple brute force joke). So, in practice, Tetris AI HAS to make it sooner (or lose in a few moves).

  18. @lieafterlie3 Tetris AI only has less to do when you WANT it to do less (being far from the achievable optimum). I.e. when you IGNORE things it could do to make success more probable = when you are not trying to make it the BEST POSSIBLE. If you do try to achieve near-perfection, then Tetris AI and chess AI will both use up the entire processing power available and will STILL have to be artificially time limited to comply with the timing requirements.

  19. @lieafterlie3 The original point being that the AI is less complex for Tetris? I don't think that the ultimate Tetris AI is any less complex than the ultimate chess AI (when both are exposed to the same HW and realistic time constraints). The area in chess is several times smaller, the number of pieces is 32 or less, there are strictly predefined ways the pieces are allowed to interact (just like there are predefined shapes of Tetris pieces). For example, you can say both AIs will take TONS

  20. @lieafterlie3 of time to create and optimize. And that is the single most important parameter. You are trying to make it look like the ultimate Tetris AI can be coded in 10 minutes and do its work perfectly in a millisecond, while the ultimate chess AI will be coded in years and do its job only so-so in a minute. I am saying that both the creation and the operation of the ultimate Tetris and chess AIs are very demanding.

  21. @lieafterlie3 It is more difficult to beat the world record in a 100 meter sprint because a) running a 100 meters is easier for everybody than running a marathon, which means that the competition will be very probably tougher (simpler things attract people more in general, you can practice a 100 meter dash many times in the time it takes to run a single marathon etc. – 100 meters are more optimized) and b) there are less people with the genetics required to beat sprint WRs than longer run WRs.

  22. @lieafterlie3 For example, the fastest white guy is 189 cm, the fastest black guys are 191 and 196 cm tall. And the 196 cm tall guy is SO MUCH faster than ANYBODY else that his body height seriosly seems to be THE attribute to have in order to be able to compete with him (if you happen to have the sprinting-essential West African origin for higher testosterone level and more suitable muscle fibres). The white dude is very young, but I doubt he'll push his 9.92 pb much lower when he peaks.

  23. @lieafterlie3 Because he's already a LOT faster than any other white guy ever. I think 9.86 (the European record) is pretty much the maximum he'll ever beat (to 9.85). But it would be nice if I was wrong…

  24. @lieafterlie3 A very complex part of the optimum Tetris AI would have to analyze the current layout for gap patterns from the standpoint of minimizing the blocking of the surface and locked out gaps (which is the main cause of incomplete line build-up, eventually leading to the AI's loss). As I say, a Tetris AI that would be designed to address everything, not just the simple and first-sight stuff, would be extremely complicated – like the optimum chess AI.

Comments are closed.

WP2Social Auto Publish Powered By : XYZScripts.com