Implementing minimax algorithm for Tic-tac-toe