basic implementation of working minimax algorithm