rewrote minimax. now working!