A Tetris in C++ for terminal, but with an Evolutionary AI implemented. All genes and values were choosen based on this paper.
I have built a computer player that chooses the best move by rating each possible next-state using an evaluation function. After alot of experimentation, the evaluation function ended up being a weighted sum of these values: Filled Spot Count, Weighted Filled Spot Count, Maximum Altitude, Connected Holes Count, Maximum Well Depth, Number of Lines Cleared, Row Transitions and Hole Count. A genetic algorithm finds optimal weights for the function. A genetic algorithm simulates adaptation, mutation, natural selection, reproduction, chromosome crossover, and evolution.
Each tetris game has an random algorithm implemented for selecting the next tetromino. The original tetris had an unbiased randomizer. No opinion to which piece should come next, just pick one and give it to the player. While an unbiased randomizer offers the greatest pure puzzle challenge to players, it is unstable, and can actually result in an unbeatable sequence. Since the idea of this project is to test the Evolutionary AI, I have implemented a version of the Tetris Worlds random generator. You can read more about how all tetris random algorithm works in this link over here, but in short, the TGM3 algorithm tries to fix the unbeatable sequence problem, and also allows for many building strategies to be consistently viable, which I would love for the AI to find out by itself.