My original plan always was to have an AI play the original NES Tetris. But at the time of writing my Java clone, I had no real idea of how to accomplish this. After digging a bit more into console emulators, I found out that the Bizhawk emulator allows you to run Lua scripts. So after reading up on ROM mapping and Lua programming, I rewrote the Java AI and hooked it up to BizHawk.
The program directly reads from RAM to know the state of the game (the playing field and the current tetromino). A complete RAM map for NES Tetris can be found here.
When you keep playing, well past the maximum 999999 score, numbers start to show up partially in hex because not enough space is allocated to them in memory. And just over 1500 lines (represented as F00 ingame) the emulator/rom simply crashes.
Java clone with AI to play the game. Without any knowledge of the next Tetromino, the algorithm is still capable of clearing well over a million lines. The first version looks nice with the colours, but it was much slower. The playing field was still a double array of ints representing the colour. I then switched to a double array of booleans and in the end to a single array of ints between 0 and 1023. With 1023 being 2^10-1, using bitwise operations, you can perfectly represent one row with 10 bits. 1111111111 is a full line, 1000101100 has a block in columns 1, 5, 7 and 8 for example.
Java clone of the previously popular 2048 game. Apart from a Java clone, the application has an AI to play the game by itself. As there is quite some randomness to it and no possibility to undo a move, it is hard to get monster scores. The AI hits the 2048 tile about 80% of the time, 4096 is reached about 15%.