I've never been quite sure what people mean by PPR and I strongly recommend against using whatever you think it means over actually thinking the endgame through because in many cases buying the PP is what maximizes your win % even if it "seems risky", but I guess it would be something like this:
gainPriority: (state, my) -> [
"Province" if my.ai.buyProvince(state, my)
[...]
getScore: (state, my) ->
for status in state.getFinalStatus()
[name, score, turns] = status
if name == my.ai.toString()
myScore = score
else
opponentScore = score
return myScore - opponentScore
buyProvince: (state, my) ->
scoreDiff = my.ai.getScore(state, my)
boolDiff = (scoreDiff < 0 and scoreDiff > -3)
boolPP = (state.countInSupply("Province") == 2)
return not (boolDiff * boolPP)
The "> -3" part is there because if a Duchy doesn't even put you ahead, your best shot is almost certainly (in a silly BM mirror at least) to buy both Provinces, something that's impossible without buying the penultimate one.
Some brief testing on 40k games of JourneymanBM showed including this PPR rule made no significant difference, which is about what I'd expect because it's so highly situational.