Tetris game and AI

I made a Tetris game because I felt like I wanted some practise in making simple games and also wanted some more experience with OpenGL and SDL. The game is made according to the Tetris standard (colors/wall-bounce/grid size/etc) but is customizable in all of those areas. I tried to make it cross-platform by using just SDL, OpenGL and SDL_ttf.

After finishing the game I felt like making an AI for it, so I did. :P It is by far not the best AI there is, but it was great practise and it's fun to watch. Initially it did not look at the next piece, but only at the best fitting position for the current piece. It also didn't look at the height of chosen positions. At that time it worked fine, but always kept stacking stuff and eventually died because of a lack of L-blocks. This was when I recorded this video:

(Sorry about the slow motion and glitchy video, it's Youtube's fault...)

After realising that that wasn't a very good AI strategy, I implemented a way for it to look at the next piece. It uses weights to determine the best position for the current piece, while not screwing the next piece over. This required quite some tweaking and should really be automated, but I've got it to a point where it works good enough for me.

It now also looks at heights and gives negative weights for that. For example, if it would receive a constant stream of S-blocks, it would stop stacking them about halfway, and start putting them somewhere else. It always prefers lower spots, even if they don't fit very well.

I'll be putting a source link here soon. For now, here is a zip with windows (32 bit) executables: tetris_windows.zip