Skip to content

유전 알고리즘으로 구현한 최적의 테트리스 AI

Notifications You must be signed in to change notification settings

JAlthea/Tetris-AI-GeneticAlgorithm

Repository files navigation

Tetris AI

Using Genetic Algorithm, AI of immortal level was implemented.
This project was written in GameMaker Studio 2.
TetrisWithAI.zip
GameMaker Studio 2

Learning example

* Early Generation Play (0 generation)




* Optimized Generation Play (15 generation)

Play video

TetrisPlay_AI_Learning.mp4
TetrisPlay_Battle.mp4

Weights

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

Fitness

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

ResultWeights.txt

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

Execution screen

Battle screen

* User vs AI Play

About

유전 알고리즘으로 구현한 최적의 테트리스 AI

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published