Working minimax for 3x3 or 4x4