When d=2, my algorithm wins at least 98 times out of 100 the vast majority of the time.
When d=5, my algorithm (and yours too!) should essentially never lose.
My heuristic in Parts B and C is 10 points for each 3-in-a-row found in the game board, and 3 points for each 2-in-a-row. Points are positive for MAX and negative for MIN. A win for MAX is +100000 and a win for MIN is -100000. Note that this heuristic doesn't even look for open spaces on the ends of the 3-in-a-rows or 2-in-a-rows, so it will make dumb moves every so often. But playing against a random player still lets it win most of the time.