Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

C# Tetris AI - The (Near) Perfect Player

JavaScript Is Best Script
Joined
Dec 13, 2010
Messages
631
Reaction score
131
So I spent the entire week writing what had always been my dream since I started programming - A Tetris AI.

To give a brief summary, in every turn,
1) The Tetris AI Exhausts all possible combination of position and orientation for a given Tetromino based on 6 factors - How many lines it will clear, how high will it cause the grid to go, how many holes it will form, how many blockages it will create, how bumpy the resultant grid is, and how many wells it will form.
2) Based on these factors, the Tetris AI will determine, using numerical weights which are the parameters for the AI, the score of each combination. It will then compare the best possible candidate, and use it for the current turn.
3) The cycle then repeats.

Of course, the AI requires parameters which must be optimized properly. To do this we implement the Genetic Algorithm:
1) We start with a few sets of parameters
2) We select the best few out of these sets of parameters
3) We combine the parameters among these sets of parameters in a pair-wise order to create new sets of parameters
4) We then alter these parameters randomly
5) Of these new sets of parameters, we pick those that perform better than their parents in step (2) to form the next sets of parameters.
6) The cycle repeats

To download the source code for this AI, please visit :
Very detailed descriptions can also be found in the above link.

Of course, there is no use copy and pasting everything here, so I prefer to summarize things a bit to give you guys a general idea of how a Tetris AI works.
 
Back
Top