The goal is to implement a simple agent that can play the game. In the past, I made one using a GameBoy Emulator with a Genetic Algorithm and a paper was published about it with the title Playing the Original Game Boy Tetris Using a Real Coded Genetic Algorithm, in case you are interested. So now, I plan to experiment more using simpler methods (I suspect that they might be enough). Running it in the browser should allow easier exploration thanks to a more accessible interface and ease of implementation. With the rust core speed should not be an issue. And finally, it allows for easier visualization and divulgation. No more need to compile C code and get hold of a shady Tetris rom.
Below you should be seeing a Tetris game being played with some pretty bad moves. By default a learning agent plays it. A Monte Carlo search looks for which features are good/bad and tries to learn from it. As of the time of writing this it can learn a bit but still is a very bad bot. There is also an option of selecting a Random Agent, which just play random moves. It also plays slower, so it is easier to see what is going on.
The information to the right of the tetris box is contains some usefull information.
lines_cleared shows how many lines have been cleared during the current game and
shows the best result so far. For each strategy that te agent tries it plays 10 games. The
average number of lines cleared during these games is used to score how good/bad it is.
The best mean is shown as
current_mean shows the mean score
of the current iteration. The two next lines shows the weights of each feature.
The top line is best strategy so far while the bottom one is the strategy being
tried. Finally, the last lines shows the features and its respective values for the current
The tetris playing agent is guided by the feature functions multiplied by some weight summed together. This number always is being optimized. A higher number (should) mean a better move. This means that the agent is composed of two optimizers. One tries to learn the best strategy while the other tries to find the best move using the current strategy.
Note: If you are seeing nothing than this means that your browser does not support WASM :( Note2: If you are on mobile the page will probably look like crap :(