Mechanics of Nintendo Tetris [6502 asm] and how to build a Tetris AI [Lua, Java]