The Python and D code contains one extra optimization, it doesn't call the computeBoardScore() method for the leaves, because it wasted computing time.

The original author has also created a further optimized C++ version that performs memoization on the performance-critical function computeBoardScore(). But I have not added this optimization to a D version because of some hard to find performance problem in D associative arrays.