implement minimax. fix main.js