Using Genetic Algorithm, AI of immortal level was implemented.
This project was written in GameMaker Studio 2.
TetrisWithAI.zip
GameMaker Studio 2
* Early Generation Play (0 generation)
* Optimized Generation Play (15 generation)
TetrisPlay_AI_Learning.mp4
TetrisPlay_Battle.mp4
Weight consists of positive and negative factors that affect the game.
For example, if you place a block and it has a lot of space between the blocks, it's not a good idea. We call this Holes.
This means that you can count the number of spaces that occur when a block is placed in a position and use it as a weight.
The weights selected in this way are : MaxHeight, Bumpiness, Holes, CompleteLine
The coefficient of weight x the sum of the corresponding numbers determines the suitability.
weight(n) = c x k (k : the number of the corresponding block)
fitness = weight(1) + weight(2) + ... + weight(n)
When the block is placed in that position, the final decision is to have the highest fitness value.
Real Fitness = MaxHeight + Bumpiness + Holes + CompleteLine
File contains weights arranged in descending order for each generation.
AI set random weights in the beginning, and AI play based on that.
It store the weights in a file at the end of each generation. Of course you can call it up.
Generation : 0 ~ 14 (AI is repeated 11 games for counting an average and the number of blocks is limited to 1000)
Generation : 15 ~ (AI play only 1 game and there is no limit on the number of blocks)
ResultWeights.txt
* User vs AI Play