I made some improvements to the code, plus an undefeatable bot. How it works is there's a table with the best move for any position.