Almost working but there is still some bug with the minimax algorithm.